root/trunk/calendar3/bldfiles/buildjar.xml

Revision 2 (checked in by douglm, 7 years ago)

Initial import of bedework

Line 
1 <!-- This file builds a single jar file. It just sets defaults for the java
2      compiler then invokes it.
3
4      This is the only place we compile files.
5
6      On entry we require:
7        build.jar.file        Fully specified name of destination jar file.
8        base.name             Defines the name of the source base.
9        base.java.sources     Defines the java source files
10        base.class.patternset Defines the java class files
11        base.resource.files   Defines extra resources to go in the jar
12
13      We will copy all files defined by base.java.patternset to a temporary
14      location and compile out of that into a temporary classes location.
15
16      We do that to avoid a problematic feature of the java compilers, the
17      tendency to recompile any referenced sources found on the source path.
18
19      So, if we have all our sources under the directory "src" and compile a
20      single package in that tree, all referenced classes will be compiled,
21      even if they exist in a jar file on the class path.
22
23      The other side-effect is that we might compile and include classes we
24      didn't realise we were compiling.
25
26      The downside is that we need to be very specific about the classes we
27      compile for a package and we might need to put classes in
28      base.java.sources which we don't want in the final jar file.
29
30      On exit we will have created classes in the directory
31         ${jar.temp.classes}
32      and a jar file
33         ${build.jar.file}
34
35      Authors: Mike Douglass   douglm@rpi.edu
36 -->
37
38 <project name="buildjar" default="build" >
39   <target name="init">
40     <!--  =================== Compilation Control Options ===============
41       These properties control option settings on the Javac compiler when it
42       is invoked using the <javac> task.
43
44       compile.debug        Should compilation include the debug option?
45       compile.deprecation  Should compilation include the deprecation option?
46       compile.optimize     Should compilation include the optimize option?
47
48       Below are the defaults. They may already be set in the build properties.
49     -->
50
51     <property name="compile.debug" value="true"/>
52     <property name="compile.deprecation" value="false"/>
53     <property name="compile.optimize" value="true"/>
54     <property name="compile.verbose" value="false"/>
55     <property name="compile.listfiles" value="false"/>
56
57     <property name="jar.dest.dir"
58              location="${org.bedework.temp.jartemp.dir}/${base.name}" />
59     <delete dir="${jar.dest.dir}" />
60     <mkdir dir="${jar.dest.dir}" />
61
62     <property name="jar.temp.sources"
63              location="${jar.dest.dir}/source" />
64     <property name="jar.temp.classes"
65              location="${jar.dest.dir}/classes" />
66   </target>
67
68   <target name="build" depends="init"
69           description="Compile calendar Java sources">
70     <!-- ==============================================================
71           See if the jar is up to date. We recompile if any of the
72           source files or metainf files are newer. We also recompile if
73           any jars on the package classpath are newer.
74          ============================================================== -->
75
76     <uptodate property="build.jar.uptodate"
77               targetfile="${build.jar.file}" >
78       <srcfiles refid="base.java.sources" />
79       <srcfiles refid="base.resource.files"/>
80       <!-- change this to a fileset
81       <srcfiles refid="compile.classpath" />
82       -->
83     </uptodate>
84
85     <antcall target="do.build.uptodate" inheritRefs="true" />
86     <antcall target="do.build.notuptodate" inheritRefs="true" />
87   </target>
88
89   <target name="do.build.notuptodate"
90           if="build.jar.uptodate">
91     <echo message="**** ${build.jar.file} is up to date" />
92   </target>
93
94   <target name="do.build.uptodate"
95           unless="build.jar.uptodate">
96     <echo message="**** ${build.jar.file} needs rebuilding" />
97
98     <!-- Delete jar file -->
99     <delete file="${build.jar.file}"/>
100
101     <dirname property="build.jar.dir" file="${build.jar.file}"/>
102
103     <mkdir dir="${build.jar.dir}" />
104
105     <!-- ==============================================================
106                       Build the classes
107          ============================================================== -->
108
109     <!-- First copy the sources we are going to compile into a temp
110          directory. -->
111     <mkdir dir="${jar.temp.sources}" />
112     <copy toDir="${jar.temp.sources}">
113       <fileset refid="base.java.sources" />
114       <fileset refid="base.resource.files"/>
115     </copy>
116
117     <mkdir dir="${jar.temp.classes}"/>
118     <echo message="About to build jar ${build.jar.file}"/>
119     <property name="cp" refid="compile.classpath" />
120     <echo message="***************cp: ${cp}"/>
121
122     <javac srcdir="${jar.temp.sources}"
123            destdir="${jar.temp.classes}"
124            debug="${compile.debug}"
125            verbose="${compile.verbose}"
126            listfiles="${compile.listfiles}"
127            deprecation="${compile.deprecation}"
128            optimize="${compile.optimize}">
129       <classpath refid="compile.classpath"/>
130       <include name="**/*.java"/>
131       <compilerarg value="-nowarn" compiler="jikes" />
132     </javac>
133
134     <!-- ==============================================================
135                       Build jar file
136          ============================================================== -->
137
138     <jar jarfile="${build.jar.file}">
139       <fileset dir="${jar.temp.classes}">
140         <patternset refid="base.class.patternset"/>
141       </fileset>
142       <fileset refid="base.resource.files"/>
143     </jar>
144   </target>
145 </project>
Note: See TracBrowser for help on using the browser.