This repository has been archived by the owner on May 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
244 lines (212 loc) · 10.6 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
<!--
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.
-->
<!-- START SNIPPET: ant-bootstrap
By default the bootstrap will use ~/.m2/repository as the integration repository but you can define the integration
repository by specifying a property on the command line:
ant -Dmaven.repo.local=/my/integration/repository
Those familiar with Maven will note this is the same way the local repository can be set from the command-line.
This facilitates having a set of builds converge on the same repository for integration purposes.
END SNIPPET: ant-bootstrap -->
<project default="all" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property name="it.workdir.version" value="3.0.x"/>
<target name="initTaskDefs">
<xmlproperty file="pom.xml" prefix="pom.xml" />
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1-SNAPSHOT.jar"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath"/>
</target>
<target name="isMavenHomeSet" depends="initTaskDefs">
<property environment="env"/>
<condition property="maven.home" value="${env.M2_HOME}">
<isset property="env.M2_HOME"/>
</condition>
<fail message="You must set the M2_HOME environment variable or specify a maven.home property to this Ant script">
<condition>
<or>
<not>
<isset property="maven.home" />
</not>
<equals arg1="${maven.home}" arg2="" trim="true" />
</or>
</condition>
</fail>
</target>
<target name="init" depends="isMavenHomeSet">
<xmlproperty prefix="pom" file="pom.xml"/>
<dirname file="${maven.home}" property="maven.home.dirname"/>
<!-- Initialize properties -->
<property name="maven.home.basename.expected" value="apache-maven-${pom.project.version}"/>
<property name="maven.home.effective" location="${maven.home.dirname}/${maven.home.basename.expected}"/>
<property name="maven.assembly" location="apache-maven/target/${maven.home.basename.expected}-bin.zip"/>
<property name="maven.repo.local" value="${user.home}/.m2/repository"/>
<property name="maven.debug" value="-e"/>
<property name="surefire.useFile" value="true"/>
<echo>maven.home = ${maven.home.effective}</echo>
<echo>maven.repo.local = ${maven.repo.local}</echo>
</target>
<target name="clean-bootstrap" description="cleans up generated bootstrap classes">
<delete dir="bootstrap"/>
</target>
<target name="pull" depends="init" unless="skip.pull">
<property name="verbose" value="false"/>
<!-- Pull the dependencies that Maven needs to build -->
<copy file="pom.xml" tofile="dependencies.xml"/>
<replace file="${basedir}/dependencies.xml" token="<!--start-->" value="<!--"/>
<replace file="${basedir}/dependencies.xml" token="<!--end-->" value="-->"/>
<artifact:pom file="${basedir}/dependencies.xml" id="pom"/>
<artifact:dependencies pathId="pom.pathid" filesetId="pom.fileset" verbose="${verbose}" useScope="compile">
<localRepository path="${maven.repo.local}"/>
<pom refid="pom"/>
</artifact:dependencies>
<delete file="${basedir}/dependencies.xml"/>
<!-- Pull the dependencies for Modello -->
<artifact:dependencies pathId="modello.pathid" filesetId="modello.fileset" verbose="${verbose}">
<localRepository path="${maven.repo.local}"/>
<!-- TODO: remove when Modello 1.0.1 is released -->
<remoteRepository url="http://repo1.maven.org/" id="central"/>
<remoteRepository url="http://snapshots.repository.codehaus.org/" id="codehaus.snapshots">
<snapshots enabled="true"/>
<releases enabled="false"/>
</remoteRepository>
<!-- /TODO -->
<dependency groupId="org.codehaus.modello" artifactId="modello-maven-plugin" version="${pom.properties.modelloVersion}"/>
</artifact:dependencies>
<!-- Pull the dependencies for the MetadataGenerator CLI -->
<artifact:dependencies pathId="pmdg.pathid" filesetId="pmdg.fileset" verbose="${verbose}">
<localRepository path="${maven.repo.local}"/>
<dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="${pom.properties.plexusVersion}"/>
</artifact:dependencies>
</target>
<target name="process-classes" depends="pull" description="generates plexus component metadata.">
<mkdir dir="${basedir}/bootstrap/target"/>
<mkdir dir="${basedir}/bootstrap/target/classes"/>
<path id="maven.classpath">
<pathelement location="bootstrap/target/classes"/>
<path refid="sources"/>
<path refid="pom.pathid"/>
<path refid="pmdg.pathid"/>
</path>
<echo>Using plexus version ${pom.properties.plexusVersion}</echo>
<java fork="fork" classname="org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli" failonerror="true">
<classpath refid="maven.classpath"/>
<!-- We need to generate component descriptors from the maven-artifact sources which use javadoc annotations. -->
<arg value="--source"/>
<arg value="${basedir}/maven-compat/src/main/java"/>
<!-- We have separated the artifact handlers and lifecycle mappings into a separate file. -->
<arg value="--descriptors"/>
<arg value="${basedir}/maven-core/src/main/resources/META-INF/plexus"/>
<!-- Search the classes for annotations that we've compiled. -->
<arg value="--classes"/>
<arg value="${basedir}/bootstrap/target/classes"/>
<!-- We'll make one big fat components descriptor. -->
<arg value="--output"/>
<arg value="${basedir}/bootstrap/target/classes/META-INF/plexus/components.xml"/>
</java>
</target>
<target name="generate-sources" depends="pull" description="generates Java sources from Modello mdo model files">
<mkdir dir="bootstrap/target"/>
<mkdir dir="bootstrap/target/generated-sources"/>
<macrodef name="modello-single-mode">
<attribute name="file"/>
<attribute name="mode"/>
<attribute name="version"/>
<sequential>
<java fork="fork" classname="org.codehaus.modello.ModelloCli" failonerror="true">
<classpath refid="modello.pathid"/>
<arg file="@{file}"/> <!-- model file -->
<arg value="@{mode}"/> <!-- output type -->
<arg file="bootstrap/target/generated-sources"/> <!-- output directory -->
<arg value="@{version}"/> <!-- model version -->
<arg value="false"/> <!-- package with version -->
<arg value="true"/> <!-- use Java 5 -->
<arg value="UTF-8"/> <!-- encoding -->
</java>
</sequential>
</macrodef>
<macrodef name="modello">
<attribute name="file"/>
<attribute name="version" default="1.0.0"/>
<sequential>
<echo taskname="modello" message="Generating sources for @{file}"/>
<modello-single-mode file="@{file}" version="@{version}" mode="java"/>
<modello-single-mode file="@{file}" version="@{version}" mode="xpp3-reader"/>
<modello-single-mode file="@{file}" version="@{version}" mode="xpp3-writer"/>
</sequential>
</macrodef>
<modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/>
<modello file="maven-lifecycle/src/main/mdo/maven-lifecycle.mdo"/>
<modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/>
<modello file="maven-project/src/main/mdo/profiles.mdo"/>
<modello file="maven-core/src/main/mdo/settings.mdo"/>
<modello file="maven-toolchain/src/main/mdo/toolchains.xml"/>
<modello file="maven-compat/src/main/mdo/metadata.mdo"/>
</target>
<target name="compile-boot" depends="generate-sources" description="compiles the bootstrap sources">
<path id="sources">
<dirset dir=".">
<include name="bootstrap/target/generated-sources"/>
<include name="*/src/main/*"/>
</dirset>
</path>
<mkdir dir="bootstrap/target/classes"/>
<javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.5" target="1.5" debug="true">
<src refid="sources"/>
<classpath refid="pom.pathid"/>
</javac>
<path id="maven.classpath">
<pathelement location="bootstrap/target/classes"/>
<pathelement location="maven-compat/src/main/resources"/>
<path refid="sources"/>
<path refid="pom.pathid"/>
</path>
</target>
<target name="maven-compile" depends="compile-boot,process-classes" description="compiles Maven using the bootstrap Maven, skipping automated tests">
<java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true">
<classpath refid="maven.classpath"/>
<arg value="${maven.debug}"/>
<arg value="-B"/>
<arg value="clean"/>
<arg value="install"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/>
<arg value="-Dsurefire.useFile=${surefire.useFile}"/>
</java>
</target>
<target name="maven-assembly" depends="maven-compile" description="generates the Maven installation assembly using the bootstrap Maven">
<echo>
The new Maven distribution was created as part of the MAVEN-COMPILE step, above.
This goal just validates the presence of that distribution.
</echo>
<condition property="build.failed">
<not>
<available file="${maven.assembly}"/>
</not>
</condition>
<fail if="build.failed" message="Assembly task seemed to succeed, but couldn't find assembly file: ${maven.assembly}"/>
</target>
<target name="extract-assembly" depends="init,maven-assembly" description="extracts the maven assembly into maven.home">
<echo>Extracting assembly to ${maven.home.dirname} ...</echo>
<!-- If we are starting from scratch make sure the directory is created -->
<delete dir="${maven.home.effective}"/>
<mkdir dir="${maven.home.effective}"/>
<unzip src="${maven.assembly}" dest="${maven.home.dirname}"/>
<chmod perm="+x">
<fileset dir="${maven.home.effective}/bin">
<include name="mvn"/>
</fileset>
</chmod>
</target>
<target name="all" depends="clean-bootstrap,init,extract-assembly"/>
</project>