<?xml version="1.0"?>
<project name="sample Ant project" default="test" basedir=".">
<target name="test" >
<echo message="The Ant test target was called."/>
</target>
</project>
The Java plugin already defines a task named test. Ant targets get treated as Gradle tasks if you import them into your build script. Therefore, you see a task naming conflict. If you rename your Ant target to something else e.g. test1 you’ll be fine.
Thank you for the suggestion. I had thought of that but it might cause some friction migrating from the old Ant build system. You know how people are sometimes.
I know a patch to ignore targets that conflict with existing tasks would be a solution but before going down that road any alternative suggestions ?
The ‘ant.importBuild’ feature wasn’t designed to be used together with Gradle plugins in the same project. A potential way out is to do a multi-project build.
I tried your solution using my sample project. All conflicting targets were pre-pended with the word legacy.
The Ant build file is imported successfully.
But now I am getting a different error message. This time the junit task used in the legacytest target is not able to find JUnit in the classpath.
* What went wrong:
Execution failed for task ':legacytest'.
> JUnit could not be found in your classpath.
You must download and install it from http://junit.org to build and run the test suite.
Now I defined the same junit dependency for all 4 dependency configurations. Is there something I have missed and should be doing to add junit to the classpath ?