##Summary
Gradle has some documentation for Ant, but it doesn’t seem to tell us how we can map Ant targets to there Gradle equivalent. It does show how to map a small subset of Ant targets, but it doesn’t show how to do advanced usages of that subset. So am I missing this documentation, or does it not exist.
I have the code below of what I want to do. I think I need a chained mapper, but I don’t know how the DSL should look like.
Background
I was having a slight inconvenience with my current Gradle Task. Either I can ignore the problem (just for now) or I can have 2 ant
calls which will basically double the time to execute my Gradle task.
I have seen that using pure Ant, I can do this with just one Ant copy
XML tag. I want to replicate that to reduce my execution time.
However, I cannot find the documentation to understand how to accurately map Ant targets
to Gradle Ant tasks
. So where can I find this documentation? I think I need a Chained Mapper
I have checked these documentation pages…
- https://docs.gradle.org/current/userguide/ant.html,
- https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:using_ant_tasks_tutorial,
- https://docs.gradle.org/current/javadoc/org/gradle/api/AntBuilder.html
Code
doLast {
println("Syncing files...\n\tfrom\t'$intelliJColorSchemeDir' \n\tto\t\t'$sourceDir'")
println("Renaming file extension")
// Sync files from IntelliJ's color scheme and rename extension
ant.copy(todir: sourceDir) {
fileset(dir: intelliJColorSchemeDir)
mapper(type: "glob", from: "*.icls", to: "*.xml")
// Cannot do this as there will then be 2 mappers
// mapper(type: "glob", from: "ChroMATERIAL IntelliJ IDEA*.*", to: "ChroMATERIAL*.*") // TODO wildcards don't work in this case. Why? Should I just not use wildcards? Would kind of prefer wildcards though
}
// ALTERNATIVE 2nd ant target - would like to have this be in the above ant `copy` target
// Rename one specific file
ant.move(todir: sourceDir) {
fileset(dir: sourceDir)
mapper(type: "glob", from: "ChroMATERIAL IntelliJ IDEA.xml", to: "ChroMATERIAL.xml")
}
println("Syncing task completely finished!")
}