-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.xml
241 lines (222 loc) · 11.9 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
<project default="basic.build" name="discovery site builder">
<!--
To test output, run maven in this folder:
$ mvn install -DPREFIX=jbosstools -DBUILD_ALIAS=Alpha1 -DBUILD_TIMESTAMP=2012-11-29_12-55-00 -DBUILD_NUMBER=6969 -DUPDATE_SITE=... -DEXTRAS_SITE=...
$ mvn install -DPREFIX=devstudio -DBUILD_ALIAS=Alpha1 -DBUILD_TIMESTAMP=2012-11-29_12-55-00 -DBUILD_NUMBER=4200 -DUPDATE_SITE=... -DEXTRAS_SITE=...
-->
<!-- pass in these values from Maven -->
<property name="UPDATE_SITE" value=""/>
<property name="EXTRAS_SITE" value=""/>
<!-- if ${WORKSPACE}/site folder exists, target that folder; else generate here. -->
<condition property="output.dir" value="${WORKSPACE}/results" else="${basedir}">
<available file="${WORKSPACE}/results" />
</condition>
<condition property="COMMON_TOOLS" value="/home/hudson/static_build_env/devstudio/tools" else="${java.io.tmpdir}">
<available file="/home/hudson/static_build_env/devstudio" type="dir" />
</condition>
<mkdir dir="${COMMON_TOOLS}" />
<tempfile property="tmpdir" destDir="${java.io.tmpdir}" prefix="aggregate-site-build"/>
<mkdir dir="${tmpdir}" />
<property name="project.build.directory" value="${output.dir}/target"/>
<property name="project.artifactId" value="org.jboss.tools.central.discovery"/>
<target name="init">
<echo level="verbose">
This script requires Ant 1.8+ and JDK 1.6+.
-------------------------------------------
$ant.version = ${ant.version}
$ant.home = ${ant.home}
$ant.java.version = ${ant.java.version}
$java.home = ${java.home}</echo>
<!-- <available file="${COMMON_TOOLS}/ant-contrib.jar" type="file" property="ant-contrib.jar.exists" /> -->
<!-- <antcall target="get.ant-contrib" /> -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<!-- <classpath>
<pathelement location="${COMMON_TOOLS}/ant-contrib.jar" />
</classpath> -->
</taskdef>
</target>
<target name="basic.build" description="discovery plugin build extra processing steps" depends="init,generate.directory.xml,generate.composite.site,cleanup" />
<!-- <target name="get.ant-contrib" unless="ant-contrib.jar.exists">
<property name="ANTCONTRIB_MIRROR" value="http://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2" />
<get usetimestamp="true" dest="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" src="${ANTCONTRIB_MIRROR}/ant-contrib-1.0b2-bin.zip" />
<touch file="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" />
<mkdir dir="${tmpdir}/ant-contrib-1.0b2-bin.zip_" />
<unzip src="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" dest="${tmpdir}/ant-contrib-1.0b2-bin.zip_" overwrite="true" />
<copy file="${tmpdir}/ant-contrib-1.0b2-bin.zip_/ant-contrib/lib/ant-contrib.jar" tofile="${COMMON_TOOLS}/ant-contrib.jar" failonerror="true" />
<delete dir="${tmpdir}/ant-contrib-1.0b2-bin.zip_" includeemptydirs="true" quiet="true" />
</target>
-->
<target name="generate.composite.site">
<if>
<or>
<equals arg1="${UPDATE_SITE}" arg2="$${UPDATE_SITE}"/>
<equals arg1="${UPDATE_SITE}" arg2="NONE"/>
</or>
<then>
<var name="UPDATE_SITE" unset="true"/>
<var name="UPDATE_SITE" value=""/>
<echo>UPDATE_SITE is not set. To add this site to the composite, use -DUPDATE_SITE=http://update/site/to/use/</echo>
</then>
</if>
<if>
<or>
<equals arg1="${EXTRAS_SITE}" arg2="$${EXTRAS_SITE}"/>
<equals arg1="${EXTRAS_SITE}" arg2="NONE"/>
</or>
<then>
<var name="EXTRAS_SITE" unset="true"/>
<var name="EXTRAS_SITE" value=""/>
<echo>EXTRAS_SITE is not set. To add this site to the composite, use -DEXTRAS_SITE=http://extras/site/to/use/</echo>
</then>
</if>
<condition property="compositeName"
value="Red Hat Developer Studio - Core + Central Update Site"
else="JBoss Tools - Core + Central Update Site">
<equals arg1="${PREFIX}" arg2="devstudio"/>
</condition>
<condition property="compositeURLs"
value="https://devstudio.redhat.com/targetplatforms/devstudiotarget/${TARGET_PLATFORM_VERSION}/REPO/,${UPDATE_SITE},${EXTRAS_SITE}"
else="https://download.jboss.org/jbosstools/targetplatforms/jbosstoolstarget/${TARGET_PLATFORM_VERSION}/REPO/,${UPDATE_SITE},${EXTRAS_SITE}">
<equals arg1="${PREFIX}" arg2="devstudio"/>
</condition>
<script language="javascript" classpath="${maven.plugin.classpath}">
<![CDATA[
property = project.setProperty("now",Math.floor((new Date()).getTime()));
]]>
</script>
<mkdir dir="${project.build.directory}/discovery-site/"/>
<antcall target="generate.composite.xml.file">
<param name="compositeName" value="${compositeName}"/>
<param name="compositeURLs" value="${compositeURLs}"/>
<param name="compositeType" value="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository"/>
<param name="compositeClass" value="compositeMetadataRepository"/>
<param name="compositeFile" value="${project.build.directory}/discovery-site/compositeContent.xml"/>
</antcall>
<antcall target="generate.composite.xml.file">
<param name="compositeName" value="${compositeName}"/>
<param name="compositeURLs" value="${compositeURLs}"/>
<param name="compositeType" value="org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository"/>
<param name="compositeClass" value="compositeArtifactRepository"/>
<param name="compositeFile" value="${project.build.directory}/discovery-site/compositeArtifacts.xml"/>
</antcall>
</target>
<target name="generate.composite.xml.file">
<!-- fileType is either org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository or org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository -->
<property name="compositeName" value="JBoss Tools - Core + Central Update Site"/>
<property name="compositeURLs" value="http://1,http://2,http://3"/>
<property name="compositeType" value="org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository"/>
<property name="compositeClass" value="compositeArtifactRepository"/>
<property name="compositeFile" value="${project.build.directory}/discovery-site/compositeArtifacts.xml"/>
<echo file="${compositeFile}"><?xml version='1.0' encoding='UTF-8'?>
<?${compositeClass} version='1.0.0'?>
<repository name='${compositeName}' type='${compositeType}' version='1.0.0'>
<properties size='2'>
<property name='p2.timestamp' value='${now}'/>
<property name='p2.compressed' value='true'/>
</properties>
</echo>
<var name="compositeURLCount" value="0"/>
<for list="${compositeURLs}" param="cURL">
<sequential>
<math result="compositeURLCount" operand1="${compositeURLCount}" operation="+" operand2="1" datatype="int" />
</sequential>
</for>
<echo file="${compositeFile}" append="true"> <children size='${compositeURLCount}'>
</echo>
<for list="${compositeURLs}" param="cURL">
<sequential>
<echo file="${compositeFile}" append="true"> <child location='@{cURL}'/>
</echo>
</sequential>
</for>
<echo file="${compositeFile}" append="true"> </children>
</repository></echo>
</target>
<target name="generate.directory.xml">
<echo level="verbose">project.build.directory = ${project.build.directory}</echo>
<!-- JBIDE-19702 if generating for earlyaccess site, copy both
org.jboss.tools.central.discovery.earlyaccess-4.3.1-SNAPSHOT.jar and
org.jboss.tools.central.discovery-4.3.1-SNAPSHOT.jar;
else just copy
org.jboss.tools.central.discovery-4.3.1-SNAPSHOT.jar.
DO NOT copy the EA jar into the Central site.
Note the trailing dash in the pattern! -->
<condition property="discovery-jar-pattern" value="*central.discovery*/target/*.central.discovery*.jar" else="*central.discovery*/target/*.central.discovery-*.jar">
<matches pattern=".*earlyaccess.*" string="${project.build.directory}"/>
</condition>
<echo level="verbose">discovery-jar-pattern = ${discovery-jar-pattern}</echo>
<!-- get filename matching org.jboss.tools.central.discovery_1.2.0.Alpha1-v20111013-0511-B1234.jar, then generate replacement directory.xml file -->
<var name="central.discovery.jars.renamed" value=""/>
<for param="central.discovery.jar.file">
<path>
<fileset dir="${project.build.directory}/../../">
<include name="${discovery-jar-pattern}" />
<exclude name="*central.discovery*/target/*-sources.jar" />
</fileset>
</path>
<sequential>
<var name="central.discovery.path" value="@{central.discovery.jar.file}" />
<echo level="verbose">central.discovery.path = ${central.discovery.path}</echo>
<var name="central.discovery.jar" unset="true"/>
<basename property="central.discovery.jar" file="${central.discovery.path}" />
<if>
<not>
<equals arg1="${central.discovery.jar}" arg2="" trim="true" />
</not>
<then>
<!-- from 2011-09-21_01-11-04 to 20110921-0111 -->
<propertyregex override="true" property="VERSION_CLEAN" defaultvalue="${VERSION}" input="${VERSION}" regexp="([0-9]+.[0-9]+.[0-9]+)-SNAPSHOT" replace="\1"/>
<mkdir dir="${project.build.directory}/discovery-site/plugins"/>
<if>
<isset property="BUILD_TIMESTAMP"/>
<then>
<propertyregex override="true" property="BUILD_TS" defaultvalue="${BUILD_TIMESTAMP}" input="${BUILD_TIMESTAMP}" regexp="([0-9]+)-([0-9]+)-([0-9]+)_([0-9]+)-([0-9]+)-([0-9]+)" replace="v\1\2\3-\4\5" />
<propertyregex override="true" property="central.discovery.jar.renamed" defaultvalue="${central.discovery.jar}" input="${central.discovery.jar}" regexp="-[0-9.]+-SNAPSHOT" replace="_${VERSION_CLEAN}.${BUILD_ALIAS}-${BUILD_TS}-B${BUILD_NUMBER}"/>
</then>
<else>
<tstamp>
<format property="BUILD_TS" pattern="yyyyMMdd-hhmm" timezone="GMT+0"/>
</tstamp>
<propertyregex override="true" property="central.discovery.jar.renamed" defaultvalue="${central.discovery.jar}" input="${central.discovery.jar}" regexp="-[0-9.]+-SNAPSHOT" replace="_${VERSION_CLEAN}.${BUILD_ALIAS}-${BUILD_TS}"/>
</else>
</if>
<copy file="${central.discovery.path}" tofile="${project.build.directory}/discovery-site/plugins/${central.discovery.jar.renamed}"/>
<echo level="verbose">Collect discovery jar: ${project.build.directory}/discovery-site/plugins/${central.discovery.jar.renamed}</echo>
<var name="central.discovery.jars.renamed" value="${central.discovery.jars.renamed} ${central.discovery.jar.renamed}"/>
</then>
</if>
</sequential>
</for>
<echo level="verbose">Generate ${project.build.directory}/discovery-site/${PREFIX}-directory.xml pointing at discovery jar(s)</echo>
<!-- base URL--> <!-- Since 2.24.0, discovery now requires full url for location-->
<propertyregex property="baseURL"
input="${UPDATE_SITE}"
regexp="(.*)/updates"
select="\1"
casesensitive="false" />
<condition property="subPath" value="discovery.earlyaccess" else="discovery.central">
<matches pattern=".*earlyaccess.*" string="${project.build.directory}"/>
</condition>
<condition property="stream" value="${stream_jbt}" else="${version_jbt}">
<matches pattern="snapshots" string="${buildType}"/>
</condition>
<!-- header -->
<echo file="${project.build.directory}/discovery-site/${PREFIX}-directory.xml"><?xml version='1.0' encoding='UTF-8'?>
<directory xmlns="http://www.eclipse.org/mylyn/discovery/directory/">
</echo>
<!-- plugin(s) -->
<for list="${central.discovery.jars.renamed}" delimiter=" " param="central.discovery.jar.renamed">
<sequential>
<echo level="verbose">Add discovery jar to directory.xml: @{central.discovery.jar.renamed}</echo>
<echo append="true" file="${project.build.directory}/discovery-site/${PREFIX}-directory.xml"><entry url="${baseURL}/updates/${subPath}/${stream}/plugins/@{central.discovery.jar.renamed}" permitCategories="true"/>
</echo>
</sequential>
</for>
<!-- footer -->
<echo append="true" file="${project.build.directory}/discovery-site/${PREFIX}-directory.xml"></directory>
</echo>
</target>
<target name="cleanup">
<delete dir="${tmpdir}" quiet="true" includeemptydirs="true" />
</target>
</project>