forked from open-eid/digidoc4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
260 lines (229 loc) · 9.82 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:jacoco="antlib:org.jacoco.ant" xmlns:ivy="antlib:org.apache.ivy.ant"
name="digidoc4j builder" basedir="."
default="base">
<property environment="env"/>
<property name="build.dir" value="build"/>
<property name="junit.dir" value="junit_report"/>
<property name="coverage.dir" value="coverage"/>
<property name="dist.dir" value="dist"/>
<property name="packaging.lib" value="packaging_jar"/>
<property name="ivy.install.version" value="2.1.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="publish.version" value="1.0" />
<property name="lib.version" value="${publish.version}"/>
<target name="version" unless="lib.version">
<exec executable="sh" outputproperty="lib.version">
<arg value="-c"/>
<arg value="git tag -l public* --sort=version:refname | tail -1 | awk -F '-' '{print $2}'"/>
<!--| awk -F '-' '{print $2}'""/>-->
</exec>
<echo>Version = ${lib.version}</echo>
</target>
<condition property="version.suffix" value=".${env.BUILD_NUMBER}-beta" else="">
<isset property="env.BUILD_NUMBER"/>
</condition>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="lib/jacocoant.jar"/>
</taskdef>
<path id="javac.classpath">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
<property name="classpath" value="javac.classpath"/>
<path id="run.classpath">
<pathelement location="${build.dir}"/>
</path>
<target name="javadoc">
<mkdir dir="javadoc"/>
<javadoc packagenames="org.digidoc4j" destdir="javadoc" encoding="UTF-8" overview="doc/overview.html"
classpathref="javac.classpath">
<packageset dir="src" defaultexcludes="yes">
<include name="org/digidoc4j"/>
<include name="org/digidoc4j/exceptions"/>
<include name="org/digidoc4j/signers"/>
</packageset>
</javadoc>
<jar destfile="${dist.dir}/digidoc4j-${lib.version}${version.suffix}-javadoc.jar" basedir="javadoc"/>
<mkdir dir="javadoc/doc-files"/>
<copy todir="javadoc/doc-files">
<fileset dir="doc/images"/>
</copy>
</target>
<target name="compile" depends="load.dependencies">
<mkdir dir="${build.dir}"/>
<copy todir="${build.dir}">
<fileset dir="resources"/>
</copy>
<javac destdir="${build.dir}" includeantruntime="false" source="1.7" debug="on" target="1.7" encoding="UTF-8">
<src path="src"/>
<src path="test"/>
<classpath refid="${classpath}"/>
</javac>
<jar destfile="${dist.dir}/digidoc4j-${lib.version}${version.suffix}.jar">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Vendor" value="Republic of Estonia Information System Authority"/>
<attribute name="Implementation-Title" value="Java BDoc/DigiDoc library"/>
<attribute name="Implementation-Version" value="${lib.version}"/>
</manifest>
<fileset dir="${build.dir}">
<exclude name="prototype/"/>
<exclude name="**/*Test.class"/>
</fileset>
<fileset dir=".">
<include name="conf/*.*"/>
</fileset>
</jar>
</target>
<target name="library" depends="init.ivy">
<ivy:retrieve transitive="false" conf="runtime" sync="true" pattern="${packaging.lib}/[artifact].[ext]"/>
<zip destfile="${dist.dir}/digidoc4j-library-${lib.version}${version.suffix}.zip">
<zipfileset dir="${packaging.lib}" includes="*.jar"/>
<zipfileset dir="lib" includes="**/dss*.jar **/jdigidoc*.jar"/>
</zip>
</target>
<target name="utility" depends="init.ivy">
<ivy:retrieve transitive="false" conf="runtime" sync="true" pattern="${packaging.lib}/[artifact].[ext]"/>
<mkdir dir="${build.dir}/util"/>
<jar jarfile="${build.dir}/util/temp.jar">
<zipgroupfileset dir="lib" includes="**/dss*.jar **/jdigidoc*.jar"/>
<zipgroupfileset dir="${packaging.lib}" includes="**/*.jar" excludes="bcprov-*.jar"/>
<zipgroupfileset dir="dist" includes="**/digidoc4j-*.jar" excludes="*-javadoc.jar *-sources.jar"/>
</jar>
<jar destfile="${build.dir}/util/digidoc4j-util.jar">
<zipfileset src="${build.dir}/util/temp.jar" excludes="META-INF/*.SF META-INF/*.RSA META-INF/*.DSA"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Vendor" value="Republic of Estonia Information System Authority"/>
<attribute name="Implementation-Title" value="Java BDoc/DigiDoc utility"/>
<attribute name="Implementation-Version" value="${lib.version}"/>
<attribute name="Main-Class" value="org.digidoc4j.main.DigiDoc4J"/>
<attribute name="Class-Path" value=". ./bcprov-jdk15on.jar"/>
</manifest>
</jar>
<delete file="${build.dir}/util/temp.jar"/>
<copy todir="${build.dir}/util">
<fileset dir="${packaging.lib}" includes="**/bcprov-*.jar"/>
<fileset dir="." includes="log4j.for.util.properties"/>
</copy>
<move file="${build.dir}/util/log4j.for.util.properties" tofile="${build.dir}/util/log4j.properties"/>
<zip destfile="${dist.dir}/digidoc4j-util-${lib.version}${version.suffix}.zip"
basedir="${build.dir}/util"/>
<delete dir="${build.dir}/util"/>
</target>
<target name="source">
<jar destfile="${dist.dir}/digidoc4j-sources-${lib.version}${version.suffix}.jar" basedir="src"/>
</target>
<target name="copy.dss.library">
<copy todir="lib">
<fileset dir="sd-dss/dss-common/target" includes="dss-common*.jar" excludes="*-sources.jar "/>
<fileset dir="sd-dss/dss-diagnostic-jaxb/target" includes="dss-diagnostic-jaxb*.jar" excludes="*-sources.jar "/>
<fileset dir="sd-dss/dss-document/target" includes="dss-document*.jar" excludes="*-sources.jar "/>
<fileset dir="sd-dss/dss-service/target" includes="dss-service*.jar" excludes="*-sources.jar "/>
<fileset dir="sd-dss/dss-spi/target" includes="dss-spi*.jar" excludes="*-sources.jar "/>
<fileset dir="sd-dss/dss-tsl-jaxb/target" includes="dss-tsl-jaxb*.jar" excludes="*-sources.jar "/>
</copy>
</target>
<target name="base" depends="version, clean, source, compile, utility, library"/>
<target name="make.utility" depends="version, clean, copy.dss.library, compile, utility"/>
<target name="all" depends="copy.dss.library, test, javadoc, coverage.report"/>
<target name="test" depends="base">
<mkdir dir="${junit.dir}"/>
<jacoco:coverage>
<junit fork="true">
<classpath refid="javac.classpath"/>
<classpath>
<pathelement location="build"/>
</classpath>
<classpath>
<pathelement location="test-tsl"/>
</classpath>
<classpath>
<pathelement location="testFiles"/>
</classpath>
<batchtest>
<fileset dir="${build.dir}" includes="**/*Test.class"/>
</batchtest>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
</junit>
</jacoco:coverage>
<junitreport todir="${junit.dir}">
<fileset dir=".">
<include name="TEST-*.xml"/>
</fileset>
<report format="noframes" todir="${junit.dir}/html"/>
</junitreport>
</target>
<target name="runtest">
<junit fork="true">
<classpath refid="javac.classpath"/>
<classpath>
<pathelement location="build"/>
</classpath>
<batchtest>
<fileset dir="${build.dir}" includes="**/*Test.class"/>
</batchtest>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
</junit>
</target>
<target name="coverage.report">
<jacoco:report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="DigiDoc4J">
<classfiles>
<fileset dir="${build.dir}">
<exclude name="**/*Test*"/>
<exclude name="eu/"/>
<exclude name="prototype/"/>
<exclude name="org/bouncycastle/"/>
<exclude name="org/digidoc4j/main/"/>
<exclude name="util/"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src"/>
</sourcefiles>
</structure>
<html destdir="${coverage.dir}"/>
</jacoco:report>
</target>
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="." includes="TEST*.xml"/>
<fileset dir="${build.dir}"/>
<fileset dir="${dist.dir}"/>
<fileset dir="javadoc"/>
</delete>
</target>
<target name="download.ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init.ivy" depends="download.ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="load.dependencies" depends="init.ivy" >
<ivy:retrieve transitive="false" conf="compile"/>
</target>
</project>