-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathivyBuild.xml
170 lines (142 loc) · 7.37 KB
/
ivyBuild.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="UTF-8"?>
<project name="ivyBuild" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="${commonBuild.dir}/commonBuild.properties" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-${ivy.install.version}.jar" />
<!-- setup ivy default configuration with some custom info -->
<property name="ivy.local.default.root" value="${repository.dir}/local"/>
<property name="ivy.shared.default.root" value="${repository.dir}/shared"/>
<target name="init-ivy">
<available property="ivy.installed" value="true" file="${ivy.jar.file}" type="file" />
</target>
<target name="download-ivy" depends="init-ivy" unless="ivy.installed">
<mkdir dir="${ivy.jar.dir}" />
<echo message="Installing ivy..." />
<get src="${central.repo}/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" />
</target>
<target name="load-ivy" depends="init-ivy,download-ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
<ivy:settings file="${commonBuild.dir}/ivysettings.xml"/>
</target>
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="load-ivy" description="-> resolve and retrieve dependencies with ivy">
<ivy:resolve file="${ivy.file}" log="download-only"/>
<ivy:retrieve log="quiet" />
<ivy:cachepath pathid="compile.path" conf="compile" />
<pathconvert property="compile.lib" refid="compile.path"></pathconvert>
<ivy:cachepath pathid="war.path" conf="war" />
<pathconvert property="war.lib" refid="war.path"></pathconvert>
<ivy:cachepath pathid="test.path" conf="test" />
<pathconvert property="test.lib" refid="test.path"></pathconvert>
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="-> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<target name="ivy-new-version" depends="load-ivy" unless="ivy.new.revision">
<!-- default module version prefix value -->
<property name="module.version.prefix" value="${module.version.target}-dev-b" />
<!-- asks to ivy an available version number -->
<ivy:info file="${ivy.file}" />
<ivy:buildnumber
organisation="${ivy.organisation}" module="${ivy.module}"
revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
</target>
<target name="local-version" depends="resolve">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
<property name="version" value="${ivy.new.revision}"/>
</target>
<target name="version" depends="ivy-new-version">
<!-- create version file in classpath for later inclusion in jar -->
<mkdir dir="${classes.dir}"/>
<echo message="version=${ivy.new.revision}" file="${classes.dir}/${ant.project.name}.properties" append="false" />
<!-- load generated version properties file -->
<property file="${classes.dir}/${ant.project.name}.properties" />
</target>
<!-- =================================
target: build. Implementing projects expected to override this target and create a war/jar
================================= -->
<target name="build" description="-> make a jar/war/ear/etc file for this project">
</target>
<!-- =================================
target: publish
================================= -->
<target name="publish" depends="clean-build, build, version" description="-> publish this project in the shared ivy repository">
<ivy:publish artifactspattern="${stage.dir}/[artifact].[ext]"
resolver="shared"
pubrevision="${version}"
status="release"
publishivy="false"
overwrite="true"
/>
<echo message="project ${ant.project.name} released with version ${version}" />
</target>
<!-- =================================
target: publish-local
================================= -->
<target name="publish-local" depends="build, local-version" description="-> publish this project in the local ivy repository">
<ivy:publish artifactspattern="${stage.dir}/[artifact].[ext]"
resolver="local"
pubrevision="${version}"
pubdate="${now}"
status="integration"
forcedeliver="true"
/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<!-- =================================
target: clean-local
================================= -->
<target name="clean-local" description="-> cleans the local repository for the current module">
<delete dir="${ivy.local.default.root}/${ant.project.name}"/>
</target>
<!-- =================================
target: clean-lib
================================= -->
<target name="clean-lib" description="-> clean the project libraries (lib) directory">
<delete includeemptydirs="true" dir="${lib.dir}"/>
</target>
<!-- =================================
target: clean-build
================================= -->
<target name="clean-build" description="-> clean the built project file directories">
<delete includeemptydirs="true" dir="${stage.dir}"/>
<delete includeemptydirs="true" dir="${test.output.dir}"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" depends="clean-build, clean-lib" description="-> clean the project" />
<!-- =================================
target: uberclean
================================= -->
<target name="uberclean" depends="clean, load-ivy" description="delete the ivy local repository, ivy cache, and project build">
<delete dir="${ivy.local.default.root}" />
<ivy:cleancache />
<echo>Successfully cleaned the ivy local repository, cache, and project build</echo>
</target>
<target name="usage">
<echo>Common ivy build file for all projects</echo>
<echo>Implementing projects are expected to define their own "build" target to build an archive file, either a jar, war, ear, etc</echo>
<echo>"publish" - publish archives to the shared company repository</echo>
<echo>"publish-local" - publish archives to your local repository</echo>
<echo>"clean-build" - clean the built project file directories</echo>
<echo>"clean-lib" - clean the project libraries (lib) directories</echo>
<echo>"clean-local" - cleans the local repository for the current module</echo>
<echo>"clean" - calls the "clean-build" and "clean-lib" targets to clean the dependencies and build for the project</echo>
<echo>"uberclean" - delete the ivy local repository, ivy cache, and project build</echo>
</target>
</project>