blob: 0a4470d48345860f4c23af2fef3700012b321ca1 (
plain)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
<!--
-
- Copyright (c) 2006 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-->
<project name="module">
<import file="common.xml"/>
<map property="module" value="${basedir}">
<globmapper from="${project.root}${file.separator}*" to="*"/>
</map>
<property name="module.dir" value="${build.dir}/${module}"/>
<property name="module.classes" value="${module.dir}/${classes.dir}"/>
<property name="module.precompiled" value="${module.dir}/${src.dir}"/>
<map property="module.name" value="${module}">
<filtermapper>
<replacestring from="${file.separator}" to="-"/>
</filtermapper>
</map>
<property name="module.jar" location="${module.dir}/${module.name}.jar"/>
<property name="module.launcher"
location="${module.dir}/${module.name}${launcher.sfx}"/>
<property name="module.manifest"
location="${module.dir}/${module.name}.mf"/>
<property name="module.doc" location="${module.dir}/${doc.dir}"/>
<property name="module.src" location="${src.dir}"/>
<property name="module.lib" location="${lib.dir}"/>
<property name="module.etc" location="${etc.dir}"/>
<!-- module.depends is supplied by the importing file -->
<pathconvert property="module.depends.dirs" pathSep=" ">
<path>
<dirset dir="${project.root}" includes="${module.depends}"/>
</path>
<globmapper from="${project.root}${file.separator}*" to="*"/>
</pathconvert>
<map property="module.depends.names" value="${module.depends.dirs}">
<filtermapper>
<replacestring from="${file.separator}" to="-"/>
</filtermapper>
</map>
<map property="module.depends.libs" value="${module.depends.dirs}"
setonempty="false">
<regexpmapper from="(.*)" to="\1/${lib.dir}/\*\*\/*\.jar" handledirsep="/"/>
</map>
<map property="module.depends.classes" value="${module.depends.dirs}" join=":">
<globmapper from="*" to="${build.dir}/*/${classes.dir}"/>
</map>
<path id="module.src.path">
<pathelement location="${module.src}"/>
<pathelement location="${module.precompiled}"/>
</path>
<path id="module.class.path">
<pathelement location="${module.classes}"/>
<fileset dir="${module.lib}" includes="**/*.jar"/>
<pathelement path="${module.depends.classes}"/>
<fileset dir="${project.root}" includes="${module.depends.libs}"/>
</path>
<pathconvert property="module.manifest.jars" pathsep=" " dirsep="/">
<path>
<fileset dir="${module.lib}" includes="**/*.jar"/>
</path>
<globmapper from="${module.lib}${file.separator}*" to="*"/>
</pathconvert>
<map property="module.manifest.deps" value="${module.depends.dirs}">
<globmapper from="*" to="*${launcher.sfx}"/>
</map>
<property name="module.manifest.classpath"
value="${module.name}.jar ${module.manifest.jars} ${module.manifest.deps}"/>
<target name="debug">
<echo message="basedir = ${basedir}"/>
<echo message = "project.root = ${project.root}"/>
<echo message = "module = ${module}"/>
<echo message = "module.name = ${module.name}"/>
<echo message = "module.jar = ${module.jar}"/>
<echo message = "module.depends = ${module.depends}"/>
<echo message = "module.depends.libs = ${module.depends.libs}"/>
<echo message = "module.depends.dirs = ${module.depends.dirs}"/>
<echo message = "module.depends.classes = ${module.depends.classes}"/>
<pathconvert property="module.class.path" refid="module.class.path"/>
<echo message = "module.class.path = ${module.class.path}"/>
<pathconvert property="pretty.module.class.path"
refid="module.class.path"
pathsep="${line.separator}| |-- "/>
<echo message = "pretty.module.class.path = ${pretty.module.class.path}"/>
<pathconvert property="module.src.path" refid="module.src.path"/>
<echo message= "module.src.path = ${module.src.path}"/>
<pathconvert property="pretty.module.src.path"
refid="module.src.path"
pathsep="${line.separator}| |-- "/>
<echo message = "pretty.module.src.path = ${pretty.module.src.path}"/>
</target>
<target name="prepare">
<mkdir dir="${module.classes}"/>
<mkdir dir="${module.precompiled}"/>
<mkdir dir="${module.doc}"/>
</target>
<target name="precompile"/>
<target name="compile" depends="prepare,precompile">
<javac destdir="${module.classes}" target="${java.target}"
source="${java.source}" debug="on">
<src refid="module.src.path"/>
<classpath refid="module.class.path"/>
</javac>
<!-- copy any non java src files into the build tree, e.g. log4j.properties -->
<copy todir="${module.classes}" verbose="true">
<fileset dir="${module.src}">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</copy>
</target>
<target name="dist-bin">
<mkdir dir="${destdir}"/>
<copy todir="${destdir}" failonerror="false">
<fileset dir="${src.bin}"/>
</copy>
<chmod dir="${destdir}" perm="ugo+rx" includes="**/*"/>
</target>
<target name="build" depends="compile">
<antcall target="dist-bin">
<param name="destdir" value="${build.dir}/${bin.dir}"/>
</antcall>
<copy todir="${build.dir}/${etc.dir}" failonerror="false">
<fileset dir="${module.etc}" excludes="**/*.conf"/>
</copy>
<copy todir="${build.dir}/${etc.dir}" failonerror="false">
<fileset dir="${build.dir}/${etc.dir}" includes="**/*.dev"/>
<mapper>
<globmapper from="*.dev" to="*"/>
</mapper>
</copy>
</target>
<target name="test"/>
<uptodate property="doc.done" targetfile="${module.doc}/index.html">
<srcfiles dir="${module.src}" includes="**/*.java"/>
</uptodate>
<target name="doc" depends="prepare" unless="doc.done">
<javadoc destdir="${module.doc}" sourcepathref="module.src.path"
classpathref="module.class.path" packagenames="*"/>
</target>
<target name="jar" depends="build">
<jar destfile="${module.jar}" basedir="${module.classes}"/>
</target>
<target name="manifest-main" if="module.main">
<manifest file="${module.manifest}">
<attribute name="Main-Class" value="${module.main}"/>
<attribute name="Class-Path" value="${module.manifest.classpath}"/>
</manifest>
</target>
<target name="manifest-lib" unless="module.main">
<manifest file="${module.manifest}">
<attribute name="Class-Path" value="${module.manifest.classpath}"/>
</manifest>
</target>
<target name="launcher" depends="manifest-main,manifest-lib">
<jar destfile="${module.launcher}" manifest="${module.manifest}"/>
</target>
<condition property="module.nodist">
<and>
<isset property="module.dist"/>
<isfalse value="${module.dist}"/>
</and>
</condition>
<target name="dist-lib" depends="jar,launcher,doc" unless="module.nodist">
<copy todir="${dist.lib}" file="${module.jar}"/>
<copy todir="${dist.lib}" file="${module.launcher}"/>
<copy todir="${dist.lib}" failonerror="false">
<fileset dir="${module.lib}"/>
</copy>
<copy todir="${dist.doc}/${module}">
<fileset dir="${module.doc}"/>
</copy>
</target>
<target name="dist" depends="dist-lib" unless="module.nodist">
<antcall target="dist-bin">
<param name="destdir" value="${dist.bin}"/>
</antcall>
<copy todir="${dist.etc}" failonerror="false">
<fileset dir="${module.etc}" excludes="**/*.dev"/>
</copy>
</target>
<target name="clean">
<delete dir="${module.dir}"/>
</target>
</project>
|