On 23/03/2011, at 2:26 AM, shadowlaw 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
>
> 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"
> }
> }
You shouldn't need a buildscript { } closure, as this is for dependencies of
the build script itself, not the classes of the project.
>
>
> 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
> }
> }
You shouldn't need the above configurations { } section, as it is simply
setting up the defaults.
>
> task copyToLib(dependsOn:configurations.default.buildArtifacts ,type: Copy){
> into libsDirName
> from configurations.compile
> }
You shouldn't need this task, unless you want to copy the dependencies to a lib
directory for some reason other than compiling.
>
> 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'
You should get rid of the colon between compile and the dependency, for example:
compile 'log4j.log4j.1.2.5
> }
When using the groovy plugin, you also need to tell Gradle which Groovy
implementation to use:
dependencies {
groovy 'org.codehaus.groovy:groovy:1.7.10'
}
>
> repositories{
> mavenCentral()
> flatDir name: 'localRepository', dirs: 'lib'
> }
You shouldn't need the flatDir repository.
>
> 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
>
> --
> 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
>
>
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support,
Consulting
http://www.gradleware.com