forked from topcoder-archive/direct-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-master-tasks.xml
215 lines (169 loc) · 8.6 KB
/
build-master-tasks.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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
Dec 1, 2008 10:12:19 PM
Build Master Tasks
TCSDEVELOPER
====================================================================== -->
<project name="tools.master.tasks">
<description>
Defines tasks that execute ant scripts or build targets on all the subprojects.
</description>
<!-- = = = = = = = = = = = = = = = = =
macrodef: run-targets-all
Builds a target on each of the subprojects.
= = = = = = = = = = = = = = = = = -->
<macrodef name="run-target-all" description="Builds a target on each of the components.">
<!-- the target to build on every subproject -->
<attribute name="target" />
<attribute name="config" />
<!-- properties that will be passed to the target to build -->
<element name="properties" optional="true"/>
<sequential>
<execute-all prefix="project.current" config="@{config}">
<sequential>
<echo message=""/>
<echo message="--- Executing for: ${project.current.name}"/>
<ant antfile="${project.current.buildType}/${project.current.basedir}/${project.current.buildfile}" target="@{target}" inheritall="false">
<propertyset>
<propertyref builtin="commandline"/>
</propertyset>
<property name="needTokenize" value="${project.current.tokenize}"/>
</ant>
</sequential>
</execute-all>
</sequential>
</macrodef>
<!-- = = = = = = = = = = = = = = = = =
scriptdef: execute-all
Runs any ant-script sequence on all subprojects.
= = = = = = = = = = = = = = = = = -->
<scriptdef name="execute-all" language="groovy" description="Runs a sequence of ant script on all the subprojects." classpathref="script.path">
<!-- the prefix of the exported properties -->
<attribute name="prefix" />
<!-- the prefix of the config name -->
<attribute name="config"/>
<!-- the ant-script to run on each of the projects -->
<element name="sequential" type="sequential" />
<![CDATA[
import groovy.util.XmlParser
def prefix = attributes.prefix
def config = attributes.config;
def projects = new XmlParser().parse(new File(project.getProperty("${config}")))
projects.project.each { subproject ->
[
[name : 'name', required : true ],
[name : 'basedir', required : false, defaultValue : subproject.'@name'],
[name : 'buildfile', required : false, defaultValue : 'build.xml'],
[name : 'buildType', required : false, defaultValue : 'components'],
[name : 'tokenize', required : false, defaultValue : 'false']
].each {
def value = subproject."@${it.name}"
if (value == null || value.trim().length() == 0) {
if (it.required) {
self.fail("The ${it.name} attribute of a subproject is required.")
}
value = it.defaultValue
}
value = project.replaceProperties(value)
if(value != null) project.setProperty("${prefix}.${it.name}", value)
}
subproject.versions.version.each {
project.setProperty("${prefix}.version.${it.'@name'}", it.'@path')
}
elements.sequential.each { it.execute() }
}
]]>
</scriptdef>
<!-- = = = = = = = = = = = = = = = = =
scriptdef: execute-single
Runs any ant-script sequence on the specified subproject.
= = = = = = = = = = = = = = = = = -->
<scriptdef name="execute-single" language="groovy" description="Runs a sequence of ant script on the specified subproject." classpathref="script.path">
<!-- the prefix of the exported properties -->
<attribute name="prefix" />
<!-- defines for which subproject project to execute -->
<attribute name="subproject" />
<!-- the ant-script to run on each of the projects -->
<element name="sequential" type="sequential" />
<![CDATA[
import groovy.util.XmlParser
def prefix = attributes.prefix
def projectName = attributes.subproject
def projects = new XmlParser().parse(new File(project.getProperty("subprojects.conf")))
def matchedProjects = projects.project.findAll {it.'@name' == projectName}
if (matchedProjects.size() == 0) {
println "The subproject ${projectName} is not defined in ${project.getProperty("subprojects.conf")}."
} else if (matchedProjects.size() != 1) {
println "The subproject ${projectName} is mutiplely defined in ${project.getProperty("subprojects.conf")}."
} else {
matchedProjects.each { subproject ->
[[name : 'name', required : true ],
[name : 'svnbase', required : true ],
[name : 'basedir', required : false, defaultValue : subproject.'@name'],
[name : 'buildfile', required : false, defaultValue : 'build.xml']].each {
def value = subproject."@${it.name}"
if (value == null || value.trim().length() == 0) {
if (it.required) {
self.fail("The ${it.name} attribute of a subproject is required.")
}
value = it.defaultValue
}
value = project.replaceProperties(value)
project.setProperty("${prefix}.${it.name}", value)
}
subproject.versions.version.each {
project.setProperty("${prefix}.version.${it.'@name'}", it.'@path')
}
elements.sequential.each { it.execute() }
}
}
]]>
</scriptdef>
<macrodef name="update-single-revision-number" description="Update revision number for a file.">
<attribute name="file" />
<attribute name="type" />
<sequential>
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpathref="script.path"/>
<pathconvert property="pathInPage" pathsep="/" dirsep="/">
<path location="@{file}"/>
<map from="${basedir}/src/web" to="" />
</pathconvert>
<exec executable="git" outputproperty="git.log.lastMod">
<arg value="log"/>
<arg value="-1"/>
<arg value="--pretty=format:%ct"/>
<arg value="@{file}"/>
</exec>
<groovy>
<![CDATA[
import java.util.*
def calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
calendar.setTimeInMillis(Long.parseLong(properties["git.log.lastMod"]) * 1000)
properties["lastModYear"] = "" + calendar.get(Calendar.YEAR)
def month = calendar.get(Calendar.MONTH) + 1
if (month < 10) {
properties["lastModMonth"] = "0" + month
} else {
properties["lastModMonth"] = "" + month
}
def day = calendar.get(Calendar.DAY_OF_MONTH)
if (day < 10) {
properties["lastModDate"] = "0" + day
} else {
properties["lastModDate"] = "" + day
}
]]>
</groovy>
<basename property="filename" file="${pathInPage}" suffix=".@{type}"/>
<replaceregexp byline="true">
<regexp pattern='([href|src])="(.*${filename})(\.git\d+)?\.@{type}(\?v=\d+)?"'/>
<substitution expression='\1="\2\.git${lastModYear}${lastModMonth}${lastModDate}\.@{type}"'/>
<fileset dir="${build_distdir}/direct.war">
<include name="**/*.jsp"/>
</fileset>
</replaceregexp>
</sequential>
</macrodef>
</project>