blob: 4e54d1dc47204e2e62ef63ce1402bc8f8edb50ff [file] [log] [blame]
Richard S. Hall85bafab2009-07-13 13:25:46 +00001<?xml version="1.0">
2<!--
3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
18 under the License.
19-->
20<project name="common"
21 xmlns:ivy="antlib:org.apache.ivy.ant">
22 <!-- a sample common ant build file, used for ivy multi-project tutorial
23 feel free to copy and adapt it to your own needs
24 Note that the only targets specific to ivy are:
25 load-ivy
26 resolve
27 report
28 ivy-new-version
29 publish
30 publish-local
31
32 All other targets are usual ant based targets, which could have been written
33 in a build not depending at all on ivy:
34 resolve constructs a lib directory based upon ivy dependencies, and then the lib dir
35 is used as in any classical ant build
36 -->
37
38 <property file="${common.dir}/build.properties"/>
39
40 <property name="ivy.jar.dir" value="/opt/apache-ivy-2.0.0-rc2" />
41 <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-2.0.0-rc2.jar" />
42 <property name="sigil-ivy-plugin.jar" value="${common.dir}/../../../target/sigil-ivy-plugin.jar"/>
43
44 <target name="hello">
45 <echo message="${ant.project.name}"/>
46 </target>
47
48 <!-- =================================
49 target: load-ivy
50 this target is not necessary if you put ivy.jar in your ant lib directory
51 if you already have ivy 2.0 in your ant lib, you can simply remove this
52 target
53 ================================= -->
54 <path id="ivy.lib.path">
55 <path location="${ivy.jar.file}"/>
56 <path location="${sigil-ivy-plugin.jar}"/>
57 <!--
58 <path location="${user.home}/src/tmp/ivy/build/ivy.jar"/>
59 -->
60 </path>
61
62 <target name="load-ivy" depends="ivy-taskdefs">
63 <ivy:settings file="${common.dir}/ivysettings.xml" />
64 </target>
65
66 <target name="ivy-taskdefs" unless="ivy.loaded">
67 <property name="ivy.loaded" value="true"/>
68 <echo message="Loading Ivy ..."/>
69 <!--
70 <taskdef resource="org/apache/ivy/ant/antlib.xml"
71 uri="antlib:org.apache.ivy.ant" classpath="${ivy.jar.file}"/>
72 -->
73 <taskdef resource="org/apache/ivy/ant/antlib.xml"
74 uri="antlib:org.apache.ivy.ant"
75 loaderRef="ivyLoader"
76 classpath="${ivy.jar.file}"/>
77
78 <taskdef name="sigil.bundle"
79 classname="org.cauldron.bld.ant.BundleTask"
80 classpath="${sigil-ivy-plugin.jar}:${bndlib.jar}"/>
81 </target>
82
83 <path id="lib.path.id">
84 <fileset dir="${lib.dir}" />
85 </path>
86
87 <path id="run.path.id">
88 <path refid="lib.path.id" />
89 <path location="${classes.dir}" />
90 </path>
91
92
93 <!-- setup ivy default configuration with some custom info -->
94 <property name="ivy.local.default.root" value="${repository.dir}/local"/>
95 <property name="ivy.shared.default.root" value="${repository.dir}/shared"/>
96
97 <!-- here is how we would have configured ivy if we had our own ivysettings file
98 <ivy:settings file="${common.dir}/ivysettings.xml" />
99 -->
100
101
102 <!-- =================================
103 target: resolve
104 ================================= -->
105 <target name="resolve" depends="clean-lib, load-ivy" description="--> resolve and retrieve dependencies with ivy">
106 <mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
107
108 <!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
109 <ivy:resolve file="${ivy.file}"/>
110 <ivy:retrieve pattern="${lib.dir}/[artifact].[ext]" />
111 </target>
112
113 <!-- =================================
114 target: report
115 ================================= -->
116 <target name="report" depends="resolve" description="--> generates a report of dependencies">
117 <ivy:report todir="${build.dir}"/>
118 </target>
119
120 <!-- =================================
121 target: compile
122 ================================= -->
123 <target name="compile" depends="resolve" description="--> compile the project">
124 <mkdir dir="${classes.dir}" />
125 <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" debug="true" />
126 </target>
127
128 <!-- =================================
129 target: run
130 ================================= -->
131 <target name="run" depends="version, compile" description="--> compile and run the project">
132 <java classpathref="run.path.id" classname="${main.class.name}"/>
133 </target>
134
135 <target name="ivy-new-version" depends="load-ivy" unless="ivy.new.revision">
136 <!-- default module version prefix value -->
137 <property name="module.version.prefix" value="${module.version.target}-dev-b" />
138
139 <!-- asks to ivy an available version number -->
140 <ivy:info file="${ivy.file}" />
141 <ivy:buildnumber
142 organisation="${ivy.organisation}" module="${ivy.module}"
143 revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
144 </target>
145
146 <target name="local-version">
147 <tstamp>
148 <format property="now" pattern="yyyyMMddHHmmss"/>
149 </tstamp>
150 <property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
151 </target>
152
153 <target name="version" depends="ivy-new-version">
154 <!-- create version file in classpath for later inclusion in jar -->
155 <mkdir dir="${classes.dir}"/>
156 <echo message="version=${ivy.new.revision}" file="${classes.dir}/${ant.project.name}.properties" append="false" />
157
158 <!-- load generated version properties file -->
159 <property file="${classes.dir}/${ant.project.name}.properties" />
160 </target>
161
162 <!-- =================================
163 target: jar
164 ================================= -->
165 <target name="jar" depends="version, compile" description="--> make a jar file for this project">
166
167 <!--
168 <jar destfile="${jar.file}">
169 <fileset dir="${classes.dir}" />
170 <manifest>
171 <attribute name="Built-By" value="${user.name}"/>
172 <attribute name="Build-Version" value="${version}" />
173 </manifest>
174 </jar>
175 -->
176
177 <sigil.bundle destpattern="${build.dir}/[id].[ext]"
178 classpathref="run.path.id"/>
179 </target>
180
181 <!-- =================================
182 target: publish
183 ================================= -->
184 <target name="publish" depends="clean-build, jar" description="--> publish this project in the ivy repository">
185 <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
186 resolver="shared"
187 pubrevision="${version}"
188 status="release"
189 />
190 <echo message="project ${ant.project.name} released with version ${version}" />
191 </target>
192
193 <!-- =================================
194 target: publish-local
195 ================================= -->
196 <target name="publish-local" depends="local-version, jar" description="--> publish this project in the local ivy repository">
197 <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
198 resolver="local"
199 pubrevision="${version}"
200 pubdate="${now}"
201 status="integration"
202 forcedeliver="true"
203 />
204 <echo message="project ${ant.project.name} published locally with version ${version}" />
205 </target>
206
207 <!-- =================================
208 target: clean-local
209 ================================= -->
210 <target name="clean-local" description="--> cleans the local repository for the current module">
211 <delete dir="${ivy.local.default.root}/${ant.project.name}"/>
212 </target>
213
214 <!-- =================================
215 target: clean-lib
216 ================================= -->
217 <target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
218 <delete includeemptydirs="true" dir="${lib.dir}"/>
219 </target>
220
221 <!-- =================================
222 target: clean-build
223 ================================= -->
224 <target name="clean-build" description="--> clean the project built files">
225 <delete includeemptydirs="true" dir="${build.dir}"/>
226 </target>
227
228 <!-- =================================
229 target: clean
230 ================================= -->
231 <target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
232</project>