This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
246 lines (208 loc) · 8.87 KB
/
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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?xml version="1.0" ?>
<!--
Copyright (c) 2013 Cyso < development [at] cyso . nl >
This file is part of vcloud-client.
vcloud-client is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
vcloud-client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with vcloud-client. If not, see <http://www.gnu.org/licenses/>.
-->
<project name="vcloud-client" basedir="." default="dist">
<!-- Set up properties containing important project directories -->
<property name="source.root" value="src"/>
<property name="class.root" value="classes"/>
<property name="bin.dir" value="bin"/>
<property name="dist.dir" value="dist"/>
<property name="libs.dir" value="lib"/>
<property name="docs.dir" value="doc"/>
<property name="root.package" value="nl.cyso.vcloud.client"/>
<property name="entry.point" value="Entry"/>
<property name="executable" value="vcloud-client"/>
<property name="debian.dir" value="debian"/>
<property name="debian.bin.dir" value="usr/share/${executable}"/>
<property name="debian.lib.dir" value="${debian.bin.dir}/lib"/>
<available file=".git" property="git.present"/>
<path id="libraries">
<pathelement location="${class.root}"/>
<fileset dir="${libs.dir}">
<include name="*.jar"/>
<exclude name="*-javadoc.jar"/>
<exclude name="*-sources.jar"/>
</fileset>
</path>
<path id="dist_libraries">
<fileset dir="${libs.dir}">
<include name="*.jar"/>
<exclude name="*-javadoc.jar"/>
<exclude name="*-sources.jar"/>
</fileset>
</path>
<pathconvert property="project.class.path" pathsep=":">
<path refid="libraries"/>
<map from="${basedir}" to="."/>
</pathconvert>
<pathconvert property="jar.class.path" pathsep=" ">
<path refid="dist_libraries"/>
<map from="${basedir}" to="."/>
</pathconvert>
<pathconvert property="debian.class.path" pathsep=" ">
<path refid="dist_libraries"/>
<map from="${basedir}" to="/${debian.bin.dir}"/>
</pathconvert>
<pathconvert property="debian.pkg.jars" pathsep="${line.separator}">
<path refid="dist_libraries"/>
<mapper type="flatten"/>
<map from="${basedir}" to=""/>
</pathconvert>
<pathconvert property="debian.pkg.jars.dest" pathsep="${line.separator}">
<path refid="dist_libraries"/>
<map from="${basedir}/${libs.dir}" to="${debian.lib.dir}"/>
</pathconvert>
<target name="print-classpath" description="Show the dependency class path">
<property name="relpath" value="${project.class.path}" relative="yes" basedir="${basedir}"/>
<echo>${relpath}</echo>
</target>
<!-- Create our runtime subdirectories and copy resources into them -->
<target name="prepare" depends="git-revision" description="Sets up build structures">
<delete dir="${class.root}"/>
<mkdir dir="${class.root}"/>
<!-- Copy our property files and O/R mappings for use at runtime -->
<copy todir="${class.root}" >
<fileset dir="${source.root}" >
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<target name="clean" description="Remove all generated files">
<delete dir="${class.root}" />
<delete dir="${dist.dir}" />
<delete dir="${bin.dir}" />
<delete file="${executable}" />
<delete file="${executable}-debug" />
<delete>
<fileset dir="${basedir}">
<include name="${executable}-*.tar.bz2" />
<include name="*.config" />
</fileset>
<fileset dir="${basedir}/debian">
<include name="${executable}.*" />
</fileset>
</delete>
<delete dir="${debian.dir}/${executable}" />
</target>
<!-- Compile the java source of the project -->
<target name="compile" depends="prepare" description="Compiles all Java classes">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on"
includeantruntime="false"
classpath="${project.class.path}"
/>
</target>
<!-- Create an easy to use bash file -->
<target name="executable" depends="compile" description="Create an easy to use bash file">
<echo file="${executable}" append="false">#!/bin/sh
java -classpath ${project.class.path} ${root.package}.${entry.point} "$$@"</echo>
<echo file="${executable}-debug" append="false">#!/bin/sh
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y -classpath ${project.class.path} ${root.package}.${entry.point} "$$@"</echo>
<chmod file="${executable}" perm="a+x"/>
<chmod file="${executable}-debug" perm="a+x"/>
</target>
<target name="git-revision" description="Store git revision in ${version}" if="git.present">
<exec executable="git" outputproperty="version" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
<condition property="version" value="${version}" else="unknown">
<and>
<isset property="version"/>
<length string="${version}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>${executable} BUILD_VERSION is ${version}</echo>
</target>
<!-- Create a clean dist directory -->
<target name="dist" depends="executable,man-page,readme" description="Create a clean dist directory">
<delete dir="${dist.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/${docs.dir}"/>
<mkdir dir="${dist.dir}/${libs.dir}"/>
<copy file="${docs.dir}/configuration.example" tofile="${dist.dir}/${executable}.config.example"/>
<copy todir="${dist.dir}/${libs.dir}">
<fileset dir="${libs.dir}">
<include name="*.jar"/>
<exclude name="*-javadoc.jar"/>
<exclude name="*-sources.jar"/>
</fileset>
</copy>
<copy file="${docs.dir}/${executable}.1" tofile="${dist.dir}/${docs.dir}/${executable}.1" />
<copy file="README.md" tofile="${dist.dir}/README.md" />
<mkdir dir="${class.root}/META-INF" />
<copy file="LICENSE" tofile="${class.root}/META-INF/LICENSE" />
<jar destfile="${dist.dir}/${executable}.jar" basedir="${class.root}">
<manifest>
<attribute name="Implementation-Vendor" value="Cyso BV."/>
<attribute name="Implementation-Title" value="${executable}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Sealed" value="false"/>
<attribute name="Class-Path" value="${jar.class.path}"/>
<attribute name="Main-Class" value="${root.package}.${entry.point}"/>
</manifest>
</jar>
<delete dir="${class.root}/META-INF" />
<echo file="${dist.dir}/${executable}" append="false">#!/bin/sh
if [ -L "$0" ]; then
CMD="$(readlink -f "$0")"
else
CMD="$0"
fi
DIR="$( cd "$( dirname "$CMD" )" && pwd )"
java -jar $DIR/${executable}.jar ${root.package}.${entry.point} "$$@"</echo>
<chmod file="${dist.dir}/${executable}" perm="a+x"/>
</target>
<target name="package-debian" depends="git-revision,dist" description="Prepare project for Debian packaging">
<echo file="debian/${executable}.install" append="false">dist/${executable}.jar ${debian.bin.dir}
dist/${executable} ${debian.bin.dir}
</echo>
<echo file="debian/jars" append="false">${debian.pkg.jars}</echo>
<exec executable="sed" output="debian/${executable}.install" append="true">
<arg value="s#^#${libs.dir}/#;s#$$# ${debian.lib.dir}#" />
<arg value="${debian.dir}/jars" />
</exec>
<delete file="debian/jars" />
<echo file="debian/${executable}.manpages" append="false">${docs.dir}/${executable}.1</echo>
<copy file="README.md" tofile="debian/${executable}.README.Debian" />
</target>
<target name="bump-version" depends="git-revision" description="Bump the BUILD_VERSION version number">
<replaceregexp file="${source.root}/nl/cyso/vcloud/client/Version.java">
<regexp pattern="BUILD_VERSION = ".*";"/>
<substitution expression="BUILD_VERSION = "${version}";"/>
</replaceregexp>
</target>
<target name="man-page" depends="compile" description="Generate man page">
<java classpath="${project.class.path}" classname="nl.cyso.vcloud.client.docs.ManPage" output="${docs.dir}/${executable}.1" />
</target>
<target name="readme" depends="compile" description="Generate README">
<java classpath="${project.class.path}" classname="nl.cyso.vcloud.client.docs.Readme" output="README.md" />
</target>
<target name="package-tar" depends="dist" description="Create tarball from dist">
<move file="${dist.dir}" tofile="${executable}-${version}" />
<tar destfile="${executable}-${version}.tar.bz2" compression="bzip2">
<tarfileset dir="." preserveleadingslashes="false">
<include name="${executable}-${version}/**" />
</tarfileset>
</tar>
<move tofile="${dist.dir}" file="${executable}-${version}" />
</target>
</project>