On Tue, Mar 22, 2011 at 5:26 PM, shadowlaw <[email protected]> wrote:

> hi guys,
>
> i project a classical groovy project structure like  this:
>
> myProject
>     src/main/groovy/
>     lib
>
> so i want is download my dependencies from maven repositories to the lib
> file and make them available in the classpath just like maven, so i've
> wrote
> the following gradle build file
>

Gradle does this for you without needing to copy the dependencies:


>
> buildscript {
>        repositories {
>                mavenCentral()
>        }
>        dependencies {
>                classpath "commons-io:commons-io:1.4"
>                classpath "org.codehaus.groovy.modules:groovyws:0.5.2"
>                classpath "log4j:log4j:1.2.15"
>        }
> }
>
>
> apply plugin : 'java'
> apply plugin : 'groovy'
>
> archivesBaseName= 'webservice'
>
> //permet de specifier le folder ou le jar sera deployer
> libsDirName = "../lib"
>
> configurations{
>        compile{
>                transitive = true
>        }
>        runtime{
>                 extendsFrom compile
>        }
> }
>
> task copyToLib(dependsOn:configurations.default.buildArtifacts ,type:
> Copy){
>        into libsDirName
>        from configurations.compile
> }
>
> task listJars << {
>        configurations.compile.each { File file -> println file.name }
> }
>
> dependencies{
> //      lib = "$projectDir/lib"
> //      groovy files(fileTree(dir: lib as File, includes: ['*.jar']))
>        compile : 'org.codehause.groovy:groovyws:0.5.2'
>        compile : 'log4j:log4j:1.2.15'
> }
>
> repositories{
>        mavenCentral()
> //        flatDir name: 'localRepository', dirs: 'lib'    // Not necessary
>
}
>
> compileJava {
>        classpath.each {
>                println "Found dependency: $it"
>        }
> }
> it seems that gradle is comiling my project coeectly but i can't see my
> dependencies in the lib folder and of corse i cannot do any importe of
> classes in groovy files. did i mess up something
>

You need a task to copy to the lib directory.  e.g.
compileJava.dependsOn("copyToLib")

// or maybe processResources.dependsOn("copyToLib")

By default, gradle will download from the maven repo to the ~/.gradle/cache
directory, the printing of classpath should have shown that.
Why would you want to copy to the lib dir, unless you are specifically
trying to create a distribution with all dependencies included (e.g. a zip
distribution)?

>
> --
> View this message in context:
> http://gradle.1045684.n5.nabble.com/pb-configuraing-gradle-tp4257046p4257046.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


-- 
Brett Cave
Systems Architect
Jemstep, Inc

www.jemstep.com

Reply via email to