I am new to Gradle and I am trying to migrate the build system of a Java application from Ant to it.
The Ant build system was created and managed by Netbeans IDE.
I came across this guide to use Gradle’s own Ant plugin: https://docs.gradle.org/current/userguide/ant.html. Using that and some information I read on this forum and stackoverflow I came up with this gradle.build
:
repositories {
mavenCentral()
}
configurations {
junitAnt
}
dependencies {
junitAnt 'junit:junit:4.12'
junitAnt('org.apache.ant:ant-junit:1.10.2') {
transitive = false
}
junitAnt('org.apache.ant:ant-junit4:1.10.2') {
transitive = false
}
}
ant.taskdef(name: 'junit',
classname: 'org.apache.tools.ant.taskdefs.optional.junit.JUnitTask',
classpath: configurations.junitAnt.asPath)
ant.importBuild('build.xml') { antTargetName ->
'ant-' + antTargetName
}
How this doesn’t seem to work:
❯❯❯ gradle ant-test ⏎ master ✚ ✱ ◼
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
> Task :ant--init-macrodef-junit-impl
Trying to override old definition of task http://www.netbeans.org/ns/j2se-project/3:test-impl
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ant--do-test-run'.
> The following error occurred while executing this line:
/home/totakura/repos/p2p-projects/2016/testing/nbproject/build-impl.xml:511: The following error occurred while executing this line:
/home/totakura/repos/p2p-projects/2016/testing/nbproject/build-impl.xml:484: The following error occurred while executing this line:
/home/totakura/repos/p2p-projects/2016/testing/nbproject/build-impl.xml:414: java.lang.NoSuchMethodError: org.apache.tools.ant.types.resources.Resources.stream()Ljava/util/stream/Stream;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
58 actionable tasks: 58 executed
Any pointers on how to resolve this?