PageRenderTime 995ms CodeModel.GetById 968ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 1ms

/build.xml

http://jmxtrans.googlecode.com/
XML | 329 lines | 281 code | 42 blank | 6 comment | 0 complexity | bb80502ae0430284efb12d57bd771f92 MD5 | raw file
  1<?xml version="1.0"?>
  2
  3<!--
  4    Build file for jmxtrans.
  5-->
  6<project name="jmxtrans" default="jar" basedir=".">
  7
  8    <property name="name" value="${ant.project.name}" />
  9    <property name="base.dir" location="." />
 10
 11    <property file="user.properties" />
 12    <property file="${user.home}/build.properties" />
 13    <property file="jar.properties"/>
 14    <property name="alexandria.home" value="${base.dir}" />
 15    <property file="${alexandria.home}/jar.properties" />
 16    <property file="build.credentials.properties" />
 17
 18    <property name="target.dir" location="target" />
 19    <property name="build.dir" location="${target.dir}" />
 20    <property name="build.classes.dir" location="${build.dir}/classes" />
 21    <property name="build.javadoc.dir" location="${build.dir}/javadoc" />
 22    <property name="build.jar.file" location="${build.dir}/${name}.jar" />
 23
 24    <property name="javadoc.dir" value="javadoc" />
 25    <property name="lib.dir" location="lib" />
 26    <property name="src.dir" location="src" />
 27
 28    <tstamp>
 29        <format property="NOW" pattern="yyyyMMdd-hh:mm:ss" />
 30        <!-- Wed, 19 Jan 2011 18:19:37 -0800 -->
 31        <format property="PROPER_NOW" pattern="E, dd MMM yyyy hh:mm:ss ZZ" />
 32        <format property="YEAR" pattern="yyyy" />
 33    </tstamp>
 34
 35    <typedef resource="com/googlecode/sweetened/sweetened.xml" classpath="${alexandria.home}/${sweetened.jar}:${alexandria.home}/${svnkit.jar}" />
 36    <sweetenedVersion />
 37
 38    <taskdef resource="net/sf/antcontrib/antlib.xml">
 39        <classpath>
 40            <pathelement location="${alexandria.home}/${ant-contrib.jar}"/>
 41        </classpath>
 42    </taskdef>
 43
 44    <spath id="sweetened.classpath">
 45        <sfilelist dir="${alexandria.home}">
 46            <sfile name="${commons-cli.jar}" scope="compile" src="${alexandria.home}/${commons-cli.src}" />
 47            <sfile name="${commons-codec.jar}" scope="compile" src="${alexandria.home}/${commons-codec.src}" />
 48            <sfile name="${commons-io.jar}" scope="compile" src="${alexandria.home}/${commons-io.src}" />
 49            <sfile name="${commons-lang.jar}" scope="compile" src="${alexandria.home}/${commons-lang.src}" />
 50            <sfile name="${commons-logging.jar}" scope="compile" src="${alexandria.home}/${commons-logging.src}" />
 51            <sfile name="${commons-pool.jar}" scope="compile" src="${alexandria.home}/${commons-pool.src}" />
 52            <sfile name="${jackson-core.jar}" scope="compile" src="${alexandria.home}/${jackson.src}" />
 53            <sfile name="${jackson-mapper.jar}" scope="compile" src="${alexandria.home}/${jackson.src}" />
 54            <sfile name="${jpathwatch.jar}" scope="compile" />
 55            <sfile name="${jrobin.jar}" scope="compile" src="${alexandria.home}/${jrobin.src}" />
 56            <sfile name="${junit.jar}" scope="unit" src="${alexandria.home}/${junit.src}" />
 57            <sfile name="${log4j.jar}" scope="compile" src="${alexandria.home}/${log4j.src}" />
 58            <sfile name="${quartz.jar}" scope="compile" src="${alexandria.home}/${quartz.src}" />
 59            <sfile name="${slf4j-api.jar}" scope="compile" src="${alexandria.home}/${slf4j-api.src}" />
 60            <sfile name="${slf4j-log4j.jar}" scope="runtime" src="${alexandria.home}/${slf4j-log4j.src}" />
 61            <sfile name="${velocity.jar}" scope="compile" src="${alexandria.home}/${velocity.src}" />
 62        </sfilelist>
 63    </spath>
 64
 65    <spath id="javac.classpath" scope="compile" parent="sweetened.classpath" />
 66    <spath id="javadoc.classpath" scope="all" parent="sweetened.classpath" />
 67    <spath id="unit.classpath" scope="all" parent="sweetened.classpath" />
 68    <spath id="all.classpath" scope="all" parent="sweetened.classpath" />
 69
 70    <path id="run.classpath">
 71        <pathelement location="${build.classes.dir}" />
 72        <path refid="master.classpath" />
 73    </path>
 74
 75    <target name="init">
 76        <typedef resource="com/googlecode/svntask/svntask.xml">
 77            <classpath>
 78                <fileset dir="${lib.dir}">
 79                    <include name="**/svnkit.jar"/>
 80                    <include name="**/svntask.jar"/>
 81                </fileset>
 82            </classpath>
 83        </typedef>
 84
 85        <svn><info path="${basedir}" revisionProperty="revisionVersion" /></svn>
 86
 87        <taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpath="${lib.dir}/ant-googlecode-0.0.2.jar" name="gcupload"/>
 88
 89        <!--  A hack because svnant does not respect Ant's properties can't be overwritten rule. -->
 90        <property name="version" value="${revisionVersion}" />
 91        <property name="build.version" value="${revisionVersion}" />
 92
 93        <property name="build.dist.dir" location="${build.dir}/${ant.project.name}-${version}"/>
 94        <property name="build.dist.zip" location="${build.dir}/${ant.project.name}-${version}.zip"/>
 95    </target>
 96
 97    <target name="clean">
 98        <delete dir="${build.dir}" />
 99    </target>
