• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0"?>
2
3<project name="common">
4
5  <property file="build.properties"/>
6
7  <!-- can be overridden at the command line with -Dversion=
8       or in IDEA, in the ant properties dialog -->
9  <property name="version" value="snapshot"/>
10  <property name="api.version" value="1.4"/>
11
12  <target name="compile" description="Compile Java source.">
13    <mkdir dir="${build.dir}/classes"/>
14    <javac srcdir="${src.dir}"
15         debug="on"
16         destdir="${build.dir}/classes"
17         source="1.6" target="1.6" includeantruntime="false">
18      <compilerarg value="-Xlint:all,-serial"/>
19      <classpath refid="compile.classpath"/>
20    </javac>
21    <copy toDir="${build.dir}/classes">
22      <fileset dir="${src.dir}" excludes="**/*.java"/>
23    </copy>
24  </target>
25
26  <target name="manifest" description="Generate OSGi manifest." depends="compile">
27    <dirname property="common.basedir" file="${ant.file.common}"/>
28    <taskdef resource="aQute/bnd/ant/taskdef.properties"
29      classpath="${common.basedir}/lib/build/bnd-0.0.384.jar"/>
30
31    <fail unless="module" message="Missing 'module' property (use the primary package name in this jar)"/>
32    <property name="imports" value=""/>
33
34    <property name="Bundle-Name" value="${ant.project.name}"/>
35    <property name="Bundle-SymbolicName" value="${module}"/>
36    <property name="Bundle-Version" value="${replace;${version};^[^0-9];0.0.0.$0}"/>
37
38    <property name="Bundle-Description" value="Guice is a lightweight dependency injection framework for Java 6 and above"/>
39    <property name="Bundle-DocURL" value="https://github.com/google/guice"/>
40    <property name="Bundle-Copyright" value="Copyright (C) 2006 Google Inc."/>
41    <property name="Bundle-License" value="http://www.apache.org/licenses/LICENSE-2.0.txt"/>
42    <property name="Bundle-RequiredExecutionEnvironment" value="JavaSE-1.6"/>
43    <property name="Bundle-Vendor" value="Google, Inc."/>
44
45    <property name="Export-Package" value="!${module}.internal.*,${module}.*;version=${api.version}"/>
46
47    <condition property="Eclipse-ExtensibleAPI" value="true">
48      <equals arg1="${module}" arg2="com.google.inject"/>
49    </condition>
50
51    <condition property="Import-Package" value="!com.google.inject.*,*" else="!${module}.*,${imports},*">
52      <istrue value="${fragment}"/>
53    </condition>
54
55    <condition property="Fragment-Host" value="com.google.inject">
56      <istrue value="${fragment}"/>
57    </condition>
58
59    <property name="-nouses" value="true"/>
60
61    <property name="-removeheaders" value="Bnd-LastModified,Ignore-Package,Include-Resource,Private-Package,Tool"/>
62
63    <bndwrap jars="${build.dir}/classes" output="${build.dir}"/>
64
65    <unjar src="${build.dir}/classes.bar" dest="${build.dir}">
66      <patternset>
67        <include name="META-INF/MANIFEST.MF"/>
68      </patternset>
69    </unjar>
70  </target>
71
72  <target name="test.compile"
73      depends="compile"
74      description="Compile test source.">
75    <mkdir dir="${build.dir}/test"/>
76    <javac srcdir="${test.dir}"
77         debug="on"
78         destdir="${build.dir}/test"
79         source="1.6" target="1.6" includeantruntime="false">
80      <classpath path="${build.dir}/classes"/>
81      <classpath path="${build.dir}/test"/>
82      <classpath refid="compile.classpath"/>
83    </javac>
84    <copy toDir="${build.dir}/test">
85      <fileset dir="${test.dir}" excludes="**/*.java"/>
86    </copy>
87  </target>
88
89  <target name="test"
90      depends="test.compile"
91      description="Execute JUnit tests.">
92    <java fork="true"
93        classname="junit.textui.TestRunner"
94        failonerror="true"
95        taskname="junit">
96      <classpath>
97        <pathelement location="${build.dir}/test"/>
98        <pathelement location="${build.dir}/classes"/>
99        <path refid="compile.classpath"/>
100      </classpath>
101      <arg value="${test.class}"/>
102    </java>
103  </target>
104
105  <target name="clean"
106      description="Remove generated files.">
107    <delete dir="${build.dir}"/>
108  </target>
109
110  <target name="source.jar"
111      description="Create a .jar file with sources">
112    <mkdir dir="${build.dir}"/>
113    <zip destfile="${build.dir}/${ant.project.name}-${version}-src.jar">
114      <fileset dir="${src.dir}"/>
115    </zip>
116  </target>
117
118  <target name="distjars"
119      depends="source.jar, jar"
120      description="Build jar files"/>
121
122  <target name="test.withdeps" depends="test.compile"
123      description="Build a jar of tests with internal.util refocused.">
124    <mkdir dir="${build.dir}/dist"/>
125    <dirname property="common.basedir" file="${ant.file.common}"/>
126    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
127        classpath="${common.basedir}/lib/build/jarjar-1.1.jar"/>
128    <jarjar jarfile="${build.dir}/${ant.project.name}-${version}-tests.jar">
129      <fileset dir="${build.dir}/test"/>
130      <rule pattern="net.sf.cglib.*" result="com.google.inject.internal.cglib.$@1"/>
131      <rule pattern="net.sf.cglib.**.*" result="com.google.inject.internal.cglib.@1.$@2"/>
132      <rule pattern="org.objectweb.asm.*" result="com.google.inject.internal.asm.$@1"/>
133      <rule pattern="org.objectweb.asm.**.*" result="com.google.inject.internal.asm.@1.$@2"/>
134      <keep pattern="com.google.inject.**"/>
135      <keep pattern="com.googlecode.**"/>
136    </jarjar>
137  </target>
138
139  <target name="jar.withdeps" depends="compile"
140      description="Build jar with dependencies embedded.">
141    <mkdir dir="${build.dir}/dist"/>
142    <dirname property="common.basedir" file="${ant.file.common}"/>
143    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
144        classpath="${common.basedir}/lib/build/jarjar-1.1.jar"/>
145    <jarjar jarfile="${build.dir}/${ant.project.name}-with-deps.jar">
146      <fileset dir="${build.dir}/classes"/>
147      <zipfileset src="${common.basedir}/lib/build/cglib-3.1.jar"/>
148      <zipfileset src="${common.basedir}/lib/build/asm-5.0.3.jar"/>
149      <rule pattern="net.sf.cglib.*" result="com.google.inject.internal.cglib.$@1"/>
150      <rule pattern="net.sf.cglib.**.*" result="com.google.inject.internal.cglib.@1.$@2"/>
151      <rule pattern="org.objectweb.asm.*" result="com.google.inject.internal.asm.$@1"/>
152      <rule pattern="org.objectweb.asm.**.*" result="com.google.inject.internal.asm.@1.$@2"/>
153      <keep pattern="com.google.inject.**"/>
154    </jarjar>
155  </target>
156</project>
157