[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[virgo-dev] Downloading dependencies from Maven Central
|
In preparing the Virgo System Verification Tests repository for donation to Eclipse I wanted to download a couple of large WAR files from Maven Central to avoid having to raise a number of CQs and trouble the legal team unnecessarily.
I found the Maven Ant tasks enabled this fairly simply. Here is an extract of the build.xml which shows the approach:
<project name="org.eclipse.virgo.server.svt" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:maven="antlib:org.apache.maven.artifact.ant">
<property name="ivy.cache.dir" value="${basedir}/../ivy-cache" />
<property name="integration.repo.dir" value="${basedir}/../integration-repo"/>
<property name="download.dir" value="${basedir}/target/bundles"/>
<property file="${basedir}/../build.properties"/>
<property file="${basedir}/../build.versions"/>
<import file="${basedir}/../virgo-build/standard/default.xml"/>
<import file="${basedir}/../build-svt/test-package.xml"/>
<property name="bundles.dir" value="${basedir}/bundles"/>
<property name="libraries.dir" value="${basedir}/libraries"/>
<property name="greenpagesdb.dir" value="${basedir}/../org.eclipse.virgo.server.svt/greenpages-db"/>
<property name="svt.cleanstart.dir" value="${basedir}/../org.eclipse.virgo.server.svt.cleanstart"/>
<!-- Make Maven Ant task available. -->
<target name="maven.init" depends="ivy.init">
<ivy:cachepath resolveId="maven.ant.tasks.classpath" pathid="maven.ant.tasks.classpath"
organisation="org.apache.maven" module="com.springsource.org.apache.maven.ant"
revision="${org.apache.maven.ant.version}" conf="runtime" type="jar" inline="true" log="download-only"/>
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven.ant.tasks.classpath"/>
<maven:install-provider groupId="org.springframework.build.aws" artifactId="org.springframework.build.aws.maven"
version="${org.springframework.build.aws.maven.version}"/>
</target>
<target name="maven.download" depends="maven.init">
<delete dir="${download.dir}" quiet="true"/>
<mkdir dir="${download.dir}"/>
<!-- Download some dependencies from Maven Central. -->
<maven:dependencies filesetId="maven.fileset" versionsId="maven.versions">
<dependency groupId="org.apache.struts" artifactId="struts2-mailreader" version="2.1.8" type="war" scope="compile" />
<dependency groupId="org.wicketstuff" artifactId="phonebook" version="1.4.8" type="war" scope="compile" />
<remoteRepository id="maven.central" url="http://repo1.maven.org/maven2" />
</maven:dependencies>
<!-- Copy the downloaded files and strip out the versions from the file names. -->
<copy todir="${download.dir}">
<fileset refid="maven.fileset" />
<mapper classpathref="maven.ant.tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${maven.versions}" to="flatten" />
</copy>
</target>
<target name="download" depends="ivy.init,maven.download">
<ivy:resolve resolveId="download.deps" file="${basedir}/ivy.xml" transitive="false"/>
<ivy:retrieve resolveId="download.deps" pattern="${download.dir}/[artifact]-[revision].[ext]" conf="test" type="jar"/>
</target>
Apart from the three commented sections, note that there is an extra XML namespace declaration for "maven" in the project element.
Regards,
Glyn