Extended build script to also build the "test" classes (as separate JAR).
[fast-key-erasure-rng-java.git] / build.xml
blob9a333c1463668ecb768393bd8485b9ca8ff1fa90
1 <project name="fast-key-erasure" default="main" basedir=".">
2         <property name="package.version" value="1.0"/>
4         <property name="src.dir" location="src"/>
5         <property name="src.dir.test" location="test"/>
6         <property name="lib.dir" location="lib"/>
7         <property name="lib.dir.test" location="${lib.dir}/test"/>
8         <property name="bin.dir" location="bin"/>
9         <property name="bin.dir.jdk8" location="${bin.dir}/@jdk8"/>
10         <property name="bin.dir.jdk17" location="${bin.dir}/@jdk17"/>
11         <property name="bin.dir.test" location="${bin.dir}/@test"/>
12         <property name="out.dir" location="dist"/>
14         <tstamp>
15                 <format property="build.date" pattern="yyyy-MM-dd" locale="en,UK" timezone="UTC"/>
16                 <format property="build.timestamp" pattern="yyyyMMdd-HHmmss" locale="en,UK" timezone="UTC"/>
17         </tstamp>
19         <property name="out.name" value="${ant.project.name}.${build.date}"/>
21         <property name="out.file.jdk8" location="${out.dir}/${out.name}.jdk-8.jar"/>
22         <property name="out.file.jdk17" location="${out.dir}/${out.name}.jdk-17.jar"/>
23         <property name="out.file.test" location="${out.dir}/${out.name}.tests.jar"/>
25         <!-- ~~~~ MAIN ~~~~ -->
27         <target name="main" depends="clean,jar">
28                 <echo message="Completed."/>
29         </target>
31         <!-- ~~~~ COMPILE ~~~~ -->
33         <target name="compile" description="compile java sources" depends="compile.jdk8,compile.jdk17,compile.test">
34                 <echo message="Completed."/>
35         </target>
37         <target name="compile.jdk8" description="compile java sources (JDK 8)">
38                 <mkdir dir="${bin.dir.jdk8}"/>
39                 <javac srcdir="${src.dir}" destdir="${bin.dir.jdk8}" debug="off" source="1.8" target="1.8" optimize="true" includeantruntime="false" encoding="utf8"/>
40         </target>
42         <target name="compile.jdk17" description="compile java sources (JDK 17)">
43                 <mkdir dir="${bin.dir.jdk17}"/>
44                 <javac srcdir="${src.dir}" destdir="${bin.dir.jdk17}" debug="off" release="17" optimize="true" includeantruntime="false" encoding="utf8"/>
45         </target>
47         <target name="compile.test" description="compile java sources (test)" depends="compile.jdk17">
48                 <mkdir dir="${bin.dir.test}"/>
49                 <javac srcdir="${src.dir.test}" destdir="${bin.dir.test}" debug="true" release="17" optimize="true" includeantruntime="false" encoding="utf8">
50                         <classpath>
51                                 <pathelement location="${bin.dir.jdk17}"/>
52                                 <pathelement location="${lib.dir.test}/apiguardian-api-1.1.2.jar"/>
53                                 <pathelement location="${lib.dir.test}/ascii85-1.2.jar"/>
54                                 <pathelement location="${lib.dir.test}/junit-jupiter-api-5.10.1.jar"/>
55                         </classpath>
56                 </javac>
57         </target>
59         <!-- ~~~~ JAR ~~~~ -->
61         <target name="jar" description="create JAR package" depends="jar.jdk8,jar.jdk17,jar.test">
62                 <echo message="Completed."/>
63         </target>
65         <target name="jar.jdk8" description="create JAR package (JDK 8)" depends="compile.jdk8">
66                 <mkdir dir="${out.dir}"/>
67                 <jar destfile="${out.file.jdk8}" basedir="${bin.dir.jdk8}" includes="**/*.class" excludes="**/Main.class">
68                         <fileset file="${basedir}/README.md"/>
69                         <fileset file="${basedir}/LICENSE.txt"/>
70                         <manifest>
71                                 <section name="io/github/deajl3ka/fast_key_erasure/">
72                                         <attribute name="Implementation-Title" value="Fast-key-erasure Random-number Generator"/>
73                                         <attribute name="Implementation-Version" value="${package.version}"/>
74                                         <attribute name="Implementation-Build-Date" value="${build.timestamp}"/>
75                                 </section>
76                         </manifest>
77                 </jar>
78                 <attrib file="${out.file.jdk8}" readonly="true"/>
79         </target>
81         <target name="jar.jdk17" description="create JAR package (JDK 17)" depends="compile.jdk17">
82                 <mkdir dir="${out.dir}"/>
83                 <jar destfile="${out.file.jdk17}" basedir="${bin.dir.jdk17}" includes="**/*.class" excludes="**/Main.class">
84                         <fileset file="${basedir}/README.md"/>
85                         <fileset file="${basedir}/LICENSE.txt"/>
86                         <manifest>
87                                 <section name="io/github/deajl3ka/fast_key_erasure/">
88                                         <attribute name="Implementation-Title" value="Fast-key-erasure Random-number Generator"/>
89                                         <attribute name="Implementation-Version" value="${package.version}"/>
90                                         <attribute name="Implementation-Build-Date" value="${build.timestamp}"/>
91                                 </section>
92                         </manifest>
93                 </jar>
94                 <attrib file="${out.file.jdk17}" readonly="true"/>
95         </target>
97         <target name="jar.test" description="create JAR package (test)" depends="compile.test">
98                 <mkdir dir="${out.dir}"/>
99                 <jar destfile="${out.file.test}" basedir="${bin.dir.test}" includes="**/*.class" excludes="**/Main.class">
100                         <fileset file="${basedir}/README.md"/>
101                         <fileset file="${basedir}/LICENSE.txt"/>
102                 </jar>
103                 <attrib file="${out.file.test}" readonly="true"/>
104         </target>
106         <!-- ~~~~ CLEAN ~~~~ -->
107         
108         <target name="clean">
109                 <delete includeemptydirs="true" verbose="true">
110                         <fileset dir="${bin.dir}" includes="**/*" erroronmissingdir="false"/>
111                         <fileset dir="${out.dir}" includes="**/*" erroronmissingdir="false"/>
112                 </delete>
113         </target>
114 </project>