On 3/03/10 4:43 AM, Russel Winder wrote:
I think I can now express the problem I am having with the Gradle build of Gant -- which only affects the tests, everything else seems fine. Some of the Gant unit tests are actually system tests: in particular, the tests for the Gant Ant task. The XML code used by the Ant process spawned from the JUnit tests uses the<gant . . .> task. This means that the location of the compiled classes of Gant has to be known. Given that there is no fixed place for this (Gradle, Eclipse, IntelliJ IDEA all have different locations for the compialtion products), the location cannot be encoded in the XML. This means the only avenue of communication is either the classpath or manually using an environment variable. Until recently, Gradle, Ant, Gant, Eclipse, IntelliJ IDEA, all ran the unit tests with the classpath being the classpath. i.e. System.getProperty ( "java.class.path" ) was the classpath used to execute the unit tests. Recently Gradle has changed the way things happen and this property no longer contains the information it used to. Specifically the classpath used to be something like: /home/users/russel/Repositories/Bazaar/Masters/Gant/Trunk_Development/bin:/home/users/russel/Repositories/Bazaar/Masters/Gant/Trunk_Development/jarfiles/maven-ant-tasks-2.0.10.jar:/home/users/russel/.m2/repository/org/apache/ant/ant/1.8.0/ant-1.8.0.jar:/home/users/russel/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/users/russel/.m2/repository/org/codehaus/groovy/groovy-all/1.8.0-beta-1-SNAPSHOT/groovy-all-1.8.0-beta-1-SNAPSHOT.jar:/home/users/russel/.m2/repository/org/apache/ant/ant-launcher/1.8.0/ant-launcher-1.8.0.jar:/home/users/russel/.m2/repository/org/apache/ivy/ivy/2.1.0-rc2/ivy-2.1.0-rc2.jar:/home/users/russel/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar So this could be used to create an initial classpath for the spawned Ant process and everything worked. It still does work this way with Eclipse and IntelliJ IDEA. Gradle now has the property set as: /home/users/russel/lib/JavaPackages/gradle-trunk/lib/gradle-core-0.9-20100301121152+0000.jar:/home/users/russel/lib/JavaPackages/gradle-trunk/lib/jul-to-slf4j-1.5.10.jar:/home/users/russel/lib/JavaPackages/gradle-trunk/lib/logback-classic-0.9.18.jar:/home/users/russel/lib/JavaPackages/gradle-trunk/lib/logback-core-0.9.18.jar:/home/users/russel/lib/JavaPackages/gradle-trunk/lib/slf4j-api-1.5.10.jar and so does not contain the crucial information about where the code under test and its dependencies are. So it seems there is no general algorithm that can be employed from within the unit tests to know the classpath with which to spawn the Ant task :-(
One option is to extract the classpath from the ClassLoader of the classes under test. Have a look at ClasspathUtil.getClasspath() in the Gradle source for an example. Not 100% guaranteed for all possible environments, but should work for anything which launches your tests.
-- Adam Murdoch Gradle Developer http://www.gradle.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
