]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.lz4/build.xml
Block external and excluded seeds in ConsistsOfProcess
[simantics/platform.git] / bundles / org.simantics.lz4 / build.xml
1 <!--
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
5
6        http://www.apache.org/licenses/LICENSE-2.0
7
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.
13 -->
14
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">
20
21   <property name="src" location="src"/>
22   <property name="build" location="build"/>
23   <property name="dist"  location="dist"/>
24   <property name="lib" location="lib" />
25
26   <property name="javac.source" value="1.6" />
27   <property name="javac.target" value="1.6" />
28
29   <property name="ivy.jar.version" value="2.2.0"/>
30   <property name="ivy.jar.name" value="ivy-${ivy.jar.version}.jar"/>
31
32   <condition property="platform" value="linux">
33    <os name="Linux"/>
34   </condition>
35   <condition property="platform" value="win32">
36    <os family="windows"/>
37   </condition>
38   <condition property="platform" value="solaris">
39    <os name="SunOS"/>
40   </condition>
41   <condition property="platform" value="darwin">
42    <os family="mac"/>
43   </condition>
44
45   <target name="clean" description="clean working copy">
46     <delete dir="${build}" />
47     <delete dir="${dist}" />
48     <delete dir="${lib}" />
49   </target>
50
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" />
54     </condition>
55     <antcall target="-ivy-install" />
56   </target>
57
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}"/>
61   </target>
62
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"/>
68   </target>
69
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"/>
75   </target>
76
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"/>
82   </target>
83
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"/> 
90   </target>
91
92   <target name="init">
93     <tstamp />
94     <ivy:resolve conf="test" />
95     <ivy:retrieve />
96   </target>
97
98   <target name="install-junit4" depends="init" unless="junit4.available">
99     <taskdef uri="antlib:com.carrotsearch.junit4">
100       <classpath>
101         <fileset dir="${lib}" includes="*.jar" />
102       </classpath>
103     </taskdef>
104     <property name="junit4.available" value="true" />
105   </target>
106
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" />
111     <java
112       fork="true"
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" />
118     </java>
119   </target>
120
121   <target name="compile-java" depends="init, generate-sources">
122     <mkdir dir="${build}/classes" />
123     <javac
124       includeAntRuntime="false"
125       srcdir="${src}/java"
126       source="${javac.source}"
127       target="${javac.target}"
128       encoding="UTF-8"
129       debug="true"
130       destdir="${build}/classes"/>
131     <mkdir dir="${build}/unsafe-classes" />
132     <javac
133       includeAntRuntime="false"
134       srcdir="${src}/java-unsafe"
135       source="${javac.source}"
136       target="${javac.target}"
137       encoding="UTF-8"
138       debug="true"
139       classpath="${build}/classes"
140       destdir="${build}/unsafe-classes"/>
141     <mkdir dir="${build}/generated-classes" />
142     <javac
143       includeAntRuntime="false"
144       srcdir="${build}/java"
145       source="${javac.source}"
146       target="${javac.target}"
147       encoding="UTF-8"
148       debug="true"
149       destdir="${build}/generated-classes">
150       <classpath>
151         <pathelement location="${build}/classes/" />
152         <pathelement location="${build}/unsafe-classes" />
153       </classpath>
154     </javac>
155   </target>
156
157   <target name="generate-headers" depends="compile-java" unless="${skip.jni}">
158     <mkdir dir="${build}/jni-headers" />
159     <javah
160       destDir="${build}/jni-headers">
161       <classpath>
162         <pathelement location="${build}/classes/" />
163       </classpath>
164       <class name="net.jpountz.lz4.LZ4JNI" />
165       <class name="net.jpountz.xxhash.XXHashJNI" />
166     </javah>
167   </target>
168
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}" />
172     <cpptasks:cc
173       debug="false"
174       optimize="extreme"
175       objdir="${build}/objects"
176       outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
177       outtype="shared">
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" />
186       <linker />
187     </cpptasks:cc>
188   </target>
189
190   <target name="compile" depends="compile-java, compile-jni" />
191
192   <target name="compile-tests" depends="compile">
193     <mkdir dir="${build}/test-classes" />
194     <javac
195       includeAntRuntime="false"
196       srcdir="${src}/test"
197       encoding="UTF-8"
198       debug="true"
199       destdir="${build}/test-classes">
200       <classpath>
201         <path location="${build}/classes" />
202         <path location="${build}/unsafe-classes" />
203         <path location="${build}/generated-classes" />
204         <fileset dir="lib" includes="*.jar" />
205       </classpath>
206     </javac>
207   </target>
208
209   <target name="test" description="run tests" depends="compile-tests, install-junit4">
210     <mkdir dir="${build}/tests" />
211     <junit4:junit4
212       dir="${java.io.tmpdir}"
213       maxmemory="300m"
214       parallelism="auto">
215       <assertions>
216         <enable package="net.jpountz.lz4"/>
217       </assertions>
218       <classpath>
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" />
227       </classpath>
228       <fileset dir="${build}/test-classes/">
229         <include name="**/*Test.class" />
230         <exclude name="**/*$*" />
231         <exclude name="**/Abstract*" />
232       </fileset>
233       <listeners>
234         <junit4:report-text
235         showThrowable="true"
236         showStackTraces="true"
237         showOutput="never"
238
239         showStatusOk="true"
240         showStatusError="true"
241         showStatusFailure="true"
242         showStatusIgnored="true"
243
244         showSuiteSummary="false" />
245         <!-- For enkins -->
246         <junit4:report-ant-xml dir="${build}/tests" />
247       </listeners>
248     </junit4:junit4>
249   </target>
250
251   <target name="sources" description="package sources">
252     <mkdir dir="${dist}" />
253     <jar
254       destfile="${dist}/${ivy.module}-${ivy.revision}-sources.jar">
255       <fileset dir="${src}/java" />
256       <fileset dir="${src}/java-unsafe" />
257     </jar>
258   </target>
259
260   <target name="docs" description="generate javadocs" depends="init">
261     <mkdir dir="${build}/docs" />
262     <javadoc
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/" />
268       <sourcepath>
269         <pathelement location="${src}/java"/>
270       </sourcepath>
271     </javadoc>
272     <mkdir dir="${dist}" />
273     <jar
274       destfile="${dist}/${ivy.module}-${ivy.revision}-javadoc.jar">
275       <fileset dir="${build}/docs" />
276     </jar>
277   </target>
278
279   <target name="jar" description="generate JAR" depends="compile">
280     <mkdir dir="${dist}" />
281     <jar
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" />
288     </jar>
289   </target>
290
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">
296             <![CDATA[
297                 // lz4 is the ant project name
298                 version = lz4.getProperty("packages.version");
299                 lz4.setProperty("packages.version", version.replace("-SNAPSHOT", ""));
300             ]]>
301     </script>
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"/>
305     </bndwrap>
306     <!-- remove plain JAR -->
307     <delete file="${dist}/${ivy.module}.jar"/>
308   </target>
309
310   <target name="makepom" description="generate a pom file">
311     <ivy:makepom
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" />
317     </ivy:makepom>
318   </target>
319
320   <target name="dist" description="package" depends="bundle,docs,sources,makepom" />
321
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" />
327     </forbidden-apis>
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" />
333     </forbidden-apis>
334   </target>
335
336   <macrodef name="deploy">
337     <attribute name="repositoryid" />
338     <attribute name="repositoryurl" />
339     <sequential>
340       <mvn:mvn>
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" />
350       </mvn:mvn>
351     </sequential>
352   </macrodef>
353
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" />
357   </target>
358
359   <target name="-deploy" depends="clean,dist">
360     <deploy repositoryid="sonatype-nexus-snapshots" repositoryurl="https://oss.sonatype.org/content/repositories/snapshots" />
361   </target>
362
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" />
367   </target>
368
369   <target name="-stage" depends="clean,dist">
370     <deploy repositoryid="sonatype-nexus-staging" repositoryurl="https://oss.sonatype.org/service/local/staging/deploy/maven2" />
371   </target>
372
373 </project>