2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
15 <project name="lz4" default="dist" basedir="."
16 xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
17 xmlns:ivy="antlib:org.apache.ivy.ant"
18 xmlns:junit4="antlib:com.carrotsearch.junit4"
19 xmlns:mvn="antlib:org.apache.maven.artifact.ant">
21 <property name="src" location="src"/>
22 <property name="build" location="build"/>
23 <property name="dist" location="dist"/>
24 <property name="lib" location="lib" />
26 <property name="javac.source" value="1.6" />
27 <property name="javac.target" value="1.6" />
29 <property name="ivy.jar.version" value="2.2.0"/>
30 <property name="ivy.jar.name" value="ivy-${ivy.jar.version}.jar"/>
32 <condition property="platform" value="linux">
35 <condition property="platform" value="win32">
36 <os family="windows"/>
38 <condition property="platform" value="solaris">
41 <condition property="platform" value="darwin">
45 <target name="clean" description="clean working copy">
46 <delete dir="${build}" />
47 <delete dir="${dist}" />
48 <delete dir="${lib}" />
51 <target name="ivy-bootstrap" description="install ivy" unless="ivy.available">
52 <condition property="ivy.available">
53 <typefound uri="antlib:org.apache.ivy.ant" name="configure" />
55 <antcall target="-ivy-install" />
58 <target name="-ivy-install" unless="ivy.available">
59 <mkdir dir="${user.home}/.ant/lib" />
60 <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}"/>
63 <target name="install-cpptasks" unless="cpptasks.available">
64 <ivy:cachepath organisation="ant-contrib" module="cpptasks" revision="1.0b5"
65 inline="true" conf="default" transitive="true" pathid="cpptasks.classpath"/>
66 <taskdef uri="antlib:net.sf.antcontrib.cpptasks" resource="net/sf/antcontrib/cpptasks/antlib.xml" classpathref="cpptasks.classpath"/>
67 <property name="cpptasks.available" value="true"/>
70 <target name="install-maven-ant-tasks" unless="maven-ant-tasks.available">
71 <ivy:cachepath organisation="org.apache.maven" module="maven-ant-tasks" revision="2.1.3"
72 inline="true" conf="default" transitive="true" pathid="maven-ant-tasks.classpath"/>
73 <taskdef uri="antlib:org.apache.maven.artifact.ant" resource="org/apache/maven/artifact/ant/antlib.xml" classpathref="maven-ant-tasks.classpath"/>
74 <property name="maven-ant-tasks.available" value="true"/>
77 <target name="install-forbidden-apis" unless="forbidden-apis.available">
78 <ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.3"
79 inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/>
80 <taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.AntTask" classpathref="forbidden-apis.classpath"/>
81 <property name="forbidden-apis.available" value="true"/>
84 <target name="install-bnd" unless="bnd.available">
85 <!-- using bnd 1.50.0 because more recent versions have broken JAR wrapping -->
86 <ivy:cachepath organisation="biz.aQute" module="bnd" revision="1.50.0"
87 inline="true" conf="default" transitive="true" pathid="bnd.classpath"/>
88 <taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd.classpath"/>
89 <property name="bnd.available" value="true"/>
94 <ivy:resolve conf="test" />
98 <target name="install-junit4" depends="init" unless="junit4.available">
99 <taskdef uri="antlib:com.carrotsearch.junit4">
101 <fileset dir="${lib}" includes="*.jar" />
104 <property name="junit4.available" value="true" />
107 <target name="generate-sources" depends="init">
108 <ivy:cachepath organisation="org.mvel" module="mvel2" revision="2.1.5.Final"
109 inline="true" conf="default" transitive="true" pathid="mvel.classpath"/>
110 <mkdir dir="${build}/java" />
113 classpathref="mvel.classpath"
114 classname="org.mvel2.sh.Main"
115 dir="${src}/build/source_templates">
116 <sysproperty key="out.dir" value="${build}/java"/>
117 <arg value="${src}/build/gen_sources.mvel" />
121 <target name="compile-java" depends="init, generate-sources">
122 <mkdir dir="${build}/classes" />
124 includeAntRuntime="false"
126 source="${javac.source}"
127 target="${javac.target}"
130 destdir="${build}/classes"/>
131 <mkdir dir="${build}/unsafe-classes" />
133 includeAntRuntime="false"
134 srcdir="${src}/java-unsafe"
135 source="${javac.source}"
136 target="${javac.target}"
139 classpath="${build}/classes"
140 destdir="${build}/unsafe-classes"/>
141 <mkdir dir="${build}/generated-classes" />
143 includeAntRuntime="false"
144 srcdir="${build}/java"
145 source="${javac.source}"
146 target="${javac.target}"
149 destdir="${build}/generated-classes">
151 <pathelement location="${build}/classes/" />
152 <pathelement location="${build}/unsafe-classes" />
157 <target name="generate-headers" depends="compile-java" unless="${skip.jni}">
158 <mkdir dir="${build}/jni-headers" />
160 destDir="${build}/jni-headers">
162 <pathelement location="${build}/classes/" />
164 <class name="net.jpountz.lz4.LZ4JNI" />
165 <class name="net.jpountz.xxhash.XXHashJNI" />
169 <target name="compile-jni" depends="install-cpptasks,generate-headers" unless="${skip.jni}">
170 <mkdir dir="${build}/objects" />
171 <mkdir dir="${build}/jni/net/jpountz/util/${platform}/${os.arch}" />
175 objdir="${build}/objects"
176 outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
178 <includepath path="${src}/xxhash" />
179 <includepath path="${src}/lz4" />
180 <includepath path="${java.home}/../include" />
181 <includepath path="${java.home}/../include/${platform}/" />
182 <includepath path="${build}/jni-headers" />
183 <fileset dir="${src}/lz4" includes="lz4.c, lz4hc.c" />
184 <fileset dir="${src}/xxhash" includes="xxhash.c" />
185 <fileset dir="${src}/jni" includes="*.c" />
190 <target name="compile" depends="compile-java, compile-jni" />
192 <target name="compile-tests" depends="compile">
193 <mkdir dir="${build}/test-classes" />
195 includeAntRuntime="false"
199 destdir="${build}/test-classes">
201 <path location="${build}/classes" />
202 <path location="${build}/unsafe-classes" />
203 <path location="${build}/generated-classes" />
204 <fileset dir="lib" includes="*.jar" />
209 <target name="test" description="run tests" depends="compile-tests, install-junit4">
210 <mkdir dir="${build}/tests" />
212 dir="${java.io.tmpdir}"
216 <enable package="net.jpountz.lz4"/>
219 <path location="${src}/resources" />
220 <path location="${src}/test-resources" />
221 <path location="${build}/classes" />
222 <path location="${build}/unsafe-classes" />
223 <path location="${build}/generated-classes" />
224 <path location="${build}/test-classes" />
225 <path location="${build}/jni" />
226 <fileset dir="${lib}" includes="*.jar" />
228 <fileset dir="${build}/test-classes/">
229 <include name="**/*Test.class" />
230 <exclude name="**/*$*" />
231 <exclude name="**/Abstract*" />
236 showStackTraces="true"
240 showStatusError="true"
241 showStatusFailure="true"
242 showStatusIgnored="true"
244 showSuiteSummary="false" />
246 <junit4:report-ant-xml dir="${build}/tests" />
251 <target name="sources" description="package sources">
252 <mkdir dir="${dist}" />
254 destfile="${dist}/${ivy.module}-${ivy.revision}-sources.jar">
255 <fileset dir="${src}/java" />
256 <fileset dir="${src}/java-unsafe" />
260 <target name="docs" description="generate javadocs" depends="init">
261 <mkdir dir="${build}/docs" />
263 overview="${src}/java/overview.html"
264 packagenames="net.jpountz.lz4,net.jpountz.xxhash"
265 windowtitle="lz4 / xxhash - Java API ${ivy.revision}"
266 destDir="${build}/docs">
267 <link href="http://download.oracle.com/javase/6/docs/api/" />
269 <pathelement location="${src}/java"/>
272 <mkdir dir="${dist}" />
274 destfile="${dist}/${ivy.module}-${ivy.revision}-javadoc.jar">
275 <fileset dir="${build}/docs" />
279 <target name="jar" description="generate JAR" depends="compile">
280 <mkdir dir="${dist}" />
282 destfile="${dist}/${ivy.module}.jar">
283 <fileset dir="${src}/resources" erroronmissingdir="false" />
284 <fileset dir="${build}/classes" />
285 <fileset dir="${build}/unsafe-classes" />
286 <fileset dir="${build}/generated-classes" />
287 <fileset dir="${build}/jni" erroronmissingdir="false" />
291 <target name="bundle" description="makes the JAR a valid OSGi bundle" depends="install-bnd, jar">
292 <taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd.classpath"/>
293 <property name="packages.version" value="${ivy.revision}"/>
294 <!-- We need to remove potential -SNAPSHOT qualifiers as package versions... -->
295 <script language="javascript">
297 // lz4 is the ant project name
298 version = lz4.getProperty("packages.version");
299 lz4.setProperty("packages.version", version.replace("-SNAPSHOT", ""));
302 <!-- wrap the JAR as a bundle and set the proper name -->
303 <bndwrap definitions="${basedir}" output="${dist}/${ivy.module}-${ivy.revision}.jar" trace="true">
304 <fileset dir="${dist}/" includes="${ivy.module}.jar"/>
306 <!-- remove plain JAR -->
307 <delete file="${dist}/${ivy.module}.jar"/>
310 <target name="makepom" description="generate a pom file">
312 ivyfile="${basedir}/ivy.xml"
313 pomfile="${dist}/${ivy.module}-${ivy.revision}.pom"
314 templatefile="${src}/build/pom.template">
315 <mapping conf="default" scope="compile" />
316 <mapping conf="test" scope="test" />
320 <target name="dist" description="package" depends="bundle,docs,sources,makepom" />
322 <target name="forbidden-apis" description="check API usage" depends="install-forbidden-apis,compile">
323 <forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.classpath">
324 <bundledSignatures name="jdk-unsafe-${javac.target}"/>
325 <bundledSignatures name="jdk-deprecated-${javac.target}"/>
326 <fileset dir="${build}/classes" includes="**/*.class" />
328 <forbidden-apis classpathref="forbidden-apis.classpath">
329 <bundledSignatures name="jdk-unsafe-${javac.target}"/>
330 <bundledSignatures name="jdk-deprecated-${javac.target}"/>
331 <fileset dir="${build}/classes" includes="**/*.class" />
332 <fileset dir="${build}/unsafe-classes" includes="**/*.class" />
336 <macrodef name="deploy">
337 <attribute name="repositoryid" />
338 <attribute name="repositoryurl" />
341 <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file" />
342 <arg value="-Durl=@{repositoryurl}" />
343 <arg value="-DrepositoryId=@{repositoryid}" />
344 <arg value="-DpomFile=${dist}/${ivy.module}-${ivy.revision}.pom" />
345 <arg value="-Dfile=${dist}/${ivy.module}-${ivy.revision}.jar" />
346 <arg value="-Dfiles=${dist}/${ivy.module}-${ivy.revision}-sources.jar,${dist}/${ivy.module}-${ivy.revision}-javadoc.jar" />
347 <arg value="-Dclassifiers=sources,javadoc" />
348 <arg value="-Dtypes=jar,jar" />
349 <arg value="-Pgpg" />
354 <target name="deploy" description="deploy snapshot to snapshot repo" depends="install-maven-ant-tasks">
355 <property name="skip.jni" value="true" />
356 <antcall target="-deploy" />
359 <target name="-deploy" depends="clean,dist">
360 <deploy repositoryid="sonatype-nexus-snapshots" repositoryurl="https://oss.sonatype.org/content/repositories/snapshots" />
363 <!-- before this, update project version from SNAPSHOT to RELEASE -->
364 <target name="stage" description="deploy to release repo" depends="install-maven-ant-tasks,test,forbidden-apis">
365 <property name="skip.jni" value="true" />
366 <antcall target="-stage" />
369 <target name="-stage" depends="clean,dist">
370 <deploy repositoryid="sonatype-nexus-staging" repositoryurl="https://oss.sonatype.org/service/local/staging/deploy/maven2" />