Calling ant test target fails with junit classpath issue (newbie)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Calling ant test target fails with junit classpath issue (newbie)

cwhite102
I'm starting to migrate some builds to gradle.  Looks very cool so far.

I wanted to wrap some existing ant builds with gradle scripts to start.
This particular ant build file is a basic netbeans java ant project (has targets such as 'jar', 'test')

My gradle script is just this one line:

ant.importBuild 'build.xml'

When I run "gradle jar" everything works
When I run "ant test" everything works
When I run "gradle test" I get a classpath problem with junit

* What went wrong:
Execution failed for task ':-do-test-run'.
Cause: The following error occurred while executing this line:
E:\Craig\Workarea\Kayak\KayakPlugins\SANDBOX\SandboxPlayArea\SandboxPlayAreaJava
\nbproject\build-impl.xml:315: Problem: failed to create task or type junitCause: Problem: failed to create task or type junit
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not
found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -ANT_HOME\lib
        -the IDE Ant configuration dialogs


My ANT_HOME is set and has everything needed.  Can someone please explain the difference between the "ant test" and the "gradle test" and why I'd get an error?

Thanks
Craig


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Calling ant test target fails with junit classpath issue (newbie)

TheKaptain
I ran into this with the update to 1.0-milestone3 as well. I'm guessing that ANT_HOME is not a factor because Gradle is using its own internal ant dependency to build, not any locally installed ant you might have, and that with the latest version they've stopped including optional ant jars in that stack. Whether that's actually true or not I can't confirm right now, but I can share how I've solved the problem in my build:

configurations {
  antClasspath
}

dependencies {
  antClasspath 'ant-contrib:ant-contrib:20020829', 'org.apache.ant:ant-junit:1.8.1'
}

// add additional jars to the AntBuilder classpath for use within the imported build.
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antClasspath.each { File f ->
  antClassLoader.addURL(f.toURI().toURL())
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Calling ant test target fails with junit classpath issue (newbie)

cwhite102
Thank you for the quick response.
That fixed it.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Calling ant test target fails with junit classpath issue (newbie)

svaens
yes, thanks from me also, 
I also came across this problem. 
I'm very grateful!

sean


On 12 May 2011 00:28, cwhite102 <[hidden email]> wrote:
Thank you for the quick response.
That fixed it.



--
View this message in context: http://gradle.1045684.n5.nabble.com/Calling-ant-test-target-fails-with-junit-classpath-issue-newbie-tp4385167p4387511.html
Sent from the gradle-user mailing list archive at Nabble.com.

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

   http://xircles.codehaus.org/manage_email



Loading...