Mark Hobson wrote:
On 24/10/05, Mark Hobson <[EMAIL PROTECTED]> wrote:
On 24/10/05, Brett Porter <[EMAIL PROTECTED]> wrote:
I really think Ant should include this in general for Antlibs.
Could you do something relatively easily with <ant:get /> ?
I like it - hadn't seen that one before, I'll give it a go thanks.
Works well, may be worth adding to the doc:
<mkdir
dir="${user.home}/.m2/repository/org/apache/maven/maven-artifact-ant/2.0"/>
<get usetimestamp="true" verbose="true"
dest="${user.home}/.m2/repository/org/apache/maven/maven-artifact-ant/2.0/maven-artifact-ant-2.0-dep.jar"
src="http://www.ibiblio.org/maven2/org/apache/maven/maven-artifact-ant/2.0/maven-artifact-ant-2.0-dep.jar"
/>
or copy Ant's fetch.xml, which will ship with ant1.7, which is property
file driven. nobody should hard code versions into build files.
<?xml version="1.0"?>
<!--
=======================================================================
Build file to fetch optiona libraries for Apache Ant
Copyright (c) 2005 The Apache Software Foundation. All rights
reserved.
=======================================================================
-->
<project name="fetch" default="all" basedir=".">
<description>
This build file downloads JAR files that optional Ant tasks use,
and installs them in a location that is accessible the next time Ant
runs.
You can choose three locations, by going -Ddest=LOCATION on the
command line
-Ddest=user user lib dir ${user.home}/.ant/lib
-Ddest=system ant lib dir ${ant.home}/lib --Default--
-Ddest=optional optional dir ${ant.home}/lib/optional (for Ant
developers)
You may also need to set proxy settings. On Java1.5, Ant tries to get
this from the OS, unless you use the -noproxy option.
Proxies can be configured manually setting the JVM proxy values in the
ANT_OPTS environment variable.
For example, to set the proxy up in the tcsh shell, the command would be
something like:
For csh/tcsh:
setenv ANT_OPTS "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
For bash:
export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
For Windows, set the environment variable in the appropriate dialog box
and open a new console. or, by hand
set ANT_OPTS = -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080
</description>
<!-- Give user a chance to override without editing this file
(and without typing -D each time it compiles it) -->
<property file="${user.home}/.ant/ant.properties"/>
<property name="lib.dir" location="lib" />
<property name="optional.dir" location="${lib.dir}/optional" />
<property name="userlib.dir" location="${user.home}/.ant/lib" />
<!-- load in our properties table -->
<property file="${lib.dir}/libraries.properties"/>
<target name="pick-dest">
<condition property="dest.dir"
value="${lib.dir}">
<or>
<equals arg1="${dest}" arg2="system" />
<not><isset property="dest"/></not>
</or>
</condition>
<condition property="dest.dir"
value="${optional.dir}">
<equals arg1="${dest}" arg2="optional" />
</condition>
<condition property="dest.dir"
value="${userlib.dir}">
<equals arg1="${dest}" arg2="user" />
</condition>
<fail>
Unknown destination : ${dest}
<condition>
<not><isset property="dest.dir" /></not>
</condition>
</fail>
<echo>Downloading to ${dest.dir}</echo>
</target>
<target name="probe-m2" depends="pick-dest">
<!-- Look for M2 ant tasks in our classpath-->
<available property="m2.antlib.found"
resource="org/apache/maven/artifact/ant/antlib.xml" />
<condition property="m2.antlib.typefound">
<typefound name="antlib:org.apache.maven.artifact.ant:artifact" />
</condition>
</target>
<target name="get-m2" depends="probe-m2,pick-dest"
unless="m2.antlib.found">
<!-- fetch M2 ant tasks into our repository, if it is not there-->
<get src="${m2.antlib.url}"
dest="${dest.dir}/${m2.jar.name}"
verbose="true"
usetimestamp="false"/>
<fail status="0">
The Maven2 JAR has been installed; rerun ant to load it.
</fail>
</target>
<target name="macros" depends="get-m2"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<macrodef name="f2">
<attribute name="project" />
<attribute name="archive" default="@{project}"/>
<sequential>
<fail>
Unknown archive @{archive}
<condition>
<not>
<isset property="@{archive}.version"/>
</not>
</condition>
</fail>
<artifact:dependencies pathID="@{archive}.path">
<dependency groupID="@{project}"
artifactID="@{archive}"
version="[EMAIL PROTECTED]"/>
</artifact:dependencies>
<!-- now we are left with the problem of getting the files
into our directory -->
<copypath destdir="${dest.dir}" pathref="@{archive}.path">
<flattenmapper/>
</copypath>
</sequential>
</macrodef>
</target>
<!-- any init stuff -->
<target name="init" depends="pick-dest,macros" >
</target>
<target name="diag" depends="init">
<echoproperties />
</target>
<target name="logging"
description="load logging libraries"
depends="init">
<f2 project="log4j" />
<f2 project="commons-logging" archive="commons-logging-api" />
</target>
<target name="junit"
description="load junit libraries"
depends="init">
<f2 project="junit" />
</target>
<target name="xml"
description="load full XML libraries (xalan, resolver)"
depends="init">
<f2 project="xalan" />
<f2 project="xml-resolver" />
</target>
<target name="networking"
description="load networking libraries (commons-net; jsch)"
depends="init">
<f2 project="commons-net" />
<f2 project="jsch" />
</target>
<target name="regexp"
description="load regexp libraries"
depends="init">
<f2 project="regexp" />
<f2 project="oro" />
</target>
<target name="antlr"
description="load antlr libraries"
depends="init">
<f2 project="antlr" />
</target>
<target name="bcel"
description="load bcel libraries"
depends="init">
<f2 project="bcel" />
</target>
<target name="jdepend"
description="load jdepend libraries"
depends="init">
<f2 project="jdepend" />
</target>
<target name="bsf"
description="load bsf libraries"
depends="init">
<f2 project="bsf" />
</target>
<target name="debugging"
description="internal ant debugging"
depends="init">
<f2 project="which" />
</target>
<target name="all"
description="load all the libraries"
depends="logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging"
/>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]