-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstandard-build.xml
executable file
·186 lines (167 loc) · 7.06 KB
/
standard-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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?xml version="1.0" encoding="UTF-8"?>
<project name="standard-build" basedir="." xmlns:maven="antlib:org.apache.maven.artifact.ant">
<!--
requires maven ant tasks plugin in the ant lib directory.
See http://maven.apache.org/ant-tasks/download.html
-->
<!-- This is version 1 -->
<property name="src" location="${basedir}/src/main/java"/>
<property name="test" location="${basedir}/src/test/java"/>
<property name="build.top" location="${basedir}/build/"/>
<property name="build.classes" location="${build.top}/classes/"/>
<property name="build.test" location="${build.top}/test/"/>
<property name="depcache" location="${basedir}/depcache/"/>
<property name="flatlib" location="${basedir}/flatlib/"/>
<property name="testOutput" location="${build.top}/testOutput"/>
<property file="local.properties"/>
<property file="build.properties"/>
<!-- Clean up temporary files. -->
<target name="clean" description="Clean up temporary files.">
<delete dir="${build.top}"/>
<delete dir="${depcache}"/>
</target>
<!-- Create directories, define the output.classpath, and define the
maven repositories. -->
<target name="init">
<fail unless="version" message="The version property was not set."/>
<fail unless="source.level" message="The source.level property was not set."/>
<fail unless="pname" message="The pname property was not set."/>
<mkdir dir="${build.top}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.test}"/>
<path id="output.classpath">
<pathelement location="${build.classes}"/>
<pathelement location="${build.test}"/>
</path>
<maven:remoteRepository url="${maven.primary.url}" id="maven.repo.primary">
<snapshots enabled="false"/>
</maven:remoteRepository>
<maven:remoteRepository url="${maven.backup.url}" id="maven.repo.backup">
<snapshots enabled="false"/>
</maven:remoteRepository>
</target>
<!-- Generate the poms and set maven classpaths.
maven.pom - The project POM
maven.compile.classpath - The compile classpath for the project POM
maven.runtime.classpath - The runtime classpath for the project POM
maven.test.classpath - The test classpath for the project POM
-->
<target name="buildpom" depends="init">
<property name="local.repository" value="${user.home}/.m2/repository"/>
<maven:pom file="pom.xml" id="maven.pom" />
<maven:dependencies pathId="maven.test.classpath" filesetId="maven.test.fileset" useScope="test">
<pom refid="maven.pom"/>
<remoteRepository refid="maven.repo.primary"/>
<remoteRepository refid="maven.repo.backup"/>
<localRepository path="${local.repository}"/>
</maven:dependencies>
<maven:dependencies pathId="maven.runtime.classpath" filesetId="maven.runtime.fileset" useScope="runtime">
<pom refid="maven.pom"/>
<remoteRepository refid="maven.repo.primary"/>
<remoteRepository refid="maven.repo.backup"/>
<localRepository path="${local.repository}"/>
</maven:dependencies>
<maven:dependencies pathId="maven.compile.classpath" filesetId="maven.compile.fileset" useScope="compile">
<pom refid="maven.pom"/>
<remoteRepository refid="maven.repo.primary"/>
<remoteRepository refid="maven.repo.backup"/>
<localRepository path="${local.repository}"/>
</maven:dependencies>
</target>
<!-- Actually compile the files. If you need custom compilation support
then override this, not the compile target. -->
<target name="compile.real">
<depend srcdir="${src}" destdir="${build.classes}" closure="true"
cache="${depcache}" />
<depend srcdir="${test}" destdir="${build.test}" closure="true"
cache="${depcache}">
<classpath location="${build.classes}"/>
</depend>
<javac srcdir="${src}" destdir="${build.classes}"
debug="on" source="${source.level}" target="${source.level}"
includeantruntime="false" deprecation="true">
<compilerarg value="-Xlint:all,-path"/>
<classpath refid="maven.compile.classpath"/>
</javac>
<!--copy todir="${build.classes}">
<fileset dir="${src}">
<exclude name="**/*.java"/>
</fileset>
</copy-->
</target>
<!-- Actually compile the test files. If you need custom compilation support
then override this, not the compileTests target. -->
<target name="compileTests.real">
<depend srcdir="${test}" destdir="${build.test}" closure="true"
cache="${depcache}">
<classpath location="${build.classes}"/>
</depend>
<javac srcdir="${test}" destdir="${build.test}"
debug="on" source="${source.level}" target="${source.level}"
includeantruntime="false" deprecation="true">
<compilerarg value="-Xlint:all,-path"/>
<classpath>
<path location="${build.classes}"/>
<path refid="maven.test.classpath"/>
</classpath>
</javac>
<!--copy todir="${build.test}">
<fileset dir="${test}">
<exclude name="**/*.java"/>
</fileset>
</copy-->
</target>
<target name="compile" depends="buildpom, compile.real" description="Compile the source files."/>
<target name="compileTests" depends="compile, compileTests.real" description="Compile the test files."/>
<target name="test.real" depends="compileTests">
<mkdir dir="${testOutput}" />
<junit printsummary="yes" haltonfailure="no" maxmemory="512m" fork="yes">
<sysproperty key="basedir" file="${top.basedir}"/>
<jvmarg value="-DconfigFile=testConfig.xml"/>
<assertions>
<enable package="org.mitre.test"/>
<enable package="org.mitre.rhex"/>
</assertions>
<classpath>
<pathelement path="${build.classes}"/>
<pathelement path="${build.test}"/>
<pathelement location="src/test/resources"/>
<pathelement location="src/main/resources"/>
<path refid="maven.test.classpath"/>
</classpath>
<formatter usefile="false" type="brief"/>
<formatter type="plain"/>
<batchtest fork="yes" todir="${testOutput}">
<fileset dir="${test}">
<include name="**/Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test" depends="test.real" description="Run the unit tests" />
<target name="generate-lib-directory" depends="buildpom" description="Copy the libraries into a flat directory.">
<delete dir="${flatlib}"/>
<mkdir dir="${flatlib}"/>
<copy todir="${flatlib}">
<fileset refid="maven.test.fileset"/>
<mapper type="flatten"/>
</copy>
</target>
<!-- The "usage" target prints to the standard output all available
targets and brief descriptions of each
-->
<target name="help">
<echo>
+--------------------------------------------------------------------------
| TARGET : DESCRIPTION
+--------------------------------------------------------------------------
| init : sets specific run time properties for the build
| compile : compiles the projects Java source
| install : Install the jar to a local maven repository
| clean : removes files created from compile target and temp files
| test : runs tests on project
| help : prints this usage statement
+--------------------------------------------------------------------------
</echo>
</target>
</project>