Hey folks, I'm trying to migrate a legacy ant proj...
# community-support
a
Hey folks, I'm trying to migrate a legacy ant project to gradle which has a few custom
ant
tasks that are available in
$ANT_HOME
. I'm importing
build.xml
via
ant.importBuild("build.xml")
. However, none of the custom ant tasks are available and the build fails because they're not defined. I've read "Using custom Ant tasks", but it sounds like that only applies if I want to run the ant tasks directly from gradle, but I really just want them available in ant so that the import succeeds. Would anyone have any pointers?
v
ANT_HOME
is irrelevant, as Gradle ships its own Ant built-in. I don't know whether you can add it similarly though, never tried. The
importBuild
is in my eyes more a crutch or very short term work-around. 🤷‍♂️
s
It also doesn’t take much to fork Ant from Gradle, roughly like this:
Copy code
val antConfig = configurations.create("ant")

dependencies {
  antConfig("org.apache.ant:ant-launcher:1.10.15")
  antConfig("whatever:extra-libs:you-need")
}

tasks.register("runAnt", JavaExec::class) {
  classpath = antConfig
  args("-buildfile", "myfile", "-Dmyprop=myvalue")
  mainClass = "org.apache.tools.ant.launch.Launcher"
}
(you could also use something like
Copy code
antConfig(fileTree(System.getenv("ANT_HOME")) { include("lib/**") })
for Ant classpath instead but that makes it more system-dependent)