-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-build-tasks.xml
287 lines (266 loc) · 14 KB
/
common-build-tasks.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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Copyright (c) 2019 Infostretch Corporation Permission is hereby granted,
free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following
conditions: The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. THE SOFTWARE
IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For any inquiry
or need additional information, please contact [email protected] -->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="comman-ant-tasks">
<property name="bin.dir" value="${basedir}/bin" />
<property name="src.dir" value="${basedir}/src" />
<property name="test.dir" value="${basedir}/test" />
<property name="test.src.dir" value="${test.dir}/src" />
<property name="meta.dir" value="${basedir}/META-INF" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<property name="ivy.revision=" value="latest.integration" />
<available file="${test.dir}" type="dir" property="test.exists"/>
<property file="build.properties" />
<property name="ivysettings.xml" value="../ivysettings.xml" />
<available file="${ivysettings.xml}" property="ivysettings.present" />
<!-- Sets the DSTAMP, TSTAMP, and TODAY properties in the current project -->
<tstamp>
<format property="build.timestamp" pattern="dd-MMM-yyyy HH:mm:ss" />
</tstamp>
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.classpath">
<fileset dir="${dist.dir}">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
<path refid="build.classpath" />
</path>
<target name="test-compile" depends="init" if="test.exists">
<taskdef classpathref="test.classpath" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" />
<echo level="info">--- test compile (start) ---</echo>
<iajc source="${source}" target="${target}" showweaveinfo="true" verbose="true" destdir="${bin.dir}" debug="false" encoding="utf-8">
<inpath location="${src.dir}">
</inpath>
<sourceroots>
<pathelement location="${test.src.dir}" />
</sourceroots>
<classpath refid="test.classpath">
</classpath>
</iajc>
<echo level="info">--- test compile (finished) ---</echo>
</target>
<target name="build"><fail message="Build target Not Found."/></target>
<target name="test" depends="build, test-compile" if="test.exists">
<taskdef resource="testngtasks" classpathref="test.classpath" />
<testng classpathref="test.classpath" workingDir="${test.dir}" outputDir="${test.dir}/test-results" haltOnFailure="true" verbose="2">
<classpath location="${bin.dir}" />
<xmlfileset dir="${test.dir}/config" includes="testrun_config.xml" />
<sysproperty key="log4j.configuration" value="file:///${test.dir}/log4j.properties" />
<sysproperty key="outputDir" value="test-results" />
</testng>
</target>
<!-- IVY -->
<target name="download-ivy" unless="${skip.download}">
<mkdir dir="${ivy.jar.dir}" />
<!-- download Ivy from web site so that it can be used even without any
special installation -->
<echo message="installing ivy..." />
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true" skipexisting="true" />
<get src="https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk14/1.45/bcprov-jdk14-1.45.jar" dest="${ivy.jar.dir}" usetimestamp="true" skipexisting="true" />
<get src="https://repo1.maven.org/maven2/org/bouncycastle/bcpg-jdk14/1.45/bcpg-jdk14-1.45.jar" dest="${ivy.jar.dir}" usetimestamp="true" skipexisting="true"/>
</target>
<!-- ================================= target: install-ivy this target is
not necessary if you put ivy.jar in your ant lib directory if you already
have ivy in your ant lib, you can simply remove this target and the dependency
the 'go' target has on it ================================= -->
<target name="install-ivy" depends="download-ivy" description="--> install ivy">
<!-- try to load ivy here from local ivy dir, in case the user has not
already dropped it into ant's lib dir (note that the latter copy will always
take precedence). We will not fail as long as local lib dir exists (it may
be empty) and ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<target name="load-setting" depends="install-ivy" if="ivysettings.present">
<get src="https://raw.githubusercontent.com/qmetry/qaf-parent/master/common-build.properties" dest="../common-build.properties" skipexisting="true"/>
<ivy:settings file="${ivysettings.xml}" />
<delete dir="${user.home}/.ivy2/cache/com.qmetry" failonerror="false" verbose="true" />
</target>
<!-- ================================= target: resolve ================================= -->
<target name="resolve" description="--> retrieve dependencies with ivy" depends="install-ivy, load-setting">
<ivy:resolve file="ivy.xml" />
<ivy:cachepath pathid="lib.path.id" />
<ivy:addpath topath="build.classpath">
<path refid="lib.path.id" />
</ivy:addpath>
<ivy:cachepath pathid="compile.path" conf="compile,provided" />
<ivy:cachepath pathid="test.path" conf="test,provided" />
</target>
<target name="init" depends="resolve">
<echo>===::${artifact.name}::===</echo>
<mkdir dir="${bin.dir}" />
<mkdir dir="${dist.dir}" />
<copy includeemptydirs="false" todir="${bin.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="clean">
<echo message="Building ${toString:build-path}" />
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${dist.dir}" failonerror="false" />
</target>
<target name="gendoc" depends="init" description="generate documentation">
<delete dir="${dist.dir}/docs" />
<mkdir dir="${dist.dir}/docs" />
<javadoc sourcepath="${src.dir}" destdir="${dist.dir}/docs" additionalparam="-Xdoclint:none" verbose="false" author="true" version="true" use="true" classpathref="build.classpath" encoding="utf-8"/>
<jar compress="true" destfile="${dist.dir}/${ivy.module}-javadoc.jar" basedir="${dist.dir}/docs" />
<delete dir="${dist.dir}/docs">
</delete>
</target>
<target name="gensource" description="Generate Source" depends="init">
<jar destfile="${dist.dir}/${ivy.module}-sources.jar" basedir="${src.dir}">
<metainf dir="." includes="LICENSE" />
<manifest>
<attribute name="Vendor" value="Infostretch Corp." />
<attribute name="Built-By" value="${user.name}" />
<section name="Build-Info">
<attribute name="qaf-Build-Time" value="${build.timestamp}" />
<!-- Information about the program itself -->
<attribute name="qaf-Version" value="${version-num}" />
<attribute name="qaf-Revision" value="${build-num}" />
</section>
</manifest>
</jar>
</target>
<target name="deploy-local" depends="init" description="local ivy install">
<ivy:buildnumber resolver="local-ivy-publish" organisation="${ivy.organisation}" module="${ivy.module}" revision="${release.num}" />
<ivy:deliver deliverpattern="${dist.dir}/ivy.xml" pubrevision="${release.num}" status="release" />
<ivy:makepom ivyfile="${dist.dir}/ivy.xml" pomfile="${dist.dir}/${ivy.module}.pom" templatefile="pom.tmpl">
<mapping conf="compile" scope="compile" />
<mapping conf="runtime" scope="runtime" />
<mapping conf="test" scope="test" />
<mapping conf="provided" scope="provided" />
</ivy:makepom>
<ivy:convertpom pomfile="${dist.dir}/${ivy.module}.pom" ivyfile="${dist.dir}/ivy.xml" description="create IVY" />
<ivy:publish resolver="local-ivy-publish" pubrevision="${release.num}" forcedeliver="false" overwrite="true" status="release">
<artifacts pattern="${dist.dir}/[artifact].[ext]" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]" ext="jar" classifier="sources" type="source" version="${release.num}" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]" ext="jar" classifier="javadoc" type="javadoc" version="${release.num}" />
</ivy:publish>
</target>
<target name="publish" depends="init" description="Publish the local repo.">
<!-- Determine build number from previously published revisions -->
<ivy:buildnumber resolver="local-m2-publish" organisation="${ivy.organisation}" module="${ivy.module}" revision="${release.num}" />
<!-- Resolve ivy dependencies and create a Maven POM file -->
<ivy:deliver deliverpattern="${dist.dir}/ivy.xml" pubrevision="${release.num}" status="release" />
<ivy:makepom ivyfile="${dist.dir}/ivy.xml" pomfile="${dist.dir}/${ivy.module}.pom" templatefile="pom.tmpl">
<mapping conf="compile" scope="compile" />
<mapping conf="runtime" scope="runtime" />
<mapping conf="test" scope="test" />
<mapping conf="provided" scope="provided" />
</ivy:makepom>
<ivy:convertpom pomfile="${dist.dir}/${ivy.module}.pom" ivyfile="${dist.dir}/ivy.xml" description="create IVY" />
<!-- Publish the local repo. Defaults to ~/.ivy2/local -->
<ivy:publish resolver="local-m2-publish" forcedeliver="false" pubrevision="${release.num}" overwrite="true">
<artifacts pattern="${dist.dir}/[artifact].[ext]" />
<!-- <artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]"
ext="pom" type="pom" version="${release.num}" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]"
ext="pom" type="pom" version="${release.num}" />
<artifact name="${ivy.module}-sources" pattern="${dist.dir}/[artifact].[ext]"
ext="jar" classifier="sources" type="sources" version="${release.num}" />
<artifact name="${ivy.module}-javadoc" pattern="${dist.dir}/[artifact].[ext]"
ext="jar" classifier="javadoc" type="javadoc" version="${release.num}" />-->
</ivy:publish>
</target>
<target name="publish-share" description="publish jar/source to maven repo mounted at ~/repo" depends="init">
<!-- Determine build number from previously published revisions -->
<ivy:buildnumber resolver="${publish.resolver}" organisation="${ivy.organisation}" module="${ivy.module}" revision="${release.num}" />
<!-- Resolve ivy dependencies and create a Maven POM file -->
<ivy:deliver deliverpattern="${dist.dir}/ivy.xml" pubrevision="${release.num}" status="${status}" />
<ivy:makepom ivyfile="${dist.dir}/ivy.xml" pomfile="${dist.dir}/${ivy.module}.pom" templatefile="pom.tmpl">
<mapping conf="compile" scope="compile" />
<mapping conf="runtime" scope="runtime" />
<mapping conf="test" scope="test" />
<mapping conf="provided" scope="provided" />
</ivy:makepom>
<!-- Publish the local repo. Defaults to ~/.ivy2/local -->
<ivy:publish resolver="${publish.resolver}" forcedeliver="true" publishivy="false" pubrevision="${release.num}" overwrite="true" status="${status}">
<artifacts pattern="${dist.dir}/[artifact](-[classifier]).[ext]" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]" ext="pom" type="pom" version="${release.num}" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]" ext="jar" classifier="sources" type="sources" version="${release.num}" />
<artifact name="${ivy.module}" pattern="${dist.dir}/[artifact].[ext]" ext="jar" classifier="javadoc" type="javadoc" version="${release.num}" />
</ivy:publish>
</target>
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="${basedir}" />
<attribute name="outProperty" default="git.cmd.output" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}" outputproperty="@{outProperty}">
<arg value="@{command}" />
<args />
</exec>
</sequential>
</macrodef>
<macrodef name="hub">
<attribute name="command" />
<attribute name="dir" default="${basedir}" />
<attribute name="outProperty" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="hub @{command}" />
<exec executable="hub" dir="@{dir}" outputproperty="@{outProperty}" output="out.txt">
<arg value="@{command}" />
<args />
</exec>
</sequential>
</macrodef>
<target name="getChangelog">
<git command="describe" outproperty="git.cmd.output">
<args>
<arg value="--tags" />
<arg value="--abbrev=0" />
</args>
</git>
<echo>Last Tag:${basedir}: ${git.cmd.output}</echo>
<git command="log" outproperty="git.log.outputog">
<args>
<arg value="${git.cmd.output}..HEAD" />
<arg value="--oneline" />
</args>
</git>
<echo>Change Log: ${git.log.outputog}</echo>
<echo file="out.txt" append="false">${artifact.name} Release ${release.num}${line.separator}${line.separator}</echo>
<echo append="true" file="out.txt">${git.log.outputog}</echo>
</target>
<target name="tag-release" depends="getChangelog">
<!-- hub release create - -copy -F release-notes.txt v2.3.0 -->
<hub command="release" outProperty="hub.output" >
<args>
<arg value="create"/>
<arg value="${release.num}"/>
<arg value="--prerelease"/>
<arg value="--file"/>
<arg value="out.txt"/>
</args>
</hub>
<echo>${hub.output}</echo>
</target>
</project>