forked from Ant-Grand/Grand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
177 lines (176 loc) · 8.64 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
<?xml version="1.0" encoding="UTF-8"?>
<project default="jar" name="grand" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="srcdir" value="src/main/java"/>
<property name="confdir" value="src/main/resources"/>
<property name="testsrcdir" value="src/test/java"/>
<property name="defaulttargetdir" value="target"/>
<property name="libdir" value="${defaulttargetdir}/lib"/>
<property name="classesdir" value="${defaulttargetdir}/classes"/>
<property name="testclassesdir" value="${defaulttargetdir}/test-classes"/>
<property name="testreportdir" value="${defaulttargetdir}/test-reports"/>
<property name="distdir" value="dist"/>
<property name="javadocdir" value="dist/docs/api"/>
<property name="java.target" value="1.6"/>
<!-- version and product -->
<property name="project.version" value="1.9.7"/>
<property name="project.vendor" value="ggTools"/>
<property name="product.name" value="${ant.project.name}-${project.version}.jar"/>
<property name="module.name" value="${ant.project.name}-module-${project.version}.jar"/>
<!-- Ivy -->
<property name="central.repo" value="https://repo1.maven.org/maven2"/>
<property name="ivy.version" value="2.5.0"/>
<property name="ivy.dir" value="${user.home}/.ivy2/cache/org.apache.ivy/jars"/>
<property name="ivy.jar.name" value="ivy-${ivy.version}.jar"/>
<available property="has.ivy" file="${ivy.dir}/${ivy.jar.name}" type="file"/>
<target name="get.ivy" description="o Get Ivy jar unless already cached" unless="has.ivy">
<mkdir dir="${ivy.dir}"/>
<get usetimestamp="true" src="${central.repo}/org/apache/ivy/ivy/${ivy.version}/${ivy.jar.name}"
skipexisting="true"
dest="${ivy.dir}/${ivy.jar.name}"/>
</target>
<target name="init" description="o Initialize Ivy" depends="get.ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dir}/${ivy.jar.name}"/>
<ivy:settings file="${basedir}/ivy.settings.xml"/>
</target>
<target name="get-deps" description="o Retrieve dependencies" depends="init" unless="noget">
<ivy:retrieve pattern="${libdir}/[artifact]-[revision].[ext]" sync="true" type="jar"/>
<path id="project.classpath">
<fileset dir="${libdir}" includes="*.jar"/>
</path>
</target>
<target name="compile" description="o Compile the code" depends="get-deps">
<mkdir dir="${classesdir}"/>
<javac source="${java.target}" target="${java.target}" includeantruntime="false" deprecation="true" debug="true" optimize="false"
srcdir="${srcdir}" destdir="${classesdir}" excludes="**/package.html" classpathref="project.classpath"/>
<propertyfile file="${confdir}/net/ggtools/grand/buildnum.properties">
<entry key="build.time" type="date" value="now" pattern="HH:mm:ss"/>
<entry key="build.number" type="int" default="0" operation="+"/>
<entry key="build.version.string" value="${project.version}"/>
<entry key="build.date" type="date" value="now" pattern="yyyy-MM-dd"/>
</propertyfile>
<copy todir="${classesdir}">
<fileset dir="${confdir}">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<target name="jar" description="o Create the jar" depends="test">
<jar jarfile="${defaulttargetdir}/${module.name}" index="true" excludes="**/package.html,org/**,task.properties" basedir="${classesdir}">
<manifest>
<attribute name="Automatic-Module-Name" value="net.ggtools.grand"/>
<section name="net/ggtools/grand">
<attribute name="Specification-Title" value="${ant.project.name}"/>
<attribute name="Specification-Version" value="${project.version}"/>
<attribute name="Specification-Vendor" value="${project.vendor}"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
<attribute name="Implementation-Vendor" value="${project.vendor}"/>
</section>
</manifest>
</jar>
<jar jarfile="${defaulttargetdir}/${product.name}" index="true" excludes="**/package.html" basedir="${classesdir}">
<manifest>
<section name="net/ggtools/grand">
<attribute name="Specification-Title" value="${ant.project.name}"/>
<attribute name="Specification-Version" value="${project.version}"/>
<attribute name="Specification-Vendor" value="${project.vendor}"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
<attribute name="Implementation-Vendor" value="${project.vendor}"/>
</section>
</manifest>
</jar>
</target>
<target name="clean" description="o Clean up the generated directories">
<delete dir="${defaulttargetdir}"/>
<delete dir="${distdir}"/>
</target>
<target name="dist" description="o Create a distribution" depends="javadoc,check-pom">
<mkdir dir="dist"/>
<copy todir="dist">
<fileset dir="${defaulttargetdir}" includes="*.jar"/>
<fileset dir="${basedir}" includes="LICENSE*,README*"/>
</copy>
</target>
<target name="test" description="o Run the test cases" if="test.failure" depends="internal-test">
<fail message="There were test failures."/>
</target>
<target name="internal-test" depends="compile-tests">
<mkdir dir="${testreportdir}"/>
<junit dir="." failureproperty="test.failure" printSummary="yes" fork="true" haltonerror="true" tempdir="${defaulttargetdir}">
<sysproperty key="basedir" value="."/>
<formatter type="xml"/>
<formatter usefile="false" type="plain"/>
<classpath>
<path refid="project.classpath"/>
<pathelement path="${testclassesdir}"/>
<pathelement path="${classesdir}"/>
</classpath>
<batchtest todir="${testreportdir}">
<fileset dir="${testsrcdir}">
<include name="**/AllTests.java"/>
<exclude name="org/apache/**"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="compile-tests" depends="compile">
<mkdir dir="${testclassesdir}"/>
<javac source="${java.target}" target="${java.target}" includeantruntime="false" deprecation="true" debug="true" optimize="false"
srcdir="${testsrcdir}" destdir="${testclassesdir}" excludes="**/package.html">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${classesdir}"/>
</classpath>
</javac>
</target>
<target name="check-pom" description="o Verify pom.xml properties" depends="get-deps">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpath="${libdir}/maven-ant-tasks-2.1.3.jar"/>
<artifact:pom id="grand.pom" file="pom.xml"/>
<echo>The pom version is ${grand.pom.version}</echo>
<fail message="maven-compiler-plugin must be first in build plugin list!">
<condition>
<not>
<equals arg1="maven-compiler-plugin" arg2="${grand.pom.build.plugins[0].artifactId}"/>
</not>
</condition>
</fail>
<xmlproperty keeproot="false" prefix="grand.pom.build">
<string value="${grand.pom.build.plugins[0].configuration}"/>
</xmlproperty>
<echoproperties prefix="grand.pom"/>
<fail message="Inconsistent Ant and Maven properties!">
<condition>
<not>
<and>
<equals arg1="${grand.pom.version}" arg2="${project.version}" forcestring="true"/>
<equals arg1="${grand.pom.build.source}" arg2="${java.target}" forcestring="true"/>
<equals arg1="${grand.pom.build.target}" arg2="${java.target}" forcestring="true"/>
</and>
</not>
</condition>
</fail>
</target>
<target name="javadoc" description="o Generate javadoc" depends="jar">
<mkdir dir="${javadocdir}"/>
<tstamp>
<format pattern="2004-yyyy" property="years"/>
</tstamp>
<property name="copyright" value="Copyright &copy;${years} ${project.vendor}."/>
<property name="title" value="Grand: Graphical Representation of ANt Dependencies ${project.version} API"/>
<javadoc use="true" private="true" destdir="${javadocdir}" author="true" version="true" windowtitle="Grand" doctitle="${title}" bottom="${copyright}"
sourcepath="${srcdir}" packagenames="net.ggtools.grand.*">
<classpath>
<path refid="project.classpath"/>
<pathelement location="${defaulttargetdir}/${product.name}"/>
</classpath>
<arg value="-tag"/>
<arg value="to.do:a:To do:"/>
</javadoc>
</target>
</project>