Hello,

I start playing with gradle a few days ago... as a maven refugee. I've read the manual and been making my way through the mailing list archive as I run into things. It's been a lot of fun so far and I definitely like the flexibility.

My setup is a little odd but I noticed something interesting that I thought I'd point out. Maybe this is known information. I'll give some background first in case any of it is relevant... sorry for being long-winded.

Since I'm playing around with an existing and working multi-project ant build, I'm leaving the one big source tree in place and just using a tree of sibling project directories to play with maven and gradle.

Sort of like:
dev
 build.xml
 /src/main/java/foo
 /src/main/java/bar
 /src/test/java/foo
 ...etc.

I then create sub-directories for foo and bar to put build.gradle files in and have a dev-level build.gradle and settings.gradle. In the main build.gradle file I inject a relative srcRootName into the sub-projects along with the other standard stuff:

dev/build.gradle:
---------------------------------
dependsOnChildren()

subprojects {
    usePlugin('java')
    usePlugin('maven')

    sourceCompatibility = 1.5
    targetCompatibility = 1.5
    group="my-group"
    version="0.42.1"

    srcRootName = "../src"

    dependencies {
        addMavenRepo()
        testCompile "junit:junit:4...@jar"
    }
}
--------------------------------------

In the individual files I do something like, dev/foo/build.gradle:
--------------------------------------
compile {
    include( "foo/**" )
}

testCompile {
    include( "foo/**" )
}
--------------------------------------

All of this works great... with one small issue. If sub-project "bar" depends on sub-project "foo", like dev/bar/build.gradle:
--------------------------------------
dependsOn( ":foo" )

compile {
    include( "bar/**" )
}

testCompile {
    include( "bar/**" )
}
--------------------------------------

(and if any of its classes refer to foo classes as they would likely) then some of foo's classes will be compiled by javac. After all, javac has the source directory and doesn't seem to know that the classes already exist.

For anyone else doing something like this, I have found a work-around:
dependencies {
    compile project( ":foo" )
}

...will keep the extra classes from getting compiled into the separate "bar" project and everything works like one would expect. Otherwise, you end up with a lot of duplicate .class files.

I don't have a normal set of projects to try so maybe this is how you always have to do it? But it seemed a bit redundant if so. I thought if this hadn't been mentioned before then someone might hit this... or maybe it will get fixed.

Thanks for the nifty new toy.
-Paul


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to