-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.xml
More file actions
205 lines (183 loc) · 9.58 KB
/
build.xml
File metadata and controls
205 lines (183 loc) · 9.58 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="NAMControllerCompiler" default="dist" basedir=".">
<property name="targetversion" value="8" />
<property name="project.version" value="2.0.0" />
<property name="MyApp" value="${ant.project.name}" />
<property name="MyApp-zipname" value="${ant.project.name}_${project.version}" />
<property name="MyApp.jar" value="${MyApp}.jar" />
<property name="src" location="src" relative="true" />
<property name="srctest" location="test" relative="true" />
<property name="bin" location="bin" relative="true" />
<property name="bintest" location="bintest" relative="true" />
<property name="lib" location="lib" relative="true" />
<property name="doc" location="doc" relative="true" />
<property name="dist" location="dist" relative="true" />
<property name="xml.resources" location="resources/xml" relative="true" />
<property name="rul2.structure.file" value="RUL2_IID_structure" />
<property name="test.resources" location="resources/test" relative="true" />
<property name="ivy.install.version" value="2.5.0"/>
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME"/>
</condition>
<property name="ivy.home" value="${user.home}/.ant"/>
<property name="ivy.jar.dir" value="${ivy.home}/lib"/>
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
<target name="download-ivy" unless="offline">
<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">
<!-- 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.
See https://ant.apache.org/ivy/history/latest-milestone/install.html. -->
<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="resolve" description="retrieve dependencies with ivy">
<mkdir dir="${lib}" />
<ivy:retrieve conf="mainapp"/>
<ivy:cachepath pathid="build.classpath" conf="mainapp"/>
</target>
<target name="clean" description="delete generated files">
<delete dir="${bin}" />
<delete dir="${bintest}" />
<delete dir="${doc}" />
<delete dir="${dist}" />
<delete file="TEST-testsuites.AllUnitTests.txt" />
<delete file="TEST-testsuites.AllIntegrationTests.txt" />
<delete file="${MyApp.jar}" />
<delete file="${MyApp}.bat" />
<delete file="${MyApp}_developer.bat" />
<delete file="${MyApp}_debug.bat" />
</target>
<target name="compile" depends="resolve" description="compile the sources">
<mkdir dir="${bin}" />
<javac release="${targetversion}" srcdir="${src}" destdir="${bin}" includeantruntime="false">
<classpath refid="build.classpath" />
</javac>
<copy todir="${bin}">
<fileset dir="${src}" includes="**/*.txt" />
</copy>
</target>
<target name="doc" depends="compile" description="generate documentation">
<mkdir dir="${doc}" />
<javadoc
sourcepath="${src}"
destdir="${doc}"
packagenames="*"
link="http://docs.oracle.com/javase/7/docs/api/"
classpathref="build.classpath"
/>
</target>
<target name="batchfiles" description="generate batch files">
<echo file="${MyApp}.bat">if "%~1"=="" goto interactive
cd %1
cd ../..
:interactive
java -jar ${MyApp}.jar %* || %windir%\SysWOW64\java -jar ${MyApp}.jar %*</echo>
<echo file="${MyApp}_developer.bat">java -jar ${MyApp}.jar dev</echo>
<echo file="${MyApp}_debug.bat">java -jar -ea ${MyApp}.jar debug</echo>
</target>
<target name="resources" description="copy resource files to appropriate locations in resource folder">
<copy file="${xml.resources}/${rul2.structure.file}_default.xml"
tofile="${xml.resources}/${rul2.structure.file}.xml"
preservelastmodified="true"
overwrite="true"
/>
<copy file="${xml.resources}/${rul2.structure.file}_default.xml"
tofile="${test.resources}/xml/${rul2.structure.file}.xml"
preservelastmodified="true"
overwrite="true"
/>
<copy file="${xml.resources}/${rul2.structure.file}.dtd"
todir="${test.resources}/xml/"
preservelastmodified="true"
overwrite="true"
/>
</target>
<target name="dist" depends="compile,resolve,batchfiles,resources" description="create binary distribution">
<!-- class path file list for manifest file -->
<pathconvert property="manifest.build.classpath" pathsep=" ">
<path refid="build.classpath"/>
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="lib/*.jar"/>
</chainedmapper>
</mapper>
</pathconvert>
<!-- Initialization -->
<delete file="${MyApp.jar}" />
<delete dir="${dist}" />
<mkdir dir="${dist}" />
<!-- Create jar file -->
<jar jarfile="${MyApp.jar}" basedir="${bin}">
<manifest>
<attribute name="Main-Class" value="controller.NAMControllerCompilerMain"/>
<attribute name="Class-Path" value="${manifest.build.classpath}"/>
</manifest>
<!-- <zipfileset dir="${src}" includes="**/*.txt" /> -->
</jar>
<!-- Create zip file with sources -->
<zip destfile="${dist}/${MyApp-zipname}_sources_and_tests.zip">
<fileset dir="${basedir}" includes="${manifest.build.classpath}" />
<fileset dir="${basedir}" includes="${MyApp}*,build.xml,ivy.xml,ivysettings.xml,README.md,LICENSE" />
<!-- source files -->
<fileset dir="${basedir}" includes="${src}/**" />
<fileset dir="${basedir}" includes="${srctest}/**" />
<!-- resource files -->
<fileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}.dtd" />
<fileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}_default.xml" />
<zipfileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}_default.xml" fullpath="${xml.resources}/${rul2.structure.file}.xml" />
<fileset dir="${basedir}" includes="${test.resources}/Controller/**" />
<zipfileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}_default.xml" fullpath="${test.resources}/xml/${rul2.structure.file}.xml" />
<zipfileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}.dtd" fullpath="${test.resources}/xml/${rul2.structure.file}.dtd" />
</zip>
<!-- Create dist zip file -->
<zip destfile="${dist}/${MyApp-zipname}.zip">
<fileset dir="${basedir}" includes="${manifest.build.classpath}" />
<fileset dir="${basedir}" includes="${MyApp}*,README.md,LICENSE" />
<fileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}.dtd" />
<fileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}_default.xml" />
<zipfileset dir="${basedir}" includes="${xml.resources}/${rul2.structure.file}_default.xml" fullpath="${xml.resources}/${rul2.structure.file}.xml" />
</zip>
</target>
<!-- ================================
tests
================================ -->
<target name="resolvetests" description="retrieve dependencies for tests with ivy">
<ivy:retrieve conf="tests"/>
<ivy:cachepath pathid="lib.test.build.classpath" conf="tests"/>
<ivy:cachepath pathid="build.classpath" conf="mainapp"/>
</target>
<path id="test.build.classpath">
<path refid="lib.test.build.classpath"/>
<path refid="build.classpath"/>
<pathelement path="${bintest}" />
<pathelement path="${bin}" />
</path>
<target name="compiletests" depends="compile,resolvetests" description="compile the tests">
<mkdir dir="${bintest}" />
<javac release="${targetversion}" srcdir="${srctest}" destdir="${bintest}" includeantruntime="false">
<classpath refid="test.build.classpath" />
</javac>
</target>
<target name="deletexml" description="deletes xml backup so that syntax check fails if supposed to">
<delete file="${test.resources}/xml/${rul2.structure.file}.xml~1" />
</target>
<target name="test" depends="compiletests,resources,deletexml">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath refid="test.build.classpath" />
<formatter type="plain"/>
<test name="testsuites.AllUnitTests"/>
<test name="testsuites.AllIntegrationTests"/>
</junit>
</target>
</project>