forked from skeeto/sample-java-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
228 lines (206 loc) · 8.34 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?xml version="1.0"?>
<project name="SampleJavaProject" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Project-specific configuration -->
<loadproperties srcfile="project.properties"/>
<property name="main.class" value="${package.main}.${ant.project.name}"/>
<property name="base.name" value="${artifactId}-${version}"/>
<!-- Standard Directory Layout -->
<property name="src.dir" value="src"/>
<property name="test.dir" value="test"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<!-- Targets -->
<target name="resolve" description="Retrieve dependencies with Ivy.">
<ivy:resolve log="download-only"/>
<ivy:cachepath conf="build" pathid="build.classpath"/>
<ivy:cachepath conf="default" pathid="runtime.classpath"/>
<ivy:cachefileset conf="default" setid="runtime.fileset"/>
<ivy:cachepath conf="test" pathid="test.classpath"/>
<ivy:cachepath conf="analysis" pathid="analysis.classpath"/>
</target>
<target name="compile" depends="resolve" description="Compile all sources.">
<mkdir dir="${dist.dir}"/>
<mkdir dir="${build.dir}/classes"/>
<javac srcdir="${src.dir}" destdir="${build.dir}/classes"
optimize="on" debug="on" deprecation="on" includeantruntime="no">
<compilerarg value="-Xlint"/>
<classpath refid="build.classpath"/>
</javac>
<copy todir="${build.dir}/classes">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="jar" depends="compile"
description="Generate the jarfile distributable.">
<jar destfile="${dist.dir}/${base.name}.jar"
basedir="${build.dir}/classes">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<jar destfile="${dist.dir}/${base.name}-all.jar"
basedir="${build.dir}/classes">
<zipgroupfileset refid="runtime.fileset"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="compile" description="Run the application.">
<java classname="${main.class}" classpath="${build.dir}/classes" fork="yes">
<classpath refid="runtime.classpath"/>
<arg value="--name"/>
<arg value="Java"/>
</java>
</target>
<target name="run-hotswap" depends="compile"
description="Run the application in hotswap mode.">
<java classname="${main.class}" classpath="${build.dir}/classes"
fork="true">
<classpath refid="runtime.classpath"/>
<jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"/>
<arg value="--loop"/>
<arg value="--name"/>
<arg value="Java"/>
</java>
</target>
<target name="hotswap" depends="compile">
<taskdef name="hotswap" classname="dak.ant.taskdefs.Hotswap"/>
<hotswap verbose="true" port="9000">
<fileset dir="${build.dir}/classes" includes="**/*.class">
<modified/>
</fileset>
</hotswap>
</target>
<target name="clean" description="Delete all generated files.">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete file="cache.properties"/>
</target>
<target name="javadoc" depends="resolve,compile"
description="Generate documentation.">
<taskdef classname="lombok.delombok.ant.DelombokTask" name="delombok"
classpathref="build.classpath"/>
<delombok verbose="true" to="${build.dir}/src" from="${src.dir}">
<classpath refid="build.classpath"/>
</delombok>
<javadoc destdir="${dist.dir}/javadoc"
link="http://download.oracle.com/javase/6/docs/api/"
sourcepath="${build.dir}/src"
Doctitle="${ant.project.name} ${version}"
Windowtitle="${ant.project.name} ${version}">
<classpath refid="build.classpath"/>
</javadoc>
</target>
<target name="format" description="Run the indenter on all source files.">
<apply executable="astyle">
<arg value="--mode=java"/>
<arg value="--suffix=none"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${test.dir}" includes="**/*.java"/>
</apply>
</target>
<target name="tags" description="Generate a TAGS file for your editor.">
<delete file="TAGS"/>
<apply executable="etags">
<arg value="-a"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${test.dir}" includes="**/*.java"/>
</apply>
</target>
<target name="check" depends="resolve" description="Run Checkstyle.">
<taskdef resource="checkstyletask.properties"
classpathref="analysis.classpath"/>
<checkstyle config="checkstyle.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath path="${build.dir}/classes"/>
</checkstyle>
</target>
<target name="findbugs" depends="compile" description="Run FindBugs.">
<taskdef classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
name="findbugs" classpathref="analysis.classpath"/>
<findbugs output="emacs" classpathref="analysis.classpath" pluginList="">
<auxclasspath refid="analysis.classpath"/>
<sourcepath path="${src.dir}"/>
<class location="${build.dir}/classes"/>
</findbugs>
</target>
<target name="pmd" depends="resolve" description="Run PMD on the code.">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="analysis.classpath"/>
<pmd>
<ruleset>pmd.xml</ruleset>
<formatter type="emacs" toConsole="true"/>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
<target name="analyze" depends="check,pmd,findbugs"
description="Run all static analysis tools."/>
<!-- Unit testing (JUnit) -->
<target name="test-compile" depends="compile">
<mkdir dir="${build.dir}/test"/>
<javac srcdir="${test.dir}" destdir="${build.dir}/test"
optimize="on" debug="on" deprecation="on"
classpath="${build.dir}/classes" includeantruntime="no">
<compilerarg value="-Xlint"/>
<classpath refid="build.classpath"/>
<classpath refid="test.classpath"/>
</javac>
<copy todir="${build.dir}/test">
<fileset dir="${test.dir}" excludes="**/*.java"/>
</copy>
<!-- Test coverage -->
<taskdef classpathref="test.classpath" resource="tasks.properties"/>
<cobertura-instrument todir="${build.dir}/instrumented"
datafile="${build.dir}/cobertura.ser">
<fileset dir="${build.dir}/classes">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
</target>
<target name="test" depends="test-compile" description="Run the unit tests.">
<junit fork="yes">
<classpath>
<pathelement path="${build.dir}/instrumented"/>
<pathelement path="${build.dir}/classes"/>
<pathelement path="${build.dir}/test"/>
<path refid="test.classpath"/>
</classpath>
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${build.dir}/cobertura.ser"/>
<batchtest>
<formatter type="brief" usefile="false"/>
<fileset dir="${build.dir}/test"/>
</batchtest>
</junit>
<cobertura-report srcdir="${src.dir}" destdir="${dist.dir}/test"
datafile="${build.dir}/cobertura.ser"/>
</target>
<!-- Maven repository support -->
<target name="bundle" depends="jar,javadoc"
description="Stage a Maven repository bundle.">
<!-- Pack up the artifacts -->
<filter filtersfile="project.properties"/>
<filter token="ant.project.name" value="${ant.project.name}"/>
<copy file="pom.xml" filtering="true"
tofile="${dist.dir}/bundle/${base.name}.pom"/>
<copy file="${dist.dir}/${base.name}.jar" todir="${dist.dir}/bundle/"/>
<jar jarfile="${dist.dir}/bundle/${base.name}-javadoc.jar">
<fileset dir="${dist.dir}/javadoc"/>
</jar>
<jar jarfile="${dist.dir}/bundle/${base.name}-sources.jar">
<fileset dir="${src.dir}"/>
</jar>
<!-- Sign all the things. You'll need gpg-agent help here. -->
<apply executable="gpg" failonerror="true">
<arg value="--detach-sign"/>
<arg value="--armor"/>
<fileset dir="${dist.dir}/bundle"/>
</apply>
<!-- Pack it all up -->
<jar destfile="${dist.dir}/bundle.jar" basedir="${dist.dir}/bundle"/>
</target>
</project>