-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathbuild.xml
74 lines (74 loc) · 3.39 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="dist" name="ant-javacard build">
<!-- Build and load the JavaCard task -->
<target name="jcpro">
<mkdir dir="build"/>
<javac debug="true" destdir="build" includeantruntime="true" target="8" source="8">
<src path="capfile/src/main/java"/>
<src path="task/src/main/java"/>
<compilerarg value="-Xlint:-options"/>
<compilerarg value="-Xlint:all"/>
<exclude name="**/module-info.java"/>
</javac>
<!-- Load the fresh task -->
<path id="task">
<pathelement path="build"/>
</path>
<taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpathref="task"/>
</target>
<!-- Get commit and timestamp from git -->
<target name="git" description="Get git values">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="true" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="--dirty"/>
</exec>
<exec executable="git" outputproperty="git.timestamp" failifexecutionfails="true" errorproperty="">
<arg value="-c"/>
<arg value="log.showSignature=false"/>
<arg value="log"/>
<arg value="-1"/>
<arg value="--format=%aI"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<condition property="repository.timestamp" value="${git.timestamp}" else="0">
<and>
<isset property="git.timestamp"/>
<length string="${git.timestamp}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>${repository.version} @ ${repository.timestamp}</echo>
</target>
<!-- Package it into a reproducible JAR -->
<target name="dist" depends="jcpro,git">
<!-- Have the modification timestamp from last git commit -->
<jar destfile="ant-javacard.jar" level="9" basedir="build" modificationtime="${repository.timestamp}">
<manifest>
<!-- It is possible to execute ant-javacard.jar... -->
<attribute name="Main-Class" value="pro.javacard.ant.DummyMain"/>
<!-- Blank out volatile values, so the same jar could be built with slight variations in JDK/ant version -->
<attribute name="Created-By" value="ant-javacard build ${repository.version}"/>
<attribute name="Ant-Version" value="irrelevant"/>
</manifest>
</jar>
<!-- Now this JAR can be used in your build.xml by placing the jar to -->
<!-- lib folder and having the following in your target: -->
<!-- <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="lib/ant-javacard.jar"/> -->
</target>
<!-- Build smoke test applets -->
<import file="tests-${ant.java.version}.xml"/>
<!-- Cleanup! -->
<target name="clean">
<delete dir="build"/>
<delete>
<fileset dir="." includes="*.cap"/>
</delete>
<delete file="ant-javacard.jar"/>
</target>
</project>