-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
164 lines (144 loc) · 6.5 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
TOTP
Petr Michalík
====================================================================== -->
<project name="TOTP" default="main" xmlns:ivy="antlib:org.apache.ivy.ant">
<description>
TOTP for Java
</description>
<!-- Folders -->
<property name="lib.dir" value="lib" />
<property name="src.dir" value="src" />
<property name="classes.dir" value="${src.dir}/classes" />
<property name="test.dir" value="${src.dir}/test" />
<property name="build.dir" value="build" />
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="build.test.dir" value="${build.dir}/test" />
<property name="build.jar.dir" value="${build.dir}/jar" />
<property name="testreport.dir" location="${build.dir}/testreport" />
<property name="doc.dir" location="docs" />
<property name="main-class" value="cz.alej.michalik.totp.client.App" />
<!-- Ivy Settings -->
<property name="ivy.install.version" value="2.1.0-rc2" />
<property name="ivy.jar.dir" value="${lib.dir}" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<!-- Path including all libraries -->
<path id="lib.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- Path used for compiling - includes all classes -->
<path id="classes.classpath">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<path refid="lib.classpath" />
</path>
<!-- Path used for testing - includes test classes & compiled classes -->
<path id="test.classpath">
<pathelement location="${build.classes.dir}" />
<pathelement location="${build.test.dir}" />
<path refid="lib.classpath" />
</path>
<target name="clean" depends="clean-build,clean-lib" description="clean everything" />
<target name="clean-build" description="clean build directory">
<delete dir="${build.dir}" />
</target>
<target name="clean-lib" description="clean lib directory">
<delete dir="${ivy.jar.dir}" />
</target>
<target name="download-ivy" unless="offline" description="download Apache Ivy">
<mkdir dir="${ivy.jar.dir}" />
<!-- download Ivy from web site so that it can be used even without any special installation -->
<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" />
</target>
<target name="init-ivy" depends="download-ivy" description="initialize Apache Ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<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>
<target name="depend" depends="init-ivy" description="retrieve dependencies with ivy">
<ivy:retrieve />
</target>
<target name="compile" depends="compile-classes,compile-tests" description="compile everything">
</target>
<target name="compile-classes" depends="depend" description="compile classes">
<mkdir dir="${build.classes.dir}" />
<javac srcdir="${classes.dir}" destdir="${build.classes.dir}" includeantruntime="true" encoding="UTF-8">
<classpath refid="classes.classpath" />
</javac>
</target>
<target name="compile-tests" depends="depend" description="compile test classes">
<mkdir dir="${build.test.dir}" />
<javac srcdir="${test.dir}" destdir="${build.test.dir}" includeantruntime="true" encoding="UTF-8">
<classpath refid="test.classpath" />
</javac>
</target>
<target name="test" depends="jar, docs" description="jUnit tests">
<delete dir="${testreport.dir}" />
<mkdir dir="${testreport.dir}" />
<mkdir dir="${testreport.dir}/xml" />
<junit printsummary="on" fork="true" haltonfailure="true">
<classpath refid="test.classpath" />
<formatter type="xml" />
<batchtest todir="${testreport.dir}/xml">
<fileset dir="${build.test.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreport.dir}">
<fileset dir="${testreport.dir}/xml">
<include name="TEST-*.xml" />
</fileset>
<report todir="${testreport.dir}" />
</junitreport>
</target>
<target name="docs" description="generate javadocs">
<delete>
<fileset dir="${doc.dir}" includes="cz" excludes="img/*, overview.html, userguide/*"/>
</delete>
<javadoc sourcepath="${classes.dir}" destdir="${doc.dir}" encoding="UTF-8" charset="UTF-8" docencoding="UTF-8" classpath="${lib.dir}/*" overview="${doc.dir}/overview.html"/>
</target>
<target name="jar" depends="jar-client,jar-server" description="create both .jar files"></target>
<target name="jar-client" depends="compile" description="create .jar file">
<mkdir dir="${build.jar.dir}" />
<jar destfile="${build.jar.dir}/${ant.project.name}.jar" basedir="${build.classes.dir}" encoding="UTF-8">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Class-Path" value="." />
</manifest>
<!-- Include libraries -->
<zipgroupfileset excludes="*javadoc*,*sources*,*ivy*,*junit*,*hamcrest*,*json*,*restlet*" dir="lib" />
<!-- and icons -->
<fileset dir=".">
<include name="material-design-icons/**/drawable-xhdpi/*black_*.png"/>
</fileset>
</jar>
</target>
<target name="jar-server" depends="compile" description="create server .jar file">
<mkdir dir="${build.jar.dir}" />
<jar destfile="${build.jar.dir}/${ant.project.name}_Server.jar" basedir="${build.classes.dir}" encoding="UTF-8">
<manifest>
<attribute name="Main-Class" value="cz.alej.michalik.totp.server.Serve" />
<attribute name="Class-Path" value="." />
</manifest>
<!-- Include libraries -->
<zipgroupfileset excludes="*javadoc*,*sources*,*ivy*,*junit*,*hamcrest*," dir="lib" />
</jar>
</target>
<target name="run" depends="jar-client" description="run client .jar file">
<java jar="${build.jar.dir}/${ant.project.name}.jar" fork="true" />
</target>
<target name="run-server" depends="jar-server" description="run .jar file">
<java jar="${build.jar.dir}/${ant.project.name.server}_Server.jar" fork="true" />
</target>
<target name="main" depends="clean,run" description="clean and test" />
</project>