| <!-- |
| 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. |
| --> |
| |
| <!-- |
| |
| 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. |
| |
| TODO: |
| - Ant Tasks for Modello (generally useful and will greatly shorten the script) |
| - Ant Tasks for Plexus Component Descriptors (generally useful and will allow us to eliminate the hand-coded descriptors) |
| |
| --> |
| |
| <project default="all" basedir="." xmlns:artifact="urn:maven-artifact-ant"> |
| |
| <target name="initTaskDefs" unless="taskdefs.inited"> |
| <xmlproperty file="pom.xml" prefix="xmlPom" /> |
| <path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1.1.jar"/> |
| <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath"/> |
| <property name="taskdefs.inited" value="true"/> |
| </target> |
| |
| <target name="initLocalRepo"> |
| <property name="maven.repo.local" location="${user.home}/.m2/repository"/> |
| <echo>Using the local repository at: ${maven.repo.local}</echo> |
| </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> |
| <echo>Using Maven home at: ${maven.home}</echo> |
| </target> |
| |
| <target name="read-poms" depends="initTaskDefs,initLocalRepo" unless="pom.version"> |
| <copy file="pom.xml" tofile="dependencies.xml"/> |
| <replace file="${basedir}/dependencies.xml" token="<!--bootstrap-start-comment-->" value="<!--"/> |
| <replace file="${basedir}/dependencies.xml" token="<!--bootstrap-end-comment-->" value="-->"/> |
| <artifact:pom file="${basedir}/dependencies.xml" id="pom"> |
| <localRepository path="${maven.repo.local}"/> |
| </artifact:pom> |
| <delete file="${basedir}/dependencies.xml"/> |
| |
| <artifact:pom file="${basedir}/maven-integration-tests/pom.xml" id="itPom"> |
| <localRepository path="${maven.repo.local}"/> |
| </artifact:pom> |
| </target> |
| |
| <target name="init" depends="isMavenHomeSet,initLocalRepo"> |
| <basename file="${maven.home}" property="maven.home.basename"/> |
| <dirname file="${maven.home}" property="maven.home.dirname"/> |
| <property name="maven.home.basename.expected" value="apache-maven-${xmlPom.project.version}"/> |
| <property name="maven.assembly" location="apache-maven/target/${maven.home.basename.expected}-bin.zip"/> |
| <property name="surefire.useFile" value="true"/> |
| <echo>maven.home = ${maven.home}</echo> |
| <echo>maven.assembly = ${maven.assembly}</echo> |
| <fail message="Expected M2_HOME to end in ${maven.home.basename.expected} but was ${maven.home}"> |
| <condition> |
| <not> |
| <equals arg1="${maven.home.basename}" arg2="${maven.home.basename.expected}" /> |
| </not> |
| </condition> |
| </fail> |
| </target> |
| |
| <target name="clean-bootstrap" description="cleans up generated bootstrap classes"> |
| <delete dir="bootstrap"/> |
| </target> |
| |
| <target name="pull" depends="init, read-poms" unless="skip.pull"> |
| <!-- Pull the dependencies that Maven needs to build --> |
| <artifact:dependencies pathId="pom.pathid" filesetId="pom.fileset" useScope="compile"> |
| <localRepository path="${maven.repo.local}"/> |
| <pom refid="pom"/> |
| </artifact:dependencies> |
| |
| <!-- Pull the dependencies for Modello --> |
| <artifact:dependencies pathId="modello.pathid" filesetId="modello.fileset"> |
| <localRepository path="${maven.repo.local}"/> |
| <dependency groupId="org.codehaus.modello" artifactId="modello-maven-plugin" version="1.0"/> |
| <dependency groupId="org.codehaus.modello" artifactId="modello-core" version="1.0"/> |
| </artifact:dependencies> |
| </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-plugin-descriptor/src/main/mdo/lifecycle.mdo"/> |
| <modello file="maven-plugin-registry/plugin-registry.mdo"/> |
| <modello file="maven-plugin-parameter-documenter/src/main/mdo/paramdoc.mdo"/> |
| <modello file="maven-profile/src/main/mdo/profiles.mdo"/> |
| <modello file="maven-settings/src/main/mdo/settings.mdo"/> |
| <modello file="maven-repository-metadata/src/main/mdo/metadata.mdo"/> |
| <modello file="maven-toolchain/src/main/mdo/toolchains.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/*"/> |
| <include name="maven-reporting/maven-reporting-api/src/main/*"/> |
| <exclude name="maven-core-it-verifier/**"/> |
| </dirset> |
| </path> |
| |
| <mkdir dir="bootstrap/target/classes"/> |
| <javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.5" target="1.5" debug="true" includeAntRuntime="false"> |
| <src refid="sources"/> |
| <classpath refid="pom.pathid"/> |
| </javac> |
| |
| <!-- DGF generating a fake pom.properties so Maven thinks it has a version number --> |
| <mkdir dir="bootstrap/target/classes/META-INF/maven/org.apache.maven/maven-core"/> |
| <echo message="version=${xmlPom.project.version}" |
| file="bootstrap/target/classes/META-INF/maven/org.apache.maven/maven-core/pom.properties"/> |
| |
| <path id="maven.classpath"> |
| <pathelement location="bootstrap/target/classes"/> |
| <path refid="sources"/> |
| <path refid="pom.pathid"/> |
| </path> |
| </target> |
| |
| <target name="maven-compile" depends="compile-boot" description="compiles Maven using the bootstrap Maven, skipping automated tests"> |
| <java fork="true" classname="org.apache.maven.cli.compat.CompatibleMain" failonerror="true"> |
| <jvmarg value="-Xmx256M"/> |
| |
| <!-- <jvmarg value="-Xdebug"/> |
| <jvmarg value="-Xnoagent"/> |
| <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=8000"/> |
| <jvmarg value="-Djava.compiler=NONE"/> --> |
| |
| <classpath refid="maven.classpath"/> |
| <arg value="-e"/> |
| <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}"/> |
| <mkdir dir="${maven.home}"/> |
| <unzip src="${maven.assembly}" dest="${maven.home.dirname}"/> |
| <chmod perm="+x"> |
| <fileset dir="${maven.home}/bin"> |
| <include name="mvn"/> |
| <include name="mvnDebug"/> |
| </fileset> |
| </chmod> |
| </target> |
| |
| <target name="its-setup"> |
| <condition property="its.win32"> |
| <os family="windows"/> |
| </condition> |
| <condition property="its.unix"> |
| <not> |
| <os family="windows"/> |
| </not> |
| </condition> |
| <property name="maven.opts.its" value="-Xmx128m -XX:MaxPermSize=128m"/> |
| </target> |
| |
| <target name="its-win32" if="its.win32"> |
| <echo>Retrieving integration tests</echo> |
| <exec failonerror="true" dir="${basedir}/${itPom.artifactId}" executable="cmd"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <arg value="/c"/> |
| <arg value="${maven.home}\bin\mvn.bat"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="process-resources"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| <exec failonerror="true" dir="${basedir}/${itPom.artifactId}/target/classes" executable="cmd"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <arg value="/c"/> |
| <arg value="${maven.home}\bin\mvn.bat"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="clean"/> |
| <arg value="package"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| |
| <echo>Running integration tests</echo> |
| <exec failonerror="true" dir="${java.io.tmpdir}/${itPom.artifactId}-${itPom.version}" executable="cmd"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <env key="MAVEN_OPTS" value="${maven.opts.its}"/> |
| <arg value="/c"/> |
| <arg value="${maven.home}\bin\mvn.bat"/> |
| <arg value="-Prun-its"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="clean"/> |
| <arg value="install"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| </target> |
| |
| <target name="its-unix" if="its.unix"> |
| <echo>Retrieving integration tests</echo> |
| <exec failonerror="true" dir="${basedir}/${itPom.artifactId}" executable="${maven.home}/bin/mvn"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="process-resources"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| <exec failonerror="true" dir="${basedir}/${itPom.artifactId}/target/classes" executable="${maven.home}/bin/mvn"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="clean"/> |
| <arg value="package"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| |
| <echo>Running integration tests</echo> |
| <exec failonerror="true" dir="${java.io.tmpdir}/${itPom.artifactId}-${itPom.version}" executable="${maven.home}/bin/mvn"> |
| <env key="M2_HOME" value="${maven.home}"/> |
| <env key="MAVEN_OPTS" value="${maven.opts.its}"/> |
| <arg value="-Prun-its"/> |
| <arg value="-e"/> |
| <arg value="-B"/> |
| <arg value="clean"/> |
| <arg value="install"/> |
| <arg value="-Dmaven.repo.local=${maven.repo.local}"/> |
| </exec> |
| </target> |
| |
| <target name="run-its" depends="init,its-setup,its-win32,its-unix"> |
| <echo>Integration-test results should be displayed above.</echo> |
| </target> |
| |
| <target name="all" depends="clean-bootstrap,init,extract-assembly"/> |
| |
| <target name="with-its" depends="all,run-its"/> |
| |
| <target name="set-temp-maven-home" depends="initTaskDefs"> |
| <property name="maven.home" location="${java.io.tmpdir}/apache-maven-${xmlPom.project.version}"/> |
| <echo>Using temporary maven install directory: ${maven.home}</echo> |
| </target> |
| |
| </project> |