forked from bridgedb/BridgeDb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-common.xml
145 lines (125 loc) · 4.89 KB
/
build-common.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
<?xml version="1.0"?>
<project name="BridgeDb-common" basedir=".">
<property name="ant.build.javac.target" value="1.6"/>
<property name="ant.build.javac.source" value="1.6"/>
<property name="checkstyle.output.file" value="warnings.txt"/>
<property file="version.props"/>
<!-- Override this to put the jars in a different target directory -->
<property name="bundle.dest" value="../dist"/>
<target name="prepare-jar-name">
<!-- the name of the plug-in jar is the project name of the calling build file with '.jar' appended -->
<property name="jar.name" value="${bundle.dest}/${ant.project.name}.jar"/>
</target>
<target name="prepare-common" depends="prepare-jar-name">
<mkdir dir="build"/>
<!-- the following property is used to skip the "test" target if there is no test subdirectory -->
<condition property="test.dir.exists"><available file="test"/></condition>
</target>
<path id="absolute.and.libs">
<path refid="absolute.deps"/>
<fileset dir="lib" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
</path>
<target name="prepare"/> <!-- designed to be overriden by project build file -->
<target name="build" depends="prepare, prepare-common">
<javac srcdir="src"
includes="**"
debug="true"
source="${ant.build.javac.source}"
destdir="build">
<classpath refid="absolute.and.libs"/>
</javac>
</target>
<!-- if the embed.jars property is specified, those jars will be unjarred into the build directory -->
<target name="unjar-embedded" depends="build">
<unjar dest="build">
<path refid="embed.jars"/>
</unjar>
</target>
<target name="jar-common" depends="build, unjar-embedded">
<echo>Creating JAR: ${jar.name}</echo>
<!-- convert classpath to a flat list/string for use as manifest classpath.
We want a flat list, assuming all jars will end up in the same destination dir.
We can't use the manifestclasspath task for this, because it will try to figure
out relative paths, which is not what we want because the jars are not in their
final location -->
<pathconvert property="manifest.cp" pathsep=" ">
<path refid="absolute.deps"/>
<path refid="transient.deps"/>
<flattenmapper />
</pathconvert>
<!-- In eclipse, you need create a Bundle-ClassPath entry in MANIFEST.MF for each non-OSGI jar.
This causes trouble if we are running outside eclipse, because the jars usually end up in a different location.
The trick is to remove the bundle-classpath used by eclipse, we embed these jars instead -->
<copy file="META-INF/MANIFEST.MF" toDir="build/META-INF"/>
<replaceregexp file="build/META-INF/MANIFEST.MF" match="^Bundle-ClassPath:" replace="Ignore-this:" flags="m"/>
<!-- Finally, create the jar file. Include all resources, build results, and manifest. -->
<jar jarfile="${jar.name}" manifest="META-INF/MANIFEST.MF">
<manifest>
<attribute name="Class-Path" value="${manifest.cp}"/>
</manifest>
<fileset dir="resources" erroronmissingdir="false">
<include name="**/*"/>
</fileset>
<fileset dir="build">
<include name="**/*.class"/>
<include name="**/*.properties"/>
</fileset>
</jar>
</target>
<target name="jar" depends="jar-common"/> <!-- may be overriden by project build file -->
<!-- just removes class files -->
<target name="clean">
<delete dir="build"/>
<delete dir="target"/>
</target>
<!-- removes class files and generated jar -->
<target name="dist-clean" depends="clean, prepare-jar-name">
<delete file="${jar.name}"/>
</target>
<!-- creates the jar, and also places all dependencies in the bundle dest directory -->
<target name="dist" depends="jar">
<copy todir="${bundle.dest}">
<path refid="absolute.deps"/>
<path refid="transient.deps"/>
</copy>
</target>
<!-- run all junit tests found in the test directory -->
<target name="test" depends="build" if="test.dir.exists">
<path id="test.classpath">
<path refid="absolute.deps"/>
<path refid="transient.deps"/>
<path refid="test.deps"/>
<pathelement location="resources"/>
<pathelement location="build"/>
<pathelement location="test"/>
<pathelement location="test-data"/>
</path>
<javac srcdir="test" debug="true"
includes="**"
destdir="build"
source="${ant.build.javac.source}">
<classpath refid="test.classpath"/>
</javac>
<junit printsummary="on" haltonfailure="false" fork="true">
<formatter type="xml" usefile="true"/>
<classpath refid="test.classpath"/>
<batchtest>
<fileset dir="test">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="checkstyle">
<taskdef resource="checkstyletask.properties"
classpath="../org.bridgedb.bio/build-lib/checkstyle-all-5.0.jar"/>
<checkstyle config="checks.xml">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<formatter toFile="${checkstyle.output.file}"/>
</checkstyle>
</target>
</project>