-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
257 lines (225 loc) · 8.99 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
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="sorts" default="dist" basedir="."
xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:junit4="antlib:com.carrotsearch.junit4"
xmlns:mvn="antlib:org.apache.maven.artifact.ant">
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="lib" location="lib" />
<property name="javac.source" value="1.6" />
<property name="javac.target" value="1.6" />
<property name="ivy.jar.version" value="2.2.0"/>
<property name="ivy.jar.name" value="ivy-${ivy.jar.version}.jar"/>
<target name="clean" description="clean working copy">
<delete dir="${build}" />
<delete dir="${dist}" />
<delete dir="${lib}" />
</target>
<target name="ivy-bootstrap" description="install ivy" unless="ivy.available">
<condition property="ivy.available">
<typefound uri="antlib:org.apache.ivy.ant" name="configure" />
</condition>
<antcall target="-ivy-install" />
</target>
<target name="-ivy-install" unless="ivy.available">
<mkdir dir="${user.home}/.ant/lib" />
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.version}/${ivy.jar.name}" dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
</target>
<target name="install-maven-ant-tasks" unless="maven-ant-tasks.available">
<ivy:cachepath organisation="org.apache.maven" module="maven-ant-tasks" revision="2.1.3"
inline="true" conf="default" transitive="true" pathid="maven-ant-tasks.classpath"/>
<taskdef uri="antlib:org.apache.maven.artifact.ant" resource="org/apache/maven/artifact/ant/antlib.xml" classpathref="maven-ant-tasks.classpath"/>
<property name="maven-ant-tasks.available" value="true"/>
</target>
<target name="install-forbidden-apis" unless="forbidden-apis.available">
<ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.3"
inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/>
<taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.AntTask" classpathref="forbidden-apis.classpath"/>
<property name="forbidden-apis.available" value="true"/>
</target>
<target name="init">
<tstamp />
<ivy:resolve conf="test" />
<ivy:retrieve />
</target>
<target name="install-junit4" depends="init" unless="junit4.available">
<taskdef uri="antlib:com.carrotsearch.junit4">
<classpath>
<fileset dir="${lib}" includes="*.jar" />
</classpath>
</taskdef>
<property name="junit4.available" value="true" />
</target>
<target name="compile-java" depends="init">
<mkdir dir="${build}/classes" />
<javac
includeAntRuntime="false"
srcdir="${src}/java"
source="${javac.source}"
target="${javac.target}"
encoding="UTF-8"
debug="true"
destdir="${build}/classes"/>
</target>
<target name="compile-examples" depends="compile-java">
<mkdir dir="${build}/example-classes" />
<javac
includeAntRuntime="false"
srcdir="${src}/example"
source="${javac.source}"
target="${javac.target}"
encoding="UTF-8"
debug="true"
destdir="${build}/example-classes">
<classpath>
<path location="${build}/classes" />
</classpath>
</javac>
</target>
<target name="compile" depends="compile-java" />
<target name="compile-tests" depends="compile,compile-examples">
<mkdir dir="${build}/test-classes" />
<javac
includeAntRuntime="false"
srcdir="${src}/test"
source="${javac.source}"
target="${javac.target}"
encoding="UTF-8"
debug="true"
destdir="${build}/test-classes">
<classpath>
<path location="${build}/classes" />
<path location="${build}/example-classes" />
<fileset dir="lib" includes="*.jar" />
</classpath>
</javac>
</target>
<target name="test" description="run tests" depends="compile-tests, install-junit4">
<mkdir dir="${build}/tests" />
<junit4:junit4
dir="${java.io.tmpdir}"
maxmemory="100m"
parallelism="auto">
<assertions>
<enable package="net.jpountz.sorts"/>
</assertions>
<classpath>
<path location="${build}/classes" />
<path location="${build}/example-classes" />
<path location="${build}/test-classes" />
<fileset dir="${lib}" includes="*.jar" />
</classpath>
<fileset dir="${build}/test-classes/">
<include name="**/*Test.class" />
<exclude name="**/*$*" />
<exclude name="**/Abstract*" />
</fileset>
<listeners>
<junit4:report-text
showThrowable="true"
showStackTraces="true"
showOutput="never"
showStatusOk="true"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="false" />
<!-- For enkins -->
<junit4:report-ant-xml dir="${build}/tests" />
</listeners>
</junit4:junit4>
</target>
<target name="sources" description="package sources">
<mkdir dir="${dist}" />
<jar
destfile="${dist}/${ivy.module}-${ivy.revision}-sources.jar">
<fileset dir="${src}/java" />
</jar>
</target>
<target name="docs" description="generate javadocs" depends="init">
<mkdir dir="${build}/docs" />
<javadoc
overview="${src}/java/overview.html"
packagenames="net.jpountz.sorts"
windowtitle="Sorts API ${ivy.revision}"
destDir="${build}/docs">
<link href="http://download.oracle.com/javase/6/docs/api/" />
<sourcepath>
<pathelement location="${src}/java"/>
</sourcepath>
</javadoc>
<mkdir dir="${dist}" />
<jar
destfile="${dist}/${ivy.module}-${ivy.revision}-javadoc.jar">
<fileset dir="${build}/docs" />
</jar>
</target>
<target name="jar" description="generate JAR" depends="compile">
<mkdir dir="${dist}" />
<jar
destfile="${dist}/${ivy.module}-${ivy.revision}.jar">
<fileset dir="${build}/classes" />
</jar>
</target>
<target name="makepom" description="generate a pom file">
<ivy:makepom
ivyfile="${basedir}/ivy.xml"
pomfile="${dist}/${ivy.module}-${ivy.revision}.pom"
templatefile="${src}/build/pom.template">
<mapping conf="default" scope="compile" />
<mapping conf="test" scope="test" />
</ivy:makepom>
</target>
<target name="dist" description="package" depends="jar,docs,sources,makepom" />
<target name="forbidden-apis" description="check API usage" depends="install-forbidden-apis,compile">
<forbidden-apis classpathref="forbidden-apis.classpath">
<bundledSignatures name="jdk-unsafe-${javac.target}"/>
<bundledSignatures name="jdk-deprecated-${javac.target}"/>
<fileset dir="${build}/classes" includes="**/*.class" />
</forbidden-apis>
</target>
<macrodef name="deploy">
<attribute name="repositoryid" />
<attribute name="repositoryurl" />
<sequential>
<mvn:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file" />
<arg value="-Durl=@{repositoryurl}" />
<arg value="-DrepositoryId=@{repositoryid}" />
<arg value="-DpomFile=${dist}/${ivy.module}-${ivy.revision}.pom" />
<arg value="-Dfile=${dist}/${ivy.module}-${ivy.revision}.jar" />
<arg value="-Dfiles=${dist}/${ivy.module}-${ivy.revision}-sources.jar,${dist}/${ivy.module}-${ivy.revision}-javadoc.jar" />
<arg value="-Dclassifiers=sources,javadoc" />
<arg value="-Dtypes=jar,jar" />
<arg value="-Pgpg" />
</mvn:mvn>
</sequential>
</macrodef>
<target name="deploy" description="deploy snapshot to snapshot repo" depends="install-maven-ant-tasks">
<property name="skip.jni" value="true" />
<antcall target="-deploy" />
</target>
<target name="-deploy" depends="clean,dist">
<deploy repositoryid="sonatype-nexus-snapshots" repositoryurl="https://oss.sonatype.org/content/repositories/snapshots" />
</target>
<!-- before this, update project version from SNAPSHOT to RELEASE -->
<target name="stage" description="deploy to release repo" depends="install-maven-ant-tasks,test,forbidden-apis">
<property name="skip.jni" value="true" />
<antcall target="-stage" />
</target>
<target name="-stage" depends="clean,dist">
<deploy repositoryid="sonatype-nexus-staging" repositoryurl="https://oss.sonatype.org/service/local/staging/deploy/maven2" />
</target>
</project>