On Oct 8, 2008, at 7:50 PM, Hans Dockter wrote:

<snip>


I suspect we should do the isolated classloader thing for java compiles too, as the javac tool uses its (context?) classloader to find classes which are not supplied on the compile classpath.

This is not necessary. The Ant javac task has an 'includeAntRuntime' property. If this is true the path of the context classloader is part of the compile classpath. Surprisingly it defaults to true when doing an ant build, which is slightly hilarious. I don't know the historic reasons for this. The Gradle AntJavac class sets this to false. So we have isolation here.

I don't know where my mind was when I have written this. The classpath for running the isolated Ant script should not affect the groovyc compile either. But we have to explicitly say so in two places. The first includeAntRuntime only applies to the Groovy compile. We have also set it for the nested javac element.

Current Version:
groovyc(
        includeAntRuntime: false,
srcdir: '${sourceDirs.collect {GradleUtil.unbackslash (it)}.join(':')}',
        destdir: '${GradleUtil.unbackslash(targetDir)}',
classpath: '${classpath.collect {GradleUtil.unbackslash (it)}.join(':')}',
        verbose: true) {
${groovyIncludes.collect {'include(name: \'' + it + '\')'}.join('\n')} ${groovyExcludes.collect {'exclude(name: \'' + it + '\')'}.join('\n')} javac([source: '${sourceCompatibility}', target: '$ {targetCompatibility}'] + ${filterNonGroovycOptions(compileOptions)}) { ${groovyJavaIncludes.collect {'include(name: \'' + it + '\')'}.join('\n')} ${groovyJavaExcludes.collect {'exclude(name: \'' + it + '\')'}.join('\n')}
        }
    }

Fixed version:
groovyc(
        includeAntRuntime: false,
srcdir: '${sourceDirs.collect {GradleUtil.unbackslash (it)}.join(':')}',
        destdir: '${GradleUtil.unbackslash(targetDir)}',
classpath: '${classpath.collect {GradleUtil.unbackslash (it)}.join(':')}',
        verbose: true) {
${groovyIncludes.collect {'include(name: \'' + it + '\')'}.join('\n')} ${groovyExcludes.collect {'exclude(name: \'' + it + '\')'}.join('\n')} javac([includeAntRuntime: false, source: '$ {sourceCompatibility}', target: '${targetCompatibility}'] + $ {filterNonGroovycOptions(compileOptions)}) { ${groovyJavaIncludes.collect {'include(name: \'' + it + '\')'}.join('\n')} ${groovyJavaExcludes.collect {'exclude(name: \'' + it + '\')'}.join('\n')}
        }
    }

I guess this should solve our problems with compile. It shouldn't stop us from modularizing :)

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





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

   http://xircles.codehaus.org/manage_email


Reply via email to