How to change Ant Build to use Gradle Compile Path

I am trying to move our existing apps to gradle and planning to use gradle only as wrapper and for dependency management for now.

My build.xml looks like this

<path id="path.base1">
		<pathelement path="${build.dir}" />
		<fileset dir="${web.dir}/WEB-INF/lib">
			<include name="*.jar" />
		</fileset>
</path>

<target name="compileApp" description="Compile Application sources.">
		<echo message="Compiling Application sources..." />
		<javac srcdir="${src.dir}" destdir="${build.dir}" encoding="utf-8" deprecation="true"  debug="${debug.mode}">
			<compilerarg value="-Xlint:-path" />
			<classpath refid="path.base1" />
		</javac>
</target>

In my build.gradle, if I copy all dependencies to where my ant build requires, everything works good

task copyDependenciesForAnt(type: Copy) {
from configurations.compile
into “./WebContent/WEB-INF/lib”
}

However, I do not want to copy these dependencies, so I have tried to set gradlePathToLib in build.gradle and tried to use it in build.xml, but fails because it cannot find reference to gradlePathToLib

Build.gradle snippet:

configurations{
antdist
}
dependencies {
antdist fileTree(dir:’./local-repo’, include:[’*.jar’])
}
task antPathsInjectedByGradle {
ant.path(id:‘gradlePathToLib’, location:configurations.antdist.asPath)
}

Build.xml snippet

<path id="path.base1" refid = "gradlePathToLib" />

<target name="compileApp" description="Compile Application sources.">
		<echo message="Compiling Application sources..." />
		<javac srcdir="${src.dir}" destdir="${build.dir}" encoding="utf-8" deprecation="true"  debug="${debug.mode}">
			<compilerarg value="-Xlint:-path" />
			<classpath refid="path.base1" />
		</javac>
</target>

How can I change my path in ANT build to use Gradle compile path? I am new to this and would really appreciate any help.

1 Like

I am facing the same issue… did you found a solution…?

No, I did not find a solution. I rewrote the ant script in gradle.