-
Notifications
You must be signed in to change notification settings - Fork 92
/
build.xml
279 lines (254 loc) · 10.3 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
<project name="umlgraph" default="compile" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant" >
<description>
The specification for the Java-based umlgraph build processes.
</description>
<!-- set global properties for this build -->
<property name="src" location="src/main/java"/>
<property name="testsrc" location="src/test"/>
<property name="build" location="build"/>
<property name="javadoc" location="javadoc"/>
<property name="lib" location="lib"/>
<property name="testsrc" location="test/src"/>
<property name="testout" location="${basedir}/testdata/dot-out"/>
<property name="testref" location="${basedir}/testdata/dot-ref"/>
<property name="dist" location="dist" />
<!-- obtain version from git; see http://techblog.41concepts.com/2009/05/08/generating-ant-build-numbers-using-subversion/ -->
<macrodef name="gitversion" description="Get git version.">
<attribute name="outputproperty"/>
<sequential>
<echo message="git rev-parse --short=6 => '@{outputproperty}'"/>
<exec executable="git"
failonerror="true"
outputproperty="@{outputproperty}">
<arg value="rev-parse"/>
<arg value="--short=6"/>
<arg value="HEAD"/>
<redirector>
<outputfilterchain>
<tokenfilter>
<replaceregex pattern="R" replace=""/>
<replaceregex pattern="_" replace="."/>
<replaceregex pattern="-" replace="."/>
<replaceregex pattern="(-.*)$" replace="-SNAPSHOT"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<echo message="gitversion returned '${@{outputproperty}}'"/>
</sequential>
</macrodef>
<!-- define Maven coordinates; see https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7c.DeploySnapshotsandStageReleaseswithAnt -->
<property name="groupId" value="org.umlgraph" />
<property name="artifactId" value="UmlGraph" />
<!-- <property name="version" value="1.0-SNAPSHOT" /> -->
<gitversion outputproperty="version"/>
<!-- define artifacts' name, which follows the convention of Maven -->
<property name="maven-jar" value="${dist}/lib/${artifactId}-${version}.jar" />
<property name="maven-javadoc-jar" value="${dist}/lib/${artifactId}-${version}-javadoc.jar" />
<property name="maven-sources-jar" value="${dist}/lib/${artifactId}-${version}-sources.jar" />
<!-- defined maven snapshots and staging repository id and url -->
<!-- passwords are stored in \Users\Diomidis Spinellis\.m2\settings.xml -->
<property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
<property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
<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/" />
<!-- import environment variables -->
<property environment="env"/>
<target name="clean">
<delete dir="${build}"/>
<delete dir="${lib}"/>
<delete dir="testdata/dot-out"/>
<delete dir="${javadoc}"/>
<delete dir="${dist}/lib"/>
</target>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${lib}"/>
<mkdir dir="testdata/dot-out"/>
<mkdir dir="${javadoc}"/>
<mkdir dir="${dist}/lib"/>
</target>
<target name="version">
<exec executable="git"
outputproperty="VERSION">
<arg value="rev-parse"/>
<arg value="--short=6"/>
<arg value="HEAD"/>
</exec>
<echo>Version is ${VERSION}</echo>
<echo file="src/main/java/org/umlgraph/doclet/Version.java">/* Automatically generated file */
package org.umlgraph.doclet;
class Version { public static String VERSION = "${VERSION}";}
</echo>
</target>
<target name="compile" depends="init,version"
description="compile the source, build library " >
<javac srcdir="${src}" destdir="${build}" debug="true"
deprecation="true" includeantruntime="false" >
<compilerarg value="-Xlint"/>
<classpath>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
</classpath>
</javac>
<jar basedir="${build}" destfile="${lib}/UmlGraph.jar" includes="org/umlgraph/doclet/*.class">
<manifest>
<attribute name="Main-Class" value="org.umlgraph.doclet.UmlGraph"/>
<attribute name="Class-Path" value="tools.jar"/>
</manifest>
</jar>
</target>
<target name="testcompile" depends="init"
description="compile the test code " >
<javac srcdir="${testsrc}" destdir="${build}" debug="true"
deprecation="true" includeantruntime="false" >
<classpath>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
</classpath>
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="test" depends="compile,testcompile"
description="run the regression tests" >
<!-- postpone failures, so we get to see the pngs -->
<java classname="org.umlgraph.test.BasicTest" fork="true" resultproperty="BasicTest.exit">
<classpath>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
<pathelement location="${build}"/>
<pathelement location="${lib}/UmlGraph.jar"/>
</classpath>
</java>
<java classname="org.umlgraph.test.UmlDocTest" fork="true" resultproperty="UmlDocTest.exit">
<classpath>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
<pathelement location="${build}"/>
<pathelement location="${lib}/UmlGraph.jar"/>
</classpath>
</java>
<apply executable="dot" dest="${testout}" parallel="false">
<arg value="-Tpng"/>
<arg value="-o"/>
<targetfile/>
<srcfile/>
<fileset dir="${testout}" includes="*.dot"/>
<mapper type="glob" from="*.dot" to="*.png"/>
</apply>
<apply executable="dot" dest="${testref}" parallel="false">
<arg value="-Tpng"/>
<arg value="-o"/>
<targetfile/>
<srcfile/>
<fileset dir="${testref}" includes="*.dot"/>
<mapper type="glob" from="*.dot" to="*.png"/>
</apply>
<!-- postponed failure, so we get to see the pngs -->
<fail message="BasicTest failed">
<condition><not><equals arg1="0" arg2="${BasicTest.exit}"/></not></condition>
</fail>
<fail message="UmlDocTest failed">
<condition><not><equals arg1="0" arg2="${UmlDocTest.exit}"/></not></condition>
</fail>
</target>
<target name="javadocs" depends="compile">
<javadoc sourcepath="${src}" packagenames="org.umlgraph.doclet.*" destdir="${javadoc}" private="true">
<doclet name="org.umlgraph.doclet.UmlGraphDoc" path="${lib}/UmlGraph.jar">
<param name="-inferrel"/>
<param name="-inferdep"/>
<param name="-autosize"/>
<param name="-collapsible"/>
<param name="-hide" value="java.*"/>
<param name="-collpackages" value="java.util.*"/>
<param name="-qualify"/>
<param name="-postfixpackage"/>
<param name="-nodefontsize" value="9"/>
<param name="-nodefontpackagesize" value="7"/>
<param name="-link" value="http://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/"/>
<param name="-link" value="http://download.oracle.com/javase/7/docs/api/"/>
</doclet>
</javadoc>
</target>
<target name="pom" description="generate the pom.xml file with the correct version">
<copy file="pom.template.xml"
tofile="pom.xml"
filtering="yes" overwrite="yes">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
</filterchain>
</copy>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<!-- build the main artifact -->
<jar jarfile="${maven-jar}" basedir="${build}" />
<!-- build the javadoc artifact -->
<javadoc sourcepath="${src}" destdir="${dist}/javadoc" />
<jar jarfile="${maven-javadoc-jar}">
<fileset dir="${dist}/javadoc" />
</jar>
<!-- build the sources artifact -->
<jar jarfile="${maven-sources-jar}">
<fileset dir="${src}" />
</jar>
</target>
<target name="deploy" depends="dist,pom" description="deploy snapshot version to Maven snapshot repository">
<!-- for this to work install http://maven.apache.org/ant-tasks/download.html into ant/lib -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${maven-jar}" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${maven-sources-jar}" />
<arg value="-Dclassifier=sources" />
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${maven-javadoc-jar}" />
<arg value="-Dclassifier=javadoc" />
</artifact:mvn>
</target>
<!-- before this, update project version (both build.xml and pom.xml) from SNAPSHOT to RELEASE -->
<target name="stage" depends="dist,pom" description="deploy release version to Maven staging repository">
<!-- sign and deploy the main artifact -->
<artifact:mvn>
<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=pom.xml" />
<arg value="-Dfile=${maven-jar}" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<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=pom.xml" />
<arg value="-Dfile=${maven-sources-jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<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=pom.xml" />
<arg value="-Dfile=${maven-javadoc-jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Pgpg" />
</artifact:mvn>
</target>
</project>