-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjava-build.xml
141 lines (115 loc) · 4.55 KB
/
java-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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
Sep 24, 2009 7:34:03 PM
java-build
Java build routines for all projects
====================================================================== -->
<project name="java-build" default="help">
<description>
Common build routines for all java projects
</description>
<!-- Always import the common build file -->
<import file="common-build.xml" />
<property name="src.dir" value="${basedir}/src/main" />
<property name="src.java.dir" value="${src.dir}/java" />
<!-- We want to always ensure that the java directory exists -->
<sequential>
<mkdir dir="${src.java.dir}" />
</sequential>
<property name="src.config.dir" value="${src.dir}/config" />
<property name="build.dir" value="${basedir}/build" />
<property name="dist.dir" value="${basedir}/dist" />
<property name="doc.dir" value="${build.dir}/doc" />
<property name="taglibdoc.dir" value="${doc.dir}/tagdoc" />
<!-- now for the library paths -->
<property name="lib.dir" value="${src.dir}/lib" />
<property name="util.lib.dir" value="${basedir}/src/util/lib" />
<property name="build.classes.dir" value="${build.dir}/classes"/>
<path id="compile.webapp.classpath">
<path refid="compile.classpath" />
</path>
<path id="compile.classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${test.lib.dir}/" includes="*.jar"/>
<fileset dir="${util.lib.dir}" includes="*.jar"/>
</path>
<fileset dir="${build.classes.dir}" id="jar.fileset.classes">
<include name="**/*.class"/>
<include name="**/*.properties"/>
<include name="**/*.templar"/>
</fileset>
<!-- include all of the extraneous files that are needed -->
<fileset dir="${src.java.dir}" id="jar.fileset.other">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
<!--
Compile all of the java source code
-->
<target name="compile" depends="clean,init" description="[java-build] Compile all of the source code">
<echo message="Compiling with Java classpath" />
<javac srcdir="${basedir}/src/main/java" destdir="${basedir}/build/classes" debug="on" classpathref="compile.classpath" includeantruntime="false" compiler="javac1.6" source="1.6" target="1.6" />
<copy todir="${basedir}/build/classes">
<fileset dir="${src.java.dir}">
<include name="**/*.properties" />
<include name="**/*.templar" />
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="[java-build] Jar the compiled files">
<jar destfile="${dist.dir}/${ant.project.name}.jar">
<!-- include the compiled files -->
<fileset refid="jar.fileset.classes" />
<fileset refid="jar.fileset.other" />
</jar>
</target>
<target name="jar-executable" depends="compile" description="[java-build] Jar the compiled files into an executable artifact.">
<fail unless="manifest.file" message="The property $${manifest.file} is required" />
<jar destfile="${dist.dir}/${ant.project.name}.jar" manifest="${manifest.file}">
<!-- include the compiled files -->
<fileset refid="jar.fileset.classes" />
<fileset refid="jar.fileset.other" />
</jar>
</target>
<target name="dist" depends="clean,jar" description="[java-build] Build the distributables" />
<!--
Create the directories that are needed
-->
<target name="init">
<!-- Create the output directories -->
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${dist.dir}" />
<!-- Create the library directories -->
<mkdir dir="${lib.dir}" />
<mkdir dir="${util.lib.dir}" />
<mkdir dir="${test.lib.dir}" />
</target>
<target name="init-project" description="[java-build] Create a new project" >
<!-- create the src directories -->
<mkdir dir="${src.java.dir}" />
<mkdir dir="${test.java.dir}" />
<!-- create the library directories -->
<mkdir dir="${lib.dir}" />
<mkdir dir="${test.lib.dir}" />
</target>
<!--
Clean up the build and distribution directories
-->
<target name="clean" description="[java-build] Clean the project by deleting all output directories">
<delete dir="${build.dir}" failonerror="false"/>
<delete dir="${dist.dir}" failonerror="false"/>
</target>
<!--
Create the source distribution
-->
<target name="dist-src" depends="init" description="[java-build] Create the source distribution">
<zip destfile="${dist.dir}/${ant.project.name}-src.zip">
<zipfileset dir=".">
<include name="src/**/*.*" />
<include name="build.xml" />
<include name="LICENCE.txt" />
</zipfileset>
</zip>
</target>
</project>