Create a new spring-boot-antlib module which allows Apache Ant users to easily create executable jars. Fixes gh-3339
94 lines
3.0 KiB
XML
94 lines
3.0 KiB
XML
<?xml version="1.0"?>
|
|
<project name="spring-boot-antlib-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit" xmlns:spring-boot="antlib:org.springframework.boot.ant" xmlns:ivy="antlib:org.apache.ivy.ant">
|
|
|
|
<property name="src.dir" location="src/main/java" />
|
|
<property name="resource.dir" location="src/main/resources" />
|
|
<property name="target.dir" location="target" />
|
|
<property name="classes.dir" location="${target.dir}/classes" />
|
|
|
|
<target name="setUp">
|
|
<ivy:cachepath inline="true" pathid="compile.classpath" organisation="joda-time" module="joda-time" type="jar" revision="2.8.1" />
|
|
|
|
<mkdir dir="${classes.dir}" />
|
|
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="compile.classpath" />
|
|
</target>
|
|
|
|
<target name="tearDown">
|
|
<delete dir="${classes.dir}" />
|
|
</target>
|
|
|
|
<target name="test-findmainclass-set-property" depends="setUp">
|
|
<spring-boot:findmainclass classesroot="${classes.dir}" property="main-class" />
|
|
<au:assertEquals expected="org.test.SampleApplication" actual="${main-class}" />
|
|
</target>
|
|
|
|
<target name="test-findmainclass-log-message" depends="setUp">
|
|
<spring-boot:findmainclass classesroot="${classes.dir}" />
|
|
<au:assertLogContains text="org.test.SampleApplication" />
|
|
</target>
|
|
|
|
<target name="test-findmainclass-override" depends="setUp">
|
|
<spring-boot:findmainclass mainclass="OVERRIDDEN" property="main-class" />
|
|
<au:assertEquals expected="OVERRIDDEN" actual="${main-class}" />
|
|
</target>
|
|
|
|
<macrodef name="check-exejar">
|
|
<attribute name="jar" />
|
|
<sequential>
|
|
<echo>Checking @{jar}</echo>
|
|
<au:assertFileExists file="@{jar}" />
|
|
|
|
<javaresource id="foo" name="foo">
|
|
<classpath>
|
|
<pathelement location="@{jar}" />
|
|
</classpath>
|
|
</javaresource>
|
|
<au:assertRefResourceExists refid="foo" />
|
|
<au:assertRefResourceContains refid="foo" value="FOO" />
|
|
|
|
<java jar="@{jar}" fork="true" />
|
|
<au:assertLogContains text="LocalDate" />
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<target name="test-exejar-explicit-start-class" depends="setUp">
|
|
<local name="jar" />
|
|
<property name="jar" location="${target.dir}/explicit.jar" />
|
|
<spring-boot:exejar destfile="${jar}" classes="${classes.dir}" start-class="org.test.SampleApplication">
|
|
<resources>
|
|
<fileset dir="${resource.dir}" />
|
|
</resources>
|
|
<lib>
|
|
<path refid="compile.classpath" />
|
|
</lib>
|
|
</spring-boot:exejar>
|
|
<check-exejar jar="${jar}" />
|
|
</target>
|
|
|
|
<target name="test-exejar-find-start-class" depends="setUp">
|
|
<local name="jar" />
|
|
<property name="jar" location="${target.dir}/found.jar" />
|
|
<spring-boot:exejar destfile="${jar}" classes="${classes.dir}">
|
|
<resources>
|
|
<fileset dir="${resource.dir}" />
|
|
</resources>
|
|
<lib>
|
|
<path refid="compile.classpath" />
|
|
</lib>
|
|
</spring-boot:exejar>
|
|
<check-exejar jar="${jar}" />
|
|
</target>
|
|
|
|
<target name="antunit">
|
|
<au:antunit>
|
|
<au:plainlistener />
|
|
<file file="${ant.file}" />
|
|
</au:antunit>
|
|
</target>
|
|
|
|
<target name="clean">
|
|
<delete dir="${target.dir}" />
|
|
</target>
|
|
|
|
</project>
|