-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-ivy.xml
148 lines (140 loc) · 6.04 KB
/
build-ivy.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<project name="tunnelingproxy.ivy"
xmlns:ivy="antlib:org.apache.ivy.ant"
>
<!-- This project uses ivy to retrieve its external library
dependencies from the maven.org repository. Ivy handles the
mechanics of retrieving libraries from the maven repository,
recursively retrieving any of their dependencies, and setting
path variables to point to all of the appropriate resulting
".jar" files. Ivy also caches its downloads under ".ivycache"
(a .gitignore'd directory) so that if the build directory is
removed, the libraries can be "downloaded" quickly again from
the local cache on the next build. If the ".ivycache"
directory is removed, then ivy will retrieve the libraries from
maven. The ivy library itself is "bootstrapped" by loading it
from the .ivycache directory, or if not found there, directly
from maven using the ant "get" task. As a result, no libraries
should need to be checked into source control, even the ivy
library itself.
-->
<property name="ivyDir" location="build/ivy"/>
<!-- Set the classpaths to the loaded libraries for the various configurations -->
<target name="ivy" depends="ivy-libs">
<path id="ivy.compile.classpath">
<fileset dir="${ivyDir}/compile">
<include name="**/*.jar" />
</fileset>
</path>
<path id="ivy.runtime.classpath">
<fileset dir="${ivyDir}/runtime">
<include name="**/*.jar" />
</fileset>
</path>
<path id="ivy.test.classpath">
<fileset dir="${ivyDir}/test">
<include name="**/*.jar" />
</fileset>
</path>
</target>
<!-- Load the dependencies specified in ivy.xml -->
<target name="ivy-libs" depends="ivy-ant-tasks,ivy-libs.checkuptodate"
unless="ivy-libs.uptodate">
<!-- Specifies where to load dependencies from (maven), and where
the cache directory is (.ivycache) -->
<ivy:configure file="ivysettings.xml"/>
<!-- Bring the dependencies into the ivy cache (typically
~/.ivy2/cache) -->
<ivy:resolve file="ivy.xml"/>
<!-- Copy the dependencies from the ivy cache into our build/ivy
directory. For each of the "configurations" we're interested
in, we retrieve the subset of files appropriate to that
configuration. The configurations are specified in the
ivy.xml file. -->
<ivy:retrieve
pattern="${ivyDir}/compile/[artifact]-[revision](-[classifier]).[ext]"
conf="compile"/>
<ivy:retrieve
pattern="${ivyDir}/runtime/[artifact]-[revision](-[classifier]).[ext]"
conf="runtime"/>
<ivy:retrieve
pattern="${ivyDir}/test/[artifact]-[revision](-[classifier]).[ext]"
conf="test"/>
<ivy:retrieve
pattern="${ivyDir}/release/[artifact]-[revision](-[classifier]).[ext]"
conf="release"/>
<ivy:retrieve
pattern="${ivyDir}/javadoc/[artifact]-[revision](-[classifier]).[ext]"
conf="javadoc"/>
<touch file="${ivyDir}/ivy-libs.complete"/>
</target>
<target name="ivy-libs.checkuptodate">
<uptodate property="ivy-libs.uptodate"
srcfile="ivy.xml"
targetfile="${ivyDir}/ivy-libs.complete"/>
</target>
<!-- Add the ivy ant tasks -->
<target name="ivy-ant-tasks" depends="bootstrap-ivy">
<!-- Add the ivy bootstrap libraries to our path -->
<path id="ivy.lib.path">
<fileset dir="${ivyDir}" includes="*.jar"/>
</path>
<!-- Define the ivy ant tasks -->
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant"
classpathref="ivy.lib.path"
/>
</target>
<!-- "Bootstrap" ivy by loading ivy.jar from .ivycache or from Maven
Central -->
<target name="bootstrap-ivy"
depends="bootstrap-ivy.checkuptodate"
unless="bootstrap-ivy.uptodate">
<property name="mavenUrl" value="https://repo1.maven.org/maven2/"/>
<property name="ivyVersion" value="2.4.0"/>
<mkdir dir="${ivyDir}"/>
<!-- Try loading from .ivycache first -->
<antcall target="copy-ivy"/>
<!-- Otherwise load from Maven Central -->
<antcall target="download-ivy"/>
<touch file="${ivyDir}/bootstrap-ivy.complete"/>
</target>
<target name="bootstrap-ivy.checkuptodate">
<uptodate property="bootstrap-ivy.uptodate"
srcfile="${ivyDir}/ivy.jar"
targetfile="${ivyDir}/bootstrap-ivy.complete"/>
</target>
<target name="copy-ivy" if="copy-ivy.available" depends="check-copy-ivy">
<copy file=".ivycache/org.apache.ivy/ivy/jars/ivy-${ivyVersion}.jar"
toFile="${ivyDir}/ivy.jar"/>
</target>
<target name="check-copy-ivy">
<available property="copy-ivy.available"
file=".ivycache/org.apache.ivy/ivy/jars/ivy-${ivyVersion}.jar"/>
</target>
<target name="download-ivy" unless="download-ivy.complete" depends="check-download-ivy">
<get src="${mavenUrl}org/apache/ivy/ivy/${ivyVersion}/ivy-${ivyVersion}.jar"
dest="${ivyDir}/ivy.jar"/>
</target>
<target name="check-download-ivy">
<available property="download-ivy.complete" file="${ivyDir}/ivy.jar"/>
</target>
<!-- javadoc for third party libraries -->
<target name="ivy-javadoc" depends="ivy" description="build javadoc for ivy-managed libraries">
<property name="ivyJavadocDir" location="${ivyDir}/javadoc"/>
<property name="ivyJavadocDest" location="build/ivy-javadoc"/>
<delete dir="${ivyJavadocDest}"/>
<macrodef name="unjarJavadoc">
<attribute name="jarName" description="The name of the jar file (minus the .jar)"/>
<sequential>
<mkdir dir="${ivyJavadocDest}/@{jarName}"/>
<unzip dest="${ivyJavadocDest}/@{jarName}"
src="${ivyJavadocDir}/@{jarName}.jar">
</unzip>
</sequential>
</macrodef>
<!-- Remember to add the appropriate declaration to ivy.xml and index.html -->
<unjarJavadoc jarName="jackson-core-2.5.3-javadoc"/>
<unjarJavadoc jarName="jackson-databind-2.5.3-javadoc"/>
<unjarJavadoc jarName="junit-4.12-javadoc"/>
</target>
</project>