Compile times are slowed by 4s resolving dependant libs for my javac
step every build on this line:
<target name="compile" depends="bootstrap">
<ivy:cachepath pathid="classpath"/> <!-- SLOW -->
I want to essentially CACHE the results of ivy:cachepath
so I don't have to do it every build. I want ${classpath}
to exist in less than 0.2 seconds
Context:
This is a vanilla ant build.xml
which bootstraps ivy, uses an ivy.xml
file that lists standard maven dependencies, then calls javac
with those libs in a class path)
<property name="ivy.install.version" value="2.4.0"/>
<property name="ivy.jar.dir" value="${basedir}/ivy"/>
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
<property name="build.dir" value="build"/>
<property name="src.dir" value="src"/>
<target name="bootstrap" description="--> install ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<!-- Download any missing libs -->
<target name="install" depends="bootstrap">
<!-- install ivy.jar -->
<mkdir dir="${ivy.jar.dir}"/>
<echo message="installing ivy..."/>
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true"/>
<!-- Downloads all the libraries from maven central via ivy.xml and saves them to classpath-->
<ivy:settings file="ivysettings.xml"/>
<ivy:resolve/>
<ivy:retrieve sync="true"
type="jar,bundle"/>
<ivy:cachepath pathid="classpath"/>
</target>
<target name="clean" depends="bootstrap">
<delete dir="${build_dir}"/>
<delete dir="./lib"/>
<delete dir="./bin"/>
<ivy:cleancache/>
</target>
<!-- Compile -->
<target name="compile" depends="bootstrap">
<ivy:cachepath pathid="classpath"/>
<ivy:settings file="ivysettings.xml"/>
<mkdir dir="${build_dir}"/>
<javac encoding="ISO-8859-1"
includeantruntime="false"
srcdir="${src_dir}"
destdir="${build_dir}"
classpathref="classpath"
debug="on">
<!--<withKotlin/> <!– If this is undefined, run "Build" target first. –>-->
</javac>
<!--<kotlinc src="${src_dir}/TestSuite/TestSuite.java" output="${build_dir}/${jar_name}.jar"/>-->
<delete file="${dist_dir}/${jar_name}.jar"/>
<pathconvert property="classpath.name" pathsep=" ">
<path refid="classpath" />
<mapper>
<chainedmapper>
<flattenmapper />
<globmapper from="*.jar" to="../lib/*.jar" />
</chainedmapper>
</mapper>
</pathconvert>
<echo message="classpath.name : ${classpath.name} " />
<jar destfile="bin/${jar_name}.jar" basedir="build" includes="**/*.class lib/*">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="Class-Path" value="${classpath.name}"/>
</manifest>
</jar>
</target>