forked from frizbog/gedcom4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
299 lines (270 loc) · 12 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<project name="gedcom4j" default="release" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property file="gedcom4j.properties" />
<!-- Stuff for Cobertura -->
<property name="cobertura.dir" value="lib/cobertura" />
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}" includes="*.jar" />
</path>
<taskdef resource="tasks.properties" classpathref="cobertura.classpath" />
<!-- Stuff for Checkstyle -->
<taskdef resource="checkstyletask.properties" classpath="lib/checkstyle-5.5-all.jar" />
<!-- Stuff for Findbugs -->
<property name="findbugs.home" value="lib/findbugs" />
<path id="findbugs.classpath">
<fileset dir="${findbugs.home}" includes="*.jar" />
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.classpath" />
<!-- Stuff for PMD -->
<path id="pmd.classpath">
<fileset dir="lib/pmd">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath" />
<!-- Stuff for Maven Ant Tasks -->
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
<property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
<property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
<!-- Not planning to sync snapshots, but if I ever do... -->
<property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
<property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
<target name="clean" description="Remove all build artifacts">
<delete dir="tmp" />
<delete dir="bin" />
<delete dir="dist" />
<delete dir="testbin" />
<delete dir="target" />
<delete dir="reports" />
<delete>
<fileset dir="${basedir}">
<include name="cobertura.ser" />
<include name=".swp" />
<include name="junit*.properties" />
</fileset>
</delete>
</target>
<target name="init" description="Create necessary directories for build">
<mkdir dir="tmp" />
<mkdir dir="bin" />
<mkdir dir="dist" />
<mkdir dir="testbin" />
<mkdir dir="reports" />
</target>
<target name="compile" depends="init" description="Compile all source code">
<javac srcdir="src" destdir="bin" deprecation="true" debug="true" debuglevel="lines,vars,source" source="1.5" target="1.5" includeantruntime="false">
<compilerarg value="-Xlint" />
</javac>
</target>
<target name="javadoc" depends="compile" description="Generate javadoc">
<delete dir="reports/javadoc" />
<javadoc sourcepath="src" destdir="reports/javadoc" access="private" />
</target>
<target name="dist" depends="javadoc" description="Build distribution jars">
<delete dir="dist" />
<mkdir dir="dist" />
<copy todir="bin">
<fileset dir="." includes="*.txt" />
</copy>
<jar basedir="bin" destfile="dist/gedcom4j-${release.version}.jar">
<manifest>
<attribute name="Source" value="http://gedcom4j.org" />
<attribute name="Release-Version" value="${release.version}" />
</manifest>
</jar>
<jar basedir="reports/javadoc" destfile="dist/gedcom4j-${release.version}-javadoc.jar">
<manifest>
<attribute name="Source" value="http://gedcom4j.org" />
<attribute name="Release-Version" value="${release.version}" />
</manifest>
</jar>
<jar basedir="." destfile="dist/gedcom4j-${release.version}-sources.jar">
<include name="src/**" />
<include name="test/**" />
<manifest>
<attribute name="Source" value="http://gedcom4j.org" />
<attribute name="Release-Version" value="${release.version}" />
</manifest>
</jar>
</target>
<target name="release" depends="clean, dist" description="Create all the artifacts in the distribution directory" />
<target name="explode-jar" depends="release" description="Convenience target for unjarring the distribution to the temp directory for inspection">
<unjar dest="tmp" src="dist/gedcom4j-${release.version}.jar" />
</target>
<target name="maven-push-to-central" description="Prepare release for push to maven repository">
<!--
This target is intended for use by the project owner(s) to push releases to maven central repository
at SonaType. It requires some specific information in your local maven repository which is not
kept in source control for security reasons. As such, this target generally won't work for anyone
but the owner(s).
-->
<!-- Make the pom.xml from the template -->
<copy filtering="true" overwrite="true" tofile="tmp/pom.xml">
<fileset dir="etc">
<include name="pom.template.xml" />
</fileset>
<filterset>
<filter token="VERSION" value="${release.version}" />
</filterset>
</copy>
<!-- Get the latest build artifacts for the desired version from the CI server -->
<get dest="dist" src="https://gedcom4j.ci.cloudbees.com/job/gedcom4j.org/lastSuccessfulBuild/artifact/dist/gedcom4j-${release.version}.jar" />
<get dest="dist" src="https://gedcom4j.ci.cloudbees.com/job/gedcom4j.org/lastSuccessfulBuild/artifact/dist/gedcom4j-${release.version}-javadoc.jar" />
<get dest="dist" src="https://gedcom4j.ci.cloudbees.com/job/gedcom4j.org/lastSuccessfulBuild/artifact/dist/gedcom4j-${release.version}-sources.jar" />
<!-- sign and stage the main jar file -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=tmp/pom.xml" />
<arg value="-Dfile=dist/gedcom4j-${release.version}.jar" />
<arg value="-Dgpg.executable=/usr/local/bin/gpg" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and stage the sources jar file -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=tmp/pom.xml" />
<arg value="-Dfile=dist/gedcom4j-${release.version}-sources.jar" />
<arg value="-Dclassifier=sources" />
<arg value="-Dgpg.executable=/usr/local/bin/gpg" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and stage the javadoc jar file -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=tmp/pom.xml" />
<arg value="-Dfile=dist/gedcom4j-${release.version}-javadoc.jar" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Dgpg.executable=/usr/local/bin/gpg" />
<arg value="-Pgpg" />
</artifact:mvn>
</target>
<target name="maven-local" depends="release" description="Prepare release for push to LOCAL maven repository">
<!--
This target is inteded to be used by any developer to install the artifact to the local
maven repository.
-->
<!-- Make the pom.xml from the template -->
<copy filtering="true" overwrite="true" tofile="tmp/pom.xml">
<fileset dir="etc">
<include name="pom.template.xml" />
</fileset>
<filterset>
<filter token="VERSION" value="${release.version}" />
</filterset>
</copy>
<artifact:pom id="mypom" file="tmp/pom.xml" />
<artifact:install file="dist/gedcom4j-${release.version}.jar">
<pom refid="mypom" />
<attach file="${basedir}/dist/gedcom4j-${release.version}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${basedir}/dist/gedcom4j-${release.version}-sources.jar" type="jar" classifier="sources" />
</artifact:install>
</target>
<target name="run-tests" depends="compile" description="Run the unit tests">
<delete dir="tmp/junit" />
<mkdir dir="tmp/junit" />
<delete dir="tmp/cobertura" />
<mkdir dir="tmp/cobertura" />
<delete dir="reports/junit" />
<mkdir dir="reports/junit" />
<delete dir="reports/coverage" />
<mkdir dir="reports/coverage" />
<javac source="1.5" target="1.5" srcdir="test" destdir="testbin" deprecation="true" debug="true" debuglevel="lines,vars,source" includeantruntime="false">
<compilerarg value="-Xlint" />
<classpath>
<fileset dir="lib" includes="junit-4.10.jar" />
<pathelement location="bin" />
</classpath>
</javac>
<property name="instr.bin" value="tmp/cobertura-instrumented-bin" />
<property name="data.file" value="${basedir}/cobertura.ser" />
<mkdir dir="${instr.bin}" />
<delete file="${data.file}" />
<cobertura-instrument todir="${instr.bin}">
<includeClasses regex="org\.gedcom4j\..*" />
<excludeClasses regex=".*TestHelper.*" />
<excludeClasses regex=".*NullOutputStream.*" />
<excludeClasses regex=".*Abstract.*" />
<instrumentationClasspath>
<path location="bin" />
</instrumentationClasspath>
</cobertura-instrument>
<junit haltonfailure="false" haltonerror="false" fork="yes" forkmode="once">
<sysproperty key="net.sourceforge.cobertura.datafile" file="${data.file}" />
<classpath>
<pathelement location="${instr.bin}" />
<pathelement location="bin" />
<pathelement location="testbin" />
<path refid="cobertura.classpath" />
<fileset dir="lib" includes="junit-4.10.jar" />
</classpath>
<batchtest todir="tmp/junit">
<fileset dir="test">
<include name="**/*" />
<exclude name="**/Abstract*" />
<exclude name="**/TestHelper*" />
<exclude name="**/NullOutputStream*" />
</fileset>
<formatter type="plain" usefile="false" />
</batchtest>
<formatter type="xml" />
</junit>
<junitreport todir="tmp/junit">
<fileset dir="tmp/junit">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="reports/junit" />
</junitreport>
<!-- These properties can be overridden on the command line to ANT (such as from Jenkins) -->
<property name="cobertura.format" value="html" />
<property name="cobertura.destdir" value="reports/coverage" />
<cobertura-report datafile="${data.file}" format="${cobertura.format}" destdir="${cobertura.destdir}">
<fileset dir="src" />
</cobertura-report>
<delete file="${data.file}" />
<delete>
<fileset dir="${basedir}">
<include name="junit*.properties" />
</fileset>
</delete>
</target>
<target name="checkstyle" description="Run Checkstyle over the source, and produce a report of violations">
<delete dir="tmp/checkstyle" />
<mkdir dir="tmp/checkstyle" />
<checkstyle config="checkstyle-config.xml" failureProperty="checkstyle.failure" failOnViolation="false">
<formatter type="xml" tofile="tmp/checkstyle/checkstyle_report.xml" />
<fileset dir="src" includes="**/*.java" />
<classpath>
<pathelement location="bin" />
</classpath>
</checkstyle>
<xslt in="tmp/checkstyle/checkstyle_report.xml" out="reports/checkstyle/index.html" style="checkstyle-noframes-severity-sorted.xsl" />
</target>
<target name="findbugs" depends="compile" description="Run FindBugs over the source to find bug patterns and potential issues">
<property name="findbugs.format" value="html" />
<property name="findbugs.destfile" value="reports/findbugs.html" />
<findbugs home="${findbugs.home}" output="${findbugs.format}" outputFile="${findbugs.destfile}" jvmargs="-Xmx128m">
<auxClasspath path="lib/junit-4.10.jar" />
<sourcePath path="src" />
<class location="bin" />
</findbugs>
</target>
<target name="pmd" depends="compile" description="Run PMD over the source to find bug patterns and potential issues">
<delete dir="tmp/pmd" />
<mkdir dir="tmp/pmd" />
<pmd shortFilenames="true">
<sourceLanguage name="java" version="1.5" />
<ruleset>pmd-config.xml</ruleset>
<formatter type="xml" toFile="tmp/pmd/pmd_report.xml" />
<formatter type="html" toFile="reports/pmd_report.html" />
<fileset dir="src">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
</project>