I'm trying to migrate from ant to gradle. First phase of this is to move all dependecies to gradle.build and still build war via ant.
To import ant builds I'm using this code:
ant.importBuild('build.xml') { antTargetName ->
'ant_' + antTargetName
}
To copy all dependencies from gradle to ant I'm trying to use this:
task copyDependenciesForAnt() {
def antLibsPath = ant."tmp.build.dir" + "/" + ant."project.libs.folder"
configurations.compile.each { Files.copy(Paths.get(it), Paths.get(antLibsPath)) }
}
ant_war.mustRunAfter copyDependenciesForAnt
With this code I have problem because i don't know how to use Files.copy here. Also there is probably easier way to achieve this in gradle, but I don't know how.
You can define a copy task in Gradle, as follows:
task copyDependenciesForAnt(type: Copy) {
from configurations.compile
into ant."tmp.build.dir" + "/" + ant."project.libs.folder"
}
ant_war.dependsOn copyDependenciesForAnt
Also, I suggest using dependsOn rather than mustRunAfter for task dependency wiring which ensures correct execution order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With