1 |
d2a8c3fd
|
Marc NICOLAS
|
<?xml version="1.0"?>
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
<project name="get-m2" default="get-m2" basedir=".">
|
25 |
|
|
|
26 |
|
|
<description>
|
27 |
|
|
This build file downloads the Maven2 Ant tasks,
|
28 |
|
|
and installs them in the location specified by the m2.dest.dir property.
|
29 |
|
|
|
30 |
|
|
You may need to set proxy settings. On Java1.5, Ant tries to get
|
31 |
|
|
this from the OS, unless you use the -noproxy option.
|
32 |
|
|
|
33 |
|
|
Proxies can be configured manually setting the JVM proxy values in the
|
34 |
|
|
ANT_OPTS environment variable.
|
35 |
|
|
|
36 |
|
|
For example, to set the proxy up in the tcsh shell, the command would be
|
37 |
|
|
something like:
|
38 |
|
|
|
39 |
|
|
For csh/tcsh:
|
40 |
|
|
setenv ANT_OPTS "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
|
41 |
|
|
For bash:
|
42 |
|
|
export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
|
43 |
|
|
For Windows, set the environment variable in the appropriate dialog box
|
44 |
|
|
and open a new console. or, by hand
|
45 |
|
|
set ANT_OPTS = -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080
|
46 |
|
|
</description>
|
47 |
|
|
|
48 |
|
|
<property file="get-m2.properties" />
|
49 |
|
|
|
50 |
|
|
<property name="m2.antlib.resource"
|
51 |
|
|
value="org/apache/maven/artifact/ant/antlib.xml" />
|
52 |
|
|
|
53 |
|
|
<property name="m2.antlib.uri"
|
54 |
|
|
value="antlib:org.apache.maven.artifact.ant" />
|
55 |
|
|
|
56 |
|
|
<macrodef name="require">
|
57 |
|
|
<attribute name="property" />
|
58 |
|
|
<sequential>
|
59 |
|
|
<fail unless="@{property}">$${@{property}} not specified</fail>
|
60 |
|
|
</sequential>
|
61 |
|
|
</macrodef>
|
62 |
|
|
|
63 |
|
|
<target name="probe-m2">
|
64 |
|
|
<require property="m2.dest.dir" />
|
65 |
|
|
<require property="m2.jar.name" />
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
<property name="m2.artifact" location="${m2.dest.dir}/${m2.jar.name}" />
|
69 |
|
|
<available property="m2.antlib.found" resource="${m2.antlib.resource}" />
|
70 |
|
|
<condition property="m2.antlib.typefound">
|
71 |
|
|
<typefound name="${m2.antlib.uri}:artifact" />
|
72 |
|
|
</condition>
|
73 |
|
|
<available property="m2.artifact.found" file="${m2.artifact}" type="file" />
|
74 |
|
|
</target>
|
75 |
|
|
|
76 |
|
|
<target name="download-m2" depends="probe-m2" unless="m2.artifact.found">
|
77 |
|
|
<require property="m2.antlib.url" />
|
78 |
|
|
<echo>Downloading to ${m2.dest.dir}</echo>
|
79 |
|
|
|
80 |
|
|
<mkdir dir="${m2.dest.dir}" />
|
81 |
|
|
|
82 |
|
|
<get src="${m2.antlib.url}"
|
83 |
|
|
dest="${m2.artifact}"
|
84 |
|
|
verbose="true"
|
85 |
|
|
usetimestamp="false" />
|
86 |
|
|
</target>
|
87 |
|
|
|
88 |
|
|
<target name="dont-validate-m2-checksum" depends="probe-m2"
|
89 |
|
|
if="m2.artifact.found">
|
90 |
|
|
<property name="checksum.equal" value="true" />
|
91 |
|
|
</target>
|
92 |
|
|
|
93 |
|
|
<target name="validate-m2-checksum"
|
94 |
|
|
depends="download-m2,dont-validate-m2-checksum"
|
95 |
|
|
if="m2.sha1.checksum" unless="m2.artifact.found">
|
96 |
|
|
<checksum file="${m2.artifact}"
|
97 |
|
|
algorithm="SHA"
|
98 |
|
|
property="${m2.sha1.checksum}"
|
99 |
|
|
verifyProperty="checksum.equal" />
|
100 |
|
|
</target>
|
101 |
|
|
|
102 |
|
|
<target name="checksum-mismatch" depends="validate-m2-checksum"
|
103 |
|
|
if="m2.sha1.checksum" unless="checksum.equal">
|
104 |
|
|
<delete file="${m2.artifact}" />
|
105 |
|
|
<fail>
|
106 |
|
|
Failed to verify the downloaded file ${m2.antlib.url}" against the checksum
|
107 |
|
|
coded into libraries.properties.
|
108 |
|
|
The local copy has been deleted, for security reasons
|
109 |
|
|
</fail>
|
110 |
|
|
</target>
|
111 |
|
|
|
112 |
|
|
<target name="checksum-match" depends="checksum-mismatch"
|
113 |
|
|
unless="m2.antlib.found">
|
114 |
|
|
<taskdef classpath="${m2.artifact}" resource="${m2.antlib.resource}"
|
115 |
|
|
uri="${m2.antlib.uri}" />
|
116 |
|
|
</target>
|
117 |
|
|
|
118 |
|
|
<target name="get-m2" depends="checksum-match"
|
119 |
|
|
description="Download the Maven2 Ant tasks" />
|
120 |
|
|
|
121 |
|
|
</project> |