-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
172 lines (147 loc) · 7.14 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
<?xml version="1.0" encoding="UTF-8"?>
<project default="all" name="webstart">
<description>eXist-db client packed in a XAR</description>
<!-- import default properties from file -->
<property file="local.build.properties"/>
<property file="build.properties"/>
<!-- import properties from eXist-db -->
<property file="${exist.home}/build.properties"/>
<!-- Load ant contrib from exist-home -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${exist.home}/tools/ant/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- derive properties from expath-pkg.xml -->
<xmlproperty file="expath-pkg.xml.tmpl"/>
<property name="xar.version" value="${package(version)}"/>
<property name="xar.app" value="${package(abbrev)}"/>
<property name="build.dir" value="build"/>
<!-- flag to prevent regeneration of keystore -->
<available file="${keystore.file}" property="keystore.present"/>
<target name="all" depends="keygen,prepare,repack,sign,pack,clean,xar" description="Generate signed JAR files"/>
<target name="sign" description="Sign JAR files">
<echo message="Signing libs in '${work.dir}'"/>
<signjar tsaurl="${tsa.url}" alias="${keystore.alias}" keystore="${keystore.file}"
storepass="${keystore.password}" lazy="true" storetype="${keystore.type}">
<path>
<fileset dir="${work.dir}" includes="*.jar"/>
</path>
</signjar>
</target>
<target name="repack" description="Repack JAR files">
<echo message="Repacking libs in '${work.dir}'"/>
<apply executable="pack200" parallel="false">
<arg value="--repack"/>
<arg value="--segment-limit=-1"/>
<arg value="--no-keep-file-order"/>
<arg value="--strip-debug"/>
<fileset dir="${work.dir}" includes="*.jar"/>
</apply>
</target>
<target name="keygen" description="Generate (dummy) keystore file" unless="keystore.present">
<echo message="Generating keystore file '${keystore.file}'"/>
<genkey alias="${keystore.alias}" storepass="${keystore.password}" keystore="${keystore.file}" verbose="false"
storetype="${keystore.type}" validity="10000">
<dname>
<param name="CN" value="eXist-db java client"/>
<param name="OU" value="eXist-db"/>
<param name="O" value="eXist-db.org"/>
<param name="C" value="NL"/>
</dname>
</genkey>
</target>
<target name="pack" description="Pack JAR files">
<echo message="Pack200'ing jar files in '${work.dir}'"/>
<apply executable="pack200" parallel="false" dest="${work.dir}">
<arg value="--modification-time=latest"/>
<arg value="--deflate-hint=true"/>
<arg value="--segment-limit=-1"/>
<arg value="--effort=9"/>
<targetfile/>
<srcfile/>
<fileset dir="${work.dir}" includes="**/*.jar"/>
<mapper type="glob" from="*" to="*.pack.gz"/>
</apply>
</target>
<target name="clean-all" description="Cleanup all files">
<delete dir="${work.dir}" failonerror="false"/>
<delete dir="${build.dir}" failonerror="false"/>
<!--<delete file="${keystore.file}" failonerror="false"/>-->
<delete file="expath-pkg.xml" failonerror="false"/>
</target>
<target name="clean" description="Cleanup jar and xar files">
<delete failonerror="false">
<fileset dir="${work.dir}" includes="*.jar"/>
<fileset dir="${build.dir}" includes="*.xar"/>
</delete>
</target>
<target name="prepare" description="Prepare">
<mkdir dir="${work.dir}"/>
<!-- copy and rename exist.jar to include version number -->
<copy file="${exist.home}/exist.jar" tofile="${work.dir}/exist-${project.version}.jar" overwrite="true"/>
<!-- copy all required JAR files from exist, note that only a subset of JAR files is required -->
<copy todir="${work.dir}" overwrite="true">
<fileset dir="${exist.home}/lib/core">
<include name="commons-io-*.jar"/>
<include name="commons-pool-*.jar"/>
<include name="j8fu-*.jar"/>
<include name="jargo-*.jar"/>
<include name="jline-*.jar"/>
<include name="log4j-api-*.jar"/>
<include name="log4j-core-*.jar"/>
<!--<include name="log4j-jul-*.jar"/>-->
<!-- log4j-slf4j-impl-2.9.0.jar -->
<include name="rsyntaxtextarea-*.jar"/>
<include name="ws-commons-util-*.jar"/>
<include name="xmldb*.jar"/>
<include name="xmlrpc-client-*.jar"/>
<include name="xmlrpc-common-*.jar"/>
</fileset>
</copy>
<!-- parse expath-pkg.xml template to include exist-db version -->
<copy file="expath-pkg.xml.tmpl" tofile="expath-pkg.xml" overwrite="true">
<filterchain>
<tokenfilter>
<replacestring from="EXIST_VERSION" to="${project.version}"/>
</tokenfilter>
</filterchain>
</copy>
<!-- store existdb version inside XAR file -->
<echoxml file="exist-config.xml">
<exist>
<version>${project.version}</version>
</exist>
</echoxml>
<!-- create jar file that includes log4j2 configuration -->
<jar destfile="${work.dir}/log4j-configuration.jar" basedir="src" includes="*.xml"/>
<!-- iterate over all jar files and add attirbutes to manifest file -->
<!-- https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/manifest.html -->
<for param="jarFile">
<path>
<fileset dir="${work.dir}">
<include name="*.jar"/>
</fileset>
</path>
<sequential>
<jar update="true" file="@{jarFile}">
<manifest>
<!-- allow the application to run anywhere
https://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/deployingWithoutCodebase.html -->
<attribute name="Codebase" value="*"/>
<!-- the appliction needs to be able to access localfiles, so 'sandbox' is not sufficient -->
<attribute name="Permissions" value="all-permissions"/>
<!-- this name is visible in the security window -->
<attribute name="Application-Name" value="eXist Native XML Database Client"/>
</manifest>
</jar>
</sequential>
</for>
</target>
<target name="xar" description="Build XAR file">
<echo message="Build XAR file in '${build.dir}'"/>
<mkdir dir="${build.dir}"/>
<zip basedir="." destfile="${build.dir}/${xar.app}-${project.version}.xar"
excludes="${build.dir}/*,.idea/*,${keystore.file},.exist*"/>
</target>
</project>