You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ke...@apache.org on 2006/10/11 18:44:57 UTC
svn commit: r462848 - /maven/components/trunk/build.xml
Author: kenney
Date: Wed Oct 11 09:44:55 2006
New Revision: 462848
URL: http://svn.apache.org/viewvc?view=rev&rev=462848
Log:
* Added snapshot version resolution using maven-metadata.xml
* moved generated-sources, classes locations etc to target/
* use the correct maven version when generating the pom.properties:
'BOOTSTRAP' is an illegal version, and causes multiple plugins to
not run because they require 2.0.2 or newer.
Modified:
maven/components/trunk/build.xml
Modified: maven/components/trunk/build.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/build.xml?view=diff&rev=462848&r1=462847&r2=462848
==============================================================================
--- maven/components/trunk/build.xml (original)
+++ maven/components/trunk/build.xml Wed Oct 11 09:44:55 2006
@@ -1,4 +1,5 @@
<project default="run-full-maven">
+
<description>
The first time you build Maven from source, you have to build Maven without Maven.
This Ant script builds a minimal Maven, just enough to re-launch Maven again in this
@@ -12,6 +13,7 @@
You can set the maven.repo.local property to specify a custom location for your
local repository for the bootstrap process.
</description>
+
<target name="isMavenHomeSet">
<property environment="env"/>
<condition property="maven.home" value="${env.M2_HOME}">
@@ -20,6 +22,7 @@
<fail unless="maven.home"
message="You must set the M2_HOME environment variable or specify a maven.home property to this Ant script"/>
</target>
+
<target name="checkMavenHome" depends="isMavenHomeSet">
<basename file="${maven.home}" property="maven.home.basename"/>
<dirname file="${maven.home}" property="maven.home.dirname"/>
@@ -33,18 +36,20 @@
</condition>
<fail if="build.failed">
The Maven install destination directory must end with '${maven.home.basename.expected}'.
- Your maven.home was = ${maven.home}
+ Your M2_HOME was = ${maven.home}
We recommend = ${maven.home.recommended}
</fail>
<echo message="maven.home=${maven.home}"/>
</target>
+
<target name="init" depends="checkMavenHome">
<property name="maven.repo.local" value="${user.home}/.m2/repository"/>
</target>
+
<target name="clean-bootstrap" description="cleans up generated bootstrap classes">
- <delete dir="bootstrap/generated-sources"/>
- <delete dir="bootstrap/classes"/>
+ <delete dir="bootstrap/target"/>
</target>
+
<!-- DGF TODO Make a simple Java Ant task that pulls dependencies and adds them to a path reference, so we don't have to copy-and-paste -->
<!-- Then again, this *is* a very simple Ant script, so maybe there's no need to get fancy...? -->
<target name="pull" depends="init"
@@ -55,18 +60,16 @@
<attribute name="name"/>
<attribute name="version"/>
<sequential>
- <get src="http://people.apache.org/repo/m2-snapshot-repository/@{orgpath}/@{version}/@{name}-@{version}.jar"
- dest="${maven.repo.local}/@{orgpath}/@{version}/@{name}-@{version}.jar" usetimestamp="true"
- ignoreerrors="true"/>
- <get src="http://repo1.maven.org/maven2/@{orgpath}/@{version}/@{name}-@{version}.jar"
- dest="${maven.repo.local}/@{orgpath}/@{version}/@{name}-@{version}.jar" usetimestamp="true"
- ignoreerrors="false"/>
- <condition property="build.failed">
- <not>
- <available file="${maven.repo.local}/@{orgpath}/@{version}/@{name}-@{version}.jar"/>
- </not>
- </condition>
- <fail if="build.failed" message="Couldn't pull dependency @{orgpath}/@{name}/@{version}"/>
+ <!-- call an ant task to download the artifact. The script cannot be
+ defined in here, because you cannot re-initialize properties.
+ Calling the script like this will scope the properties so they can
+ be re-initialized.
+ -->
+ <antcall target="download-artifact" inheritAll="true">
+ <param name="orgpath" value="@{orgpath}"/>
+ <param name="name" value="@{name}"/>
+ <param name="version" value="@{version}"/>
+ </antcall>
</sequential>
</macrodef>
<pull orgpath="org/codehaus/plexus/plexus-utils" version="1.1" name="plexus-utils"/>
@@ -84,11 +87,14 @@
<pull orgpath="org/codehaus/modello/modello-core" version="1.0-alpha-7" name="modello-core"/>
<pull orgpath="org/codehaus/modello/modello-plugin-xml" version="1.0-alpha-8" name="modello-plugin-xml"/>
<pull orgpath="org/codehaus/modello/modello-plugin-xpp3" version="1.0-alpha-8" name="modello-plugin-xpp3"/>
+ <pull orgpath="junit/junit" version="3.8.1" name="junit"/>
</target>
+
<target name="classpath-pre" depends="init,pull"
description="constructs a classpath reference containing our dependencies, and verifies that all files are present">
<path id="pre.classpath">
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar"/>
+ <pathelement location="${maven.repo.local}/junit/junit/3.8.1/junit-3.8.1.jar"/>
<pathelement
location="${maven.repo.local}/org/codehaus/plexus/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.jar"/>
<pathelement location="${maven.repo.local}/commons-cli/commons-cli/1.0/commons-cli-1.0.jar"/>
@@ -125,9 +131,13 @@
<pathconvert property="pre.classpath.str" refid="pre.classpath" pathsep="
"/>
<pathconvert property="modello.classpath.str" refid="modello.classpath" pathsep="
"/>
</target>
+
<target name="generate-sources" depends="classpath-pre"
- description="generates Java sources from Modello mdo model files">
- <mkdir dir="bootstrap/generated-sources"/>
+ 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"/>
@@ -137,12 +147,13 @@
<classpath refid="modello.classpath"/>
<arg file="@{file}"/>
<arg value="@{mode}"/>
- <arg file="bootstrap/generated-sources"/>
+ <arg file="bootstrap/target/generated-sources"/>
<arg value="@{version}"/>
<arg value="false"/>
</java>
</sequential>
</macrodef>
+
<macrodef name="modello">
<attribute name="file"/>
<attribute name="version" default="1.0.0"/>
@@ -153,6 +164,7 @@
<modello-single-mode file="@{file}" version="@{version}" mode="xpp3-writer"/>
</sequential>
</macrodef>
+
<modello file="maven-model/maven.mdo" version="4.0.0"/>
<!-- DGF TODO turn this into a big <apply> task? write a custom task? -->
<modello file="maven-plugin-descriptor/src/main/mdo/lifecycle.mdo"/>
@@ -168,7 +180,7 @@
<target name="compile-boot" depends="generate-sources" description="compiles the bootstrap sources">
<path id="sources">
<dirset dir=".">
- <include name="bootstrap/generated-sources"/>
+ <include name="bootstrap/target/generated-sources"/>
<include name="*/src/main/*"/>
<include name="maven-reporting/maven-reporting-api/src/main/*"/>
<exclude name="maven-repository-tools/**"/>
@@ -176,19 +188,19 @@
</dirset>
</path>
- <mkdir dir="bootstrap/classes"/>
- <javac destdir="bootstrap/classes" debug="on">
+ <mkdir dir="bootstrap/target/classes"/>
+ <javac destdir="bootstrap/target/classes" debug="on">
<src refid="sources"/>
<classpath refid="pre.classpath"/>
</javac>
<!-- DGF generating a fake pom.properties so Maven thinks it has a version number -->
- <mkdir dir="bootstrap/classes/META-INF/maven/org.apache.maven/maven-core"/>
- <echo message="version=BOOTSTRAP"
- file="bootstrap/classes/META-INF/maven/org.apache.maven/maven-core/pom.properties"/>
+ <mkdir dir="bootstrap/target/classes/META-INF/maven/org.apache.maven/maven-core"/>
+ <echo message="version=${pom.project.version}"
+ file="bootstrap/target/classes/META-INF/maven/org.apache.maven/maven-core/pom.properties"/>
<path id="maven.classpath">
- <pathelement location="bootstrap/classes"/>
+ <pathelement location="bootstrap/target/classes"/>
<path refid="sources"/>
<path refid="pre.classpath"/>
</path>
@@ -205,6 +217,7 @@
<arg value="install"/>
</java>
</target>
+
<target name="maven-assembly" depends="maven-compile"
description="generates the Maven installation assembly using the bootstrap Maven">
<java fork="true" dir="maven-cli" classname="org.apache.maven.cli.MavenCli" failonerror="true">
@@ -223,11 +236,13 @@
<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">
<delete dir="${maven.home}"/>
<unzip src="${maven.assembly}" dest="${maven.home.dirname}"/>
</target>
+
<target name="run-full-maven" depends="init,extract-assembly"
description="runs the full extracted Maven, now with tests">
<property name="maven.goals" value="clean install"/>
@@ -245,4 +260,49 @@
<arg line="${maven.goals}"/>
</java>
</target>
+
+
+ <!--
+ Downloads an artifact, detecting wheter it's a snapshot, and uses the maven-metadata.xml to retrieve
+ the correct version.
+ -->
+ <target name="download-artifact">
+
+ <!-- choose the proper repository -->
+ <condition property="repo" value="http://people.apache.org/repo/m2-snapshot-repository" else="http://repo1.maven.org/maven2">
+ <contains string="${version}" substring="SNAPSHOT"/>
+ </condition>
+
+ <!-- get the metadata file -->
+ <get src="${repo}/${orgpath}/${version}/maven-metadata.xml"
+ dest="${maven.repo.local}/${orgpath}/${version}/bootstrap-maven-metadata.xml" usetimestamp="true"
+ ignoreerrors="true"
+ />
+
+ <!-- Replace 'SNAPSHOT' with 'timestamp-buildnumber'. This is ugly but
+ ant doesn't allow updating of properties.
+ -->
+ <xmlproperty file="${maven.repo.local}/${orgpath}/${version}/bootstrap-maven-metadata.xml"/>
+ <echo file="deleteme.version.properties" message="${version}"/>
+ <replaceregexp file="deleteme.version.properties"
+ match="SNAPSHOT"
+ replace="${metadata.versioning.snapshot.timestamp}-${metadata.versioning.snapshot.buildNumber}"
+ byline="true"/>
+ <loadfile srcFile="deleteme.version.properties" property="fileversion"/>
+
+ <echo>Resolved version ${fileversion} (given=${version})</echo>
+
+ <!-- download the final jar -->
+ <get src="${repo}/${orgpath}/${version}/${name}-${fileversion}.jar"
+ dest="${maven.repo.local}/${orgpath}/${version}/${name}-${fileversion}.jar" usetimestamp="true"
+ ignoreerrors="false"
+ />
+ <condition property="build.failed">
+ <not>
+ <available file="${maven.repo.local}/${orgpath}/${version}/${name}-${version}.jar"/>
+ </not>
+ </condition>
+ <fail if="build.failed" message="Couldn't pull dependency ${orgpath}/${name}/${version}"/>
+ </target>
+
</project>