100
101     <target name="classes" depends="init">
102        <mkdir dir="${build.classes.dir}" />
103
104        <javac srcdir="${src.dir}"
105                destdir="${build.classes.dir}"
106                optimize="off"
107                deprecation="off"
108                debug="on"
109                debuglevel="lines,vars,source"
110                source="1.5"
111                target="1.5"
112                encoding="UTF-8"
113                verbose="off"
114                fork="false"
115                includeantruntime="false"
116            >
117            <classpath path="${toString:javac.classpath}"/>
118        </javac>
119    </target>
120
121    <target name="jar" depends="classes">
122        <sync todir="${build.classes.dir}">
123            <preserveintarget>
124                <include name="**/*.class"/>
125            </preserveintarget>
126            <fileset dir="src" defaultexcludes="yes">
127                <include name="**/*.xml"/>
128                <include name="**/*.properties"/>
129            </fileset>
130        </sync>
131        <jar destfile="${build.jar.file}" basedir="${build.classes.dir}">
132            <manifest>
133                <attribute name="Specification-Version" value="${version}" />
134                <attribute name="Implementation-Version" value="${TODAY}" />
135                <attribute name="Main-Class" value="com.googlecode.jmxtrans.JmxTransformer" />
136            </manifest>
137        </jar>
138    </target>
139
140    <target name="jar-all" depends="jar">
141        <zip destfile="${build.dir}/jmxtrans-all.jar">
142            <zipgroupfileset dir="lib">
143                <include name="*.jar" />
144                <exclude name="ant*.jar" />
145                <exclude name="*sources*.jar" />
146                <exclude name="*junit*.jar" />
147                <exclude name="*svn*.jar" />
148            </zipgroupfileset>
149            <zipgroupfileset dir="${build.dir}" includes="jmxtrans.jar"/>
150        </zip>
151    </target>
152
153    <target name="javadoc" depends="classes">
154        <javadoc
155            destdir="${build.javadoc.dir}"
156            packagenames="*"
157            author="true"
158            version="true"
159            Windowtitle="jmxlogger javadoc"
160        >
161            <fileset dir="${src.dir}">
162                <exclude name="**/*.xml" />
163                <exclude name="**/*.properties" />
164            </fileset>
165            <doctitle><![CDATA[<h1>jmxtrans</h1>]]></doctitle>
166            <bottom><![CDATA[<i>Copyright &#169; ${YEAR} Jon Stevens and a gang of pencils. All Rights Reserved. Build version: ${build.version}</i>]]></bottom>
167            <classpath path="${toString:javadoc.classpath}" />
168        </javadoc>
169
170        <sync todir="${javadoc.dir}" includeEmptyDirs="true">
171            <fileset dir="${build.javadoc.dir}" />
172            <preserveintarget>
173                <include name="**/.svn/**"/>
174            </preserveintarget>
175        </sync>
176    </target>
177
178    <target name="dist" depends="clean, jar, jar-all, javadoc">
179        <copy todir="${build.dist.dir}">
180            <fileset dir="${build.dir}">
181                <include name="javadoc/**" />
182            </fileset>
183
184            <fileset dir="${base.dir}">
185                <include name="*.xml" />
186                <include name="*.json" />
187                <include name="*.sh" />
188                <include name="README.html" />
189                <exclude name="test-*.json" />
190                <exclude name="*.log" />
191                <exclude name="build.credentials.properties" />
192            </fileset>
193
194            <fileset dir="${build.dir}">
195                <include name="*.jar" />
196            </fileset>
197        </copy>
198
199        <copy todir="${build.dist.dir}/lib">
200            <fileset dir="lib">
201                <include name="*.jar" />
202                <exclude name="*-sources.jar" />
203            </fileset>
204        </copy>
205
206        <copy todir="${build.dist.dir}/src">
207            <fileset dir="${base.dir}/src">
208                <include name="**" />
209            </fileset>
210        </copy>
211
212        <dirname property="build.dist.dir.dirname" file="${build.dist.dir}" />
213        <basename property="build.dist.dir.basename" file="${build.dist.dir}" />
214
215        <zip zipfile="${build.dist.zip}" basedir="${build.dist.dir.dirname}">
216            <include name="${build.dist.dir.basename}/**" />
217        </zip>
218    </target>
219
220    <target name="debian" depends="dist">
221        <filter token="PACKAGE" value="jmxtrans" />
222        <filter token="NOW" value="${NOW}" />
223        <filter token="PROPER_NOW" value="${PROPER_NOW}" />
224        <filter token="YEAR" value="${YEAR}" />
225        <filter token="FULL_VERSION" value="${sVersion}" />
226        <filter token="VERSION" value="${sVersionRevision}" />
227        <filter token="BRANCH_NAME" value="${sVersionBranchName}" />
228
229        <copy todir="${target.dir}/jmxtrans/debian" filtering="true">
230            <fileset dir="debian">
231                <include name="**"/>
232            </fileset>
233        </copy>
234        <unzip src="${build.dist.zip}" dest="${target.dir}/jmxtrans/debian/tmp/usr/share" />
235        <move todir="${target.dir}/jmxtrans/debian/tmp/usr/share/jmxtrans">
236            <fileset dir="${target.dir}/jmxtrans/debian/tmp/usr/share/jmxtrans-${sVersionRevision}">
237                <include name="**"/>
238            </fileset>
239        </move>
240        <chmod file="${target.dir}/jmxtrans/debian/rules" perm="ugo+rx"/>
241
242        <exec executable="/usr/bin/debuild" dir="${target.dir}/jmxtrans" failonerror="true">
243            <arg line="-b"/>
244        </exec>
245    </target>
246
247    <target name="rpm" depends="dist">
248
249        <copy todir="${target.dir}/jmxtrans/rpm" >
250            <fileset dir="rpm">
251                <include name="**"/>
252            </fileset>
253        </copy>
254
255        <mkdir dir="${target.dir}/jmxtrans/rpm/BUILD" />
256        <mkdir dir="${target.dir}/jmxtrans/rpm/RPMS" />
257        <mkdir dir="${target.dir}/jmxtrans/rpm/SRPMS" />
258        <mkdir dir="${target.dir}/jmxtrans/rpm/TEMP" />
259
260        <copy file="${build.dist.zip}" todir="${target.dir}/jmxtrans/rpm/SOURCES"/>
261
262        <exec executable="/usr/bin/rpmbuild" dir="${target.dir}/jmxtrans/rpm" failonerror="true">
263            <arg line="-ba --define='_topdir ${target.dir}/jmxtrans/rpm' --define='_tmppath ${target.dir}/jmxtrans/rpm/TEMP' --define='VERSION ${version}' --define='RELEASE 0' --define='JMXTRANS_SOURCE jmxtrans-${version}.zip' SPECS/jmxtrans.spec"/>
264        </exec>
265    </target>
266
267    <target name="upload" depends="init">
268        <gcupload projectname="${ant.project.name}"
269            userName="${gc.username}"
270            password="${gc.password}"
271            filename="${build.dist.zip}"
272            targetfilename="${build.dist.zip}"
273            summary="${ant.project.name} distribution"
274            labels="Featured, Type-Package, OpSys-All" />
275
276        <!-- hacky, but need both path to file and filename -->
277        <path id="file.deb">
278            <fileset dir="${target.dir}" includes="*.deb" />
279        </path>
280        <property name="file.deb.path" refid="file.deb" />
281        <pathconvert property="file.deb.target" targetos="unix">
282            <path>
283                <fileset dir="${target.dir}" includes="*.deb" />
284            </path>
285            <mapper type="flatten"/>
286        </pathconvert>
287
288        <gcupload projectname="${ant.project.name}"
289            userName="${gc.username}"
290            password="${gc.password}"
291            filename="${file.deb.path}"
292            targetfilename="${file.deb.target}"
293            summary="${ant.project.name} debian distribution"
294            labels="Featured, Type-Installer, OpSys-Linux, Debian" />
295    </target>
296
297    <target name=".eclipse" description="Generate eclipse project metadata">
298        <sweetenedClasspath file=".classpath">
299            <sweetenedBits refid="unit.classpath" />
300            <data>
301                <classpath>
302                    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
303                    <sweetenedEntries />
304                    <classpathentry kind="src" path="src"/>
305                    <classpathentry kind="src" path="test"/>
306                    <classpathentry kind="output" path="_eclipse"/>
307                </classpath>
308            </data>
309        </sweetenedClasspath>
310        <echoxml file=".project">
311            <projectDescription>
312                <name>${name}-${sVersionBranchName}</name>
313                <comment></comment>
314                <projects>
315                </projects>
316                <buildSpec>
317                    <buildCommand>
318                        <name>org.eclipse.jdt.core.javabuilder</name>
319                        <arguments>
320                        </arguments>
321                    </buildCommand>
322                </buildSpec>
323                <natures>
324                    <nature>org.eclipse.jdt.core.javanature</nature>
325                </natures>
326            </projectDescription>
327        </echoxml>
328    </target>
329</project>