[GRADLE-771] Handle name clashes between Gradle tasks and imported Ant targets Created: 07/Dec/09 Updated: 10/Nov/14 Resolved: 27/Aug/14 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.2-rc-1 |
Type: | Improvement | ||
Reporter: | Tomek Kaczanowski | Assignee: | Luke Daley |
Resolution: | Fixed | Votes: | 11 |
Description |
a typical migration scenario of your Ant Java project starts with build.gradle looking like this: it will probably fail because of name clash of tasks from build.xml and those provided by Java plugin:
Possible solutions (ideas from mailing list discussion):
|
Comments |
Comment by Taylor Brown [ 07/Feb/12 ] |
Being able to put a namespace on my imported tasks would be helpful. I am in the process of migrating from ant, and this feature would have helped me. I use the GradleFx plugin which defines a "test" task. So does my ant build. I will be editing my build.xml of course, but it would have been nice to say, "Put all of these tasks into my custom namespace". |
Comment by Rohitashva Mathur [ 27/Mar/12 ] |
You can create your own namespace for these ant tasks by leveraging an intermediate ant build file that references the original ant build file and attaches a namespace to the tasks defined therein. So, if the original build file is build.xml, create another ant build file called wrapper.xml and define it like the following fragment - <project default="test"> <include file="build.xml" as="somename"/> </project> in the gradle build script instead of referring build.xml, refer wrapper.xml //ant.importBuild 'build.xml' All the ant tasks are now available under namespace "somename". A task named 'clean' in build.xml can now be invoked via gradle with names as somename.clean, and build.gradle can have its own version of clean. gradle clean – clean in build.gradle |
Comment by Peter Sipos [ 20/Mar/13 ] |
This would also be very useful when using multiple plugins. Actually even for simple use-cases like a flex build which publishes to a maven repo, you need maven plugin, which requires Java plugin and gradleFx both defining the basic tasks, like clean, test. I also encountered the migration issue when imported legacy build.xml - it will surely have 'clean' and similar basic tasks names. This feature is a MUST. |
Comment by Erik Vonderheid [ 06/Mar/14 ] |
Here is another solution without a wrapper XML:
|
Comment by Peter Butkovic [ 28/Apr/14 ] |
not sure why, but workaround proposed by @RohitashvaMathur didn't work for me. |