-
Notifications
You must be signed in to change notification settings - Fork 19
/
common.xml
230 lines (200 loc) · 9.4 KB
/
common.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
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="Ant - Common">
<dirname property="Ant - Common.dir" file="${ant.file.Ant - Common}"/>
<import file="${Ant - Common.dir}/macros.xml"/>
<property environment="env"/>
<property name="src.dir" value="src"/>
<property name="dtd.dir" value="dtd"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>
<path id="test.class.path">
<path refid="local.class.path"/>
<pathelement location="config"/>
</path>
<filelist id="test.classes"/>
<!-- ================================================================== -->
<!-- Removes all created files and directories -->
<!-- ================================================================== -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- Makes sure the needed directory structure is in place -->
<!-- ================================================================== -->
<target name="prepare" depends="init">
<mkdir dir="${build.dir}/classes"/>
<mkdir dir="${build.dir}/lib"/>
</target>
<target name="prepare-docs" depends="init">
<mkdir dir="${build.dir}/javadocs"/>
</target>
<target name="init"/>
<if>
<available file="${src.dir}"/>
<then>
<selector id="src-extra-set">
<or>
<filename name="**/*.properties"/>
<filename name="**/*.groovy"/>
<filename name="**/*.xml"/>
<filename name="**/*.bsh"/>
<filename name="**/*.logic"/>
<filename name="**/*.js"/>
<filename name="**/*.js"/>
<filename name="**/*.jacl"/>
<filename name="**/*.py"/>
<filename name="META-INF/**"/>
</or>
</selector>
<property name="src.extra.dir" value="${src.dir}"/>
</then>
<else>
<selector id="src-extra-set">
<filename name="**" negate="true"/>
</selector>
<property name="src.extra.dir" value="."/>
</else>
</if>
<!-- ================================================================== -->
<!-- Compilation of the source files -->
<!-- ================================================================== -->
<target name="classes" depends="prepare">
<if>
<available file="${src.dir}"/>
<then>
<javac18/>
</then>
</if>
</target>
<target name="jar" depends="classes">
<main-jar/>
</target>
<!-- ================================================================== -->
<!-- Build JavaDoc -->
<!-- ================================================================== -->
<target name="docs" depends="prepare-docs">
<default-javadoc/>
</target>
<macrodef name="run-junit">
<attribute name="build.jar" default="${build.dir}/lib/${name}.jar"/>
<attribute name="build-test.jar" default="${build.dir}/lib/${name}-test.jar"/>
<sequential>
<mkdir dir="${build.dir}/test-results"/>
<junit fork="on" haltonfailure="on" forkmode="once" showoutput="on" printsummary="off">
<classpath>
<path refid="junit.class.path"/>
<path refid="test.class.path"/>
<pathelement location="@{build.jar}"/>
<pathelement location="@{build-test.jar}"/>
</classpath>
<sysproperty key="net.sourceforge.cobertura.datafile" file="${build.dir}/test-results/cobertura.dat"/>
<sysproperty key="ofbiz.home" value="${ofbiz.home.dir}"/>
<formatter usefile="false" type="plain"/>
<batchtest>
<filelist refid="test.classes"/>
</batchtest>
</junit>
</sequential>
</macrodef>
<target name="tests" depends="jar">
<run-junit/>
</target>
<patternset id="cobertura-src-dirs">
<include name="src"/>
</patternset>
<target name="tests-cobertura" depends="jar">
<mkdir dir="${build.dir}/cobertura-lib"/>
<taskdef resource="tasks.properties" classpathref="cobertura.class.path"/>
<delete file="${build.dir}/test-results/cobertura.dat"/>
<cobertura-instrument datafile="${build.dir}/test-results/cobertura.dat" todir="${build.dir}/cobertura-lib">
<fileset dir="${build.dir}/lib">
<include name="*.jar"/>
</fileset>
</cobertura-instrument>
<run-junit build.jar="${build.dir}/cobertura-lib/${name}.jar"
build-test.jar="${build.dir}/cobertura-lib/${name}-test.jar"/>
<delete dir="${build.dir}/test-results/cobertura-report"/>
<mkdir dir="${build.dir}/test-results/cobertura-report"/>
<cobertura-report datafile="${build.dir}/test-results/cobertura.dat"
destdir="${build.dir}/test-results/cobertura-report">
<dirset dir=".">
<patternset refid="cobertura-src-dirs"/>
</dirset>
<include name="**/*.java"/>
</cobertura-report>
</target>
<target name="all" depends="jar,docs"/>
<!-- ================================================================== -->
<!-- Apply patches if exist -->
<!-- ================================================================== -->
<!--
This macro applies all patches found in ./patches/@{deployment} relative to ${ofbiz.home.dir}
and stops the build process if patches fail (to save time deleting all the rejects)
We use patch command here instead of svn patch because it's supposed to run in a server where patch is intalled in path
-->
<macrodef name="apply-patches">
<attribute name="deployment" default="dev"/>
<sequential>
<!-- patch task can't handle a fileset => create a global patch -->
<if>
<available file="patches"/>
<then>
<concat destfile="patches/@{deployment}.patch" encoding="UTF-8" outputencoding="UTF-8">
<!-- exclude the patch itself in case it's still there -->
<fileset dir="patches" includes="@{deployment}/*.patch"/>
</concat>
<patch strip="0" patchfile="patches/@{deployment}.patch" dir="${ofbiz.home.dir}"
failonerror="true"/>
<delete>
<fileset dir="patches" includes="@{deployment}.patch"/>
</delete>
</then>
</if>
</sequential>
</macrodef>
<target name="prepare-to-build-dev"
description="Does everything needed to get you a ready to start building OFBiz for development. This include generic patches for OFBiz itself, not only hot-deploy components">
<apply-patches deployment="dev"/>
</target>
<target name="prepare-to-build-test"
description="Does everything needed to get you a ready to start building OFBiz for integration testing">
<apply-patches deployment="test"/>
</target>
<target name="prepare-to-build-qa"
description="Does everything needed to get you a ready to start building OFBiz in QA-Environment">
<apply-patches deployment="qa"/>
<!-- need to use flatten here as qa dir might not exist and thus can't be included in "dir" -->
<copy toDir="config/" overwrite="true" flatten="true">
<fileset dir="patches" includes="qa/*.properties"/>
</copy>
</target>
<target name="prepare-to-build-production"
description="Does everything needed to get you a ready to start building OFBiz in production">
<apply-patches deployment="production"/>
<!-- need to use flatten here as production dir might not exist and thus can't be included in "dir" -->
<copy toDir="config/" overwrite="true" flatten="true">
<fileset dir="patches" includes="production/*.properties"/>
</copy>
<!-- Some files might need to be deleted in production, notably some specific script files -->
<!--exec executable="svn" dir="${ofbiz.home.dir}">
<arg value="delete"/>
<arg value="filename.sh"/>
</exec-->
</target>
</project>