Post by Sean Van Buggenumwhere my helper class function 'StringHlpr.ltrim' trims all consecutive characters (of any characters provided in the 2nd String argument) to the left of the 1st argument
(because the Java classloader function getResource doesn't like slashes in front of the path.
This works no problem when actually running the program, as well as when running the junit test via ant, with in eclipse or standalone.
Only in gradle does it fail.
24-May-2011 11:33:43 svUbuntuX2
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/antlr-2.7.7.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/GMetrics-0.3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-maven-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-sonar-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-antlr-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jetty-6.1.25.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/bsh-2.0b4.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-ide-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-osgi-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jetty-util-6.1.25.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/checkstyle-5.3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/sonar-batch-bootstrapper-2.6.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jetty-annotations-6.1.25.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/bndlib-1.15.0.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/servlet-api-2.5-20081211.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jetty-naming-6.1.25.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-jetty-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-plugins-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/testng-5.14.10.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-code-quality-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/commons-beanutils-core-1.8.3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jsp-api-2.1-6.1.14.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/junit-4.8.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-scala-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/CodeNarc-0.13.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jsp-2.1-6.1.14.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/ant-antlr-1.8.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/core-3.1.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/geronimo-annotation_1.0_spec-1.0.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jetty-plus-6.1.25.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/jcommander-1.12.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/snakeyaml-1.6.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/gradle-announce-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jansi-1.2.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/logback-classic-0.9.28.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-httpclient-3.0.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-wrapper-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-ui-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/ivy-2.2.0.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/ant-launcher-1.8.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/log4j-over-slf4j-1.6.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jna-3.2.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/core-impl/
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jcl-over-slf4j-1.6.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/guava-r08.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jsch-0.1.42.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jna-posix-1.0.3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/webdavlib-2.0.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/dom4j-1.6.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-codec-1.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-tooling-api-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/ant-1.8.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-io-1.4.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jul-to-slf4j-1.6.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/plugins/
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-lang-2.6.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/groovy-all-1.7.10.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-open-api-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/logback-core-0.9.28.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jaxen-1.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-launcher-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/gradle-core-1.0-milestone-3.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/slf4j-api-1.6.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-cli-1.2.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/jzlib-1.0.7.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/asm-all-3.3.1.jar
file:/mnt/data/bin/gradle-1.0-milestone-3/lib/commons-collections-3.2.1.jar
file:/mnt/data/bin/java6/jdk1.6.0_24/lib/tools.jar
24-May-2011 11:33:43 svUbuntuX2
SEVERE: End of classpath output
which is strange, because when I iterate over the sourceSets.test.runtimeClasspath fileset, it shows I should have it on my classpath
testClasses.doFirst {
println "Test classpath is:- "
sourceSets.test.runtimeClasspath.getFiles().each { file ->
println "file: \"" + file + "\""
}
}
Test classpath is:-
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/build/classes/test"
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/build/classes/main"
file: "/mnt/data/dev/svn/working_build/lib/junit.jar"
file: "/mnt/data/dev/svn/working_build/lib/app.jar"
file: "/mnt/data/dev/svn/working_build/app.jar"
file: "/mnt/data/dev/svn/working_build/lib/xstream-1.3.1.jar"
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/general/ModulesTestCaseBase/build/libs/general/ModulesTestCaseBase.jar"
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/build/libs/data_export/Project1.jar"
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/src/test/resources"
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/test"
where the resource I want can be found at the path
file: "/mnt/data/dev2/workflow/testRelocate/modules_extra/data_export/Project1/build/classes/test"
(i've checked; it is there!)
So, it could be down to which classloader I am using. However, that's as maybe, I need to restate, It works in ANT in two running environments. Why should it not work in Gradle?
I don't really want to go modifying application code to suit Gradle.
any ideas ? Anyone come across such similar problems with Classpath and classloader?
thanks and regards,
sean
Hi Sean,
Can you post a snippet of the Java code you're using to access the
files? Also, what value is this set to for your tests?
new File('.').getAbsolutePath()
Cheers,
Merlyn
Post by Sean Van BuggenumHi all,
for what I believe may be my final problem for some time,
I would like a better understanding of what is causing the test
resources of my project not to be picked up at runtime (of the junit
tests).
For a better understanding of my setup, let me explain;
My projects (which i've been migrating from junit to gradle) have a
{projectDir}
{projectDir}/src
{projectDir}/test
{projectDir}/build.gradle
{projectDir}/build/classes/main
{projectDir}/build/classes/test
I have resources, such as XML files in with my test source files, for
example, I have an XML file in the test directory, at some level.
When I check to see if this XML file is turning up in the build
output, at ./build/classes/test/etcetc
it is. No problem there.
However, when my junit test runs, it is not able to find the xml file
which it tries to read on the classpath.
So, my question is regarding classpath and the junit test run during
java build.
Any idea why it is not working?
In case it matters, i've modified the working dir for the test run, via
test{
workingDir = new File("${junitWorkingDir}")
}
I wouldn't think this matters, if my file is on the classpath correctly.
----------------------------------
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test'
}
resources {
srcDir 'test'
}
}
}
test{
workingDir = new File("${junitWorkingDir}")
}
jar{
manifest.from("src/META-INF/MANIFEST.MF")
}
dependencies {
testCompile files("${buildLibs}/junit.jar")
testCompile files("${buildLibs}/app.jar")
testCompile project(':general/ModulesTestCaseBase')
compile files("${buildHome}/app.jar")
}
I guess I need to add something to test.runtimeClasspath but, I don't
know why...
Again, thanks in advance.
Should I come across the answer by myself, i'll post it for others.
sean
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting