Simple build script to just copy dependencies to folder?

I have an existing app built with Ant. I had tried integrating Ivy, but I hit roadblocks with downloading timestamped snapshots, so I gave up on that tack.

I’ve built a preliminary Gradle build script that just specifies the dependencies, and I’d like to just have this build script copy all of the specified dependencies into the “lib” directory. I found a SO post that talked about this, and I just copied in the part that supposedly copies the dependencies, but it doesn’t appear to work. I don’t fully understand the syntax of what that task is doing yet.

This is what I have so far:

apply plugin:'java'
  repositories {
    maven {
        url "~/.m2/repository"
    }
    maven {
        url "http://==hostandport==/nexus/content/repositories/cditspoc-snapshots"
    }
    maven {
        url "http://==hostandport==/nexus/content/repositories/cditspoc-3rd-party"
    }
    mavenCentral()
}
  configurations {
    compile {
        transitive
= false
    }
}
  dependencies {
    compile "com.att.ecom.poc:poc-domain-model:0.0.1-SNAPSHOT"
    compile "org.apache.commons:commons-lang3:3.1"
    compile "org.springframework:spring-aop:4.0.0.RELEASE"
    compile "org.springframework:spring-beans:4.0.0.RELEASE"
    compile "org.springframework:spring-context:4.0.0.RELEASE"
    compile "org.springframework:spring-core:4.0.0.RELEASE"
    compile "org.springframework:spring-expression:4.0.0.RELEASE"
    compile "org.springframework:spring-web:4.0.0.RELEASE"
    compile "com.oracle.coherence:coherence:12.1.2-0-0"
}
  task copyToLib(type: Copy) {
    into "$buildDir/lib"
    from configurations.runtime
}
  build.dependsOn(copyToLib)

When I just do “gradle build”, it does this:

% gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:copyToLib UP-TO-DATE
:build UP-TO-DATE
  BUILD SUCCESSFUL
  Total time: 1.603 secs
% ls lib
./
../

As you can see, nothing was copied to the “lib” directory. I know it’s saying “UP-TO-DATE”, which is another problem. When I ran this the first time, it didn’t print that on the “copyToLib” line, but it also didn’t copy any of the dependencies.

I need to understand the right way to do this.

For the most part, it looks like you have it. $buildDir/lib will resolve to “build/lib” though, not “lib”. Check whether you have a build directory in your project and a lib directory in build with your dependencies. Most likely you do. You can also run the task straight without running the build task. Just run “gradle copyToLib”.

You probably checked the wrong directory. Also, subsequent task executions see that you already copied the files which makes the task UP-TO-DATE.

Yeah, well, I TRIED to reply saying that I figured this out, but as I described on the other thread, it never completed the posting. I’m trying again now.