forked from apache/incubator-retired-edgent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-build.xml
212 lines (184 loc) · 8.22 KB
/
common-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
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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="quarks.common"
xmlns:jacoco="antlib:org.jacoco.ant"
>
<description>
Common tasks.
</description>
<!-- Assumption is that build files are two levels deep -->
<property name="quarks.dir" location="${basedir}/../.."/>
<property name="quarks.tools" location="${quarks.dir}/tools"/>
<property name="target.dir" location="${quarks.dir}/target"/>
<property name="quarks.ext" location="${quarks.dir}/ext"/>
<!-- Project specific extension jars -->
<property name="project.ext" location="${basedir}/ext"/>
<property name="target.java8.dir" location="${target.dir}/java8"/>
<property name="target.java8.ext" location="${target.java8.dir}/ext"/>
<property name="quarks.lib" location="${target.java8.dir}/lib"/>
<!-- default to quarks lib -->
<condition property="lib"
value="${target.java8.dir}/${component.path}/lib"
else="${quarks.lib}">
<isset property="component.path"/>
</condition>
<condition property="component.ext"
value="${target.java8.dir}/${component.path}/ext">
<isset property="component.path"/>
</condition>
<property name="quarks.analytics" location="${target.java8.dir}/analytics"/>
<property name="quarks.apps" location="${target.java8.dir}/apps"/>
<property name="quarks.connectors" location="${target.java8.dir}/connectors"/>
<property name="quarks.console" location="${target.java8.dir}/console"/>
<property name="quarks.utils" location="${target.java8.dir}/utils"/>
<property name="quarks.samples" location="${target.java8.dir}/samples"/>
<property name="src" location="src/main/java"/>
<property name="resources" location="src/main/resources"/>
<property name="classes" location="classes"/>
<property name="jarname" value="${ant.project.name}.jar"/>
<property name="jar" location="${lib}/${jarname}"/>
<property name="test.src" location="src/test/java"/>
<property name="test.classes" location="test.classes"/>
<property name="test.dir" location="unittests"/>
<!-- compile.classpath ref is used by default for compilation
and manifest class path generation.
When the full compile needs external jars that should
not be in the manifest compile.classpath should just
include local jars and a new reference id should be used
that includes compile.classpath and the external jars.
The property full.compile.classpath.id is set
to the name of the reference (see android examples).
-->
<property name="full.compile.classpath.id" value="compile.classpath"/>
<!-- Core Quarks ext class path -->
<path id="quarks.ext.classpath">
<pathelement location="${target.java8.ext}/google-gson-2.2.4/gson-2.2.4.jar" />
<pathelement location="${target.java8.ext}/slf4j-1.7.12/slf4j-api-1.7.12.jar"/>
<pathelement location="${target.java8.ext}/metrics-3.1.2/metrics-core-3.1.2.jar"/>
</path>
<!-- Quarks samples common class path -->
<path id="quarks.samples.classpath">
<pathelement location="${quarks.lib}/quarks.providers.development.jar"/>
<pathelement location="${quarks.lib}/quarks.providers.direct.jar"/>
<pathelement location="${target.java8.ext}/slf4j-1.7.12/slf4j-jdk14-1.7.12.jar"/>
</path>
<!-- Quarks unit tests common class path -->
<path id="test.common.classpath">
<pathelement location="${target.java8.ext}/slf4j-1.7.12/slf4j-jdk14-1.7.12.jar"/>
</path>
<!-- expects a property of component.path e.g. connectors/iotf -->
<!-- only called by non-core components -->
<macrodef name="setup.component">
<sequential>
<property name="component.target" location="${target.java8.dir}/${component.path}"/>
<property name="component.lib" location="${component.target}/lib"/>
<!-- <property name="component.ext" location="${component.target}/ext"/> -->
<mkdir dir="${component.lib}"/>
<mkdir dir="${component.ext}"/>
<copy todir="${component.ext}" includeEmptyDirs="no" failonerror="false" quiet="true">
<fileset dir="${project.ext}"/>
</copy>
</sequential>
</macrodef>
<target name="project.component" if="component.path">
<setup.component/>
</target>
<macrodef name="quarks.compile">
<sequential>
<javac debug="true" includeantruntime="no"
srcdir="${src}"
destdir="${classes}"
classpathref="${full.compile.classpath.id}"/>
</sequential>
</macrodef>
<target name="all" depends="jar,test.compile"/>
<target name="init">
<mkdir dir="${src}"/>
<mkdir dir="${test.src}"/>
<mkdir dir="${classes}"/>
<mkdir dir="${resources}"/>
<mkdir dir="${test.classes}"/>
<mkdir dir="${target.java8.dir}"/>
<mkdir dir="${target.java8.ext}"/>
<mkdir dir="${quarks.lib}"/>
<copy todir="${target.java8.ext}">
<fileset dir="${quarks.ext}"/>
</copy>
</target>
<target name="clean" >
<delete dir="${classes}"/>
<delete dir="${test.classes}"/>
<delete dir="${test.dir}"/>
<delete file="${jar}"/>
</target>
<target name="compile" depends="init,project.component">
<quarks.compile/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${classes}/META-INF"/>
<copy file="${quarks.dir}/LICENSE" tofile="${classes}/META-INF/LICENSE"/>
<copy file="${quarks.dir}/NOTICE" tofile="${classes}/META-INF/NOTICE"/>
<manifestclasspath property="jar.classpath" jarfile="${jar}"
maxParentLevels="5">
<classpath refid="compile.classpath"/>
</manifestclasspath>
<jar destfile="${jar}">
<manifest>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${commithash}-${DSTAMP}-${TSTAMP}"/>
<attribute name="Implementation-Vendor" value="[email protected]"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
<fileset dir="${classes}"/>
<fileset dir="${resources}"/>
</jar>
</target>
<target name="test.compile" depends="jar">
<javac debug="true" includeantruntime="yes"
srcdir="${test.src}"
destdir="${test.classes}"
classpathref="test.compile.classpath"/>
</target>
<!-- Allow the pattern of tests to run be set
ant -Dtest.base.pattern='**/*TestManual.java test'
-->
<property name="test.base.pattern" value="**/*Test.java"/>
<target name="test" depends="test.compile,test.run"/>
<target name="test.run">
<mkdir dir="${test.dir}"/>
<tempfile property="test.run.dir" prefix="testrun" destDir="${test.dir}"/>
<mkdir dir="${test.run.dir}"/>
<jacoco:coverage enabled="yes" destfile="${test.run.dir}/jacoco.exec">
<junit fork="yes" dir="${test.run.dir}" printsummary="yes" showoutput="no"
haltonfailure="yes">
<classpath>
<path refid="test.classpath"/>
</classpath>
<sysproperty key="quarks.build.ci" value="${quarks.build.ci}"/>
<assertions><enable/></assertions>
<formatter type="xml"/>
<!-- Only use the brief formatter for a continuous integration build" -->
<formatter type="brief" usefile="no" if="quarks.build.ci"/>
<batchtest todir="${test.run.dir}">
<fileset dir="${test.src}">
<include name="${test.base.pattern}"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
</project>