Dear Gradle friends,

It's been a very long time for me since I've been involved with Gradle.
You've been doing a fantastic job over the past couple of months and the
result is just stunning.

I've gotten hooked - again - to Gradle and started playing with it for fun
and self-education. Right now I'm trying to port Spring from Ant to Gradle
but I've run into some compile weirdnedd. This is why I'm seeking your help.
I'm using Gradle 0.8.

I won't lay out the details of my entire setup, it's Gradle so it's pretty
simple. I've uploaded a zip file containing the spring source and my build
logic for those of you interested here:

http://drop.io/29t58yo (48Mb)

The crux of the matter is this: I've added a project spring-beans which gets
its source code from the big spring src/ directory. Normally my build file
for spring-beans looks like this:

compileJava {
source = fileTree {
from src_dir
include "org/springframework/beans/**"
exclude "org/springframework/beans/factory/aspectj/**"
}
}

dependencies {
compile project(':src:spring-core')
compile ':cglib-nodep-2.1_3'
}


Pretty basic stuff, only it doesn't work. What happens, and you can try this
yourself ("gradle clean build upload" from the project root), is that
CompileJava is trying to compile files from the org.springframework.core
package which it shouldn't touch and for which it is missing JARs on the
class path.

I've changed my build file as follows and this does work:

compileJava.doFirst {
def temp_src_dir = file('build/temp/src')
temp_src_dir.mkdirs()

copy {
from src_dir
into temp_src_dir
include "org/springframework/beans/**"
exclude "org/springframework/beans/factory/aspectj/**"
}
}

compileJava {
source = fileTree('build/temp/src')
}

dependencies {
compile project(':src:spring-core')
compile ':cglib-nodep-2.1_3'
}

Works but doesn't look as slick. I'm at a loss to explain why the normal
case doesn't work and why separating the intended code does work. The only
thing I can think of is that the compiler first checks the source folder for
classes it needs and only afterwards the class path. Is this a known
problem? I've checked the issues in JIRA but nothing jumped me in the eye.

Thanks for your help

Steven

Reply via email to