Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
488 lines (421 sloc) 22.2 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="gora-common" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="name" value="${ant.project.name}" />
<property name="version" value="0.2-incubating" />
<property name="final.name" value="${ant.project.name}-${version}" />
<property name="year" value="2011" />
<property name="module.version.target" value="${version}" />
<property name="module.name" value="${ant.project.name}-${version}"/>
<!-- Load all the default properties, and any the user wants -->
<!-- to contribute (without having to type -D or edit this file -->
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
<property file="${basedir}/default.properties" />
<property name="project.dir" value="${basedir}/.."/>
<property name="lib.dir" value="${basedir}/lib" />
<property name="lib-ext.dir" value="${basedir}/lib-ext" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="src.dir" value="${basedir}/src/main/java" />
<property name="conf.dir" value="${basedir}/conf" />
<property name="jar.file" value="${build.dir}/${module.name}.jar" />
<property name="job.file" value="${build.dir}/${module.name}.job" />
<property name="dist.dir" value="${build.dir}/${name}" />
<property name="examples.src.dir" value="${basedir}/src/examples/java" />
<property name="examples.build.dir" value="${build.dir}/examples" />
<property name="examples.build.classes.dir" value="${examples.build.dir}/classes" />
<property name="test.src.dir" value="${basedir}/src/test/java" />
<property name="test.conf.dir" value="${basedir}/src/test/conf" />
<property name="test.build.dir" value="${build.dir}/test" />
<property name="test.build.data" value="${test.build.dir}/data" />
<property name="test.build.classes.dir" value="${test.build.dir}/classes" />
<property name="test.jar.file" value="${build.dir}/${ant.project.name}-test-${version}.jar" />
<property name="test.lib.dir" value="${basedir}/src/test/lib"/>
<property name="test.log.dir" value="${test.build.dir}/logs"/>
<property name="test.include" value="Test*"/>
<property name="test.junit.output" value="no"/>
<property name="test.junit.timeout" value="3600000"/>
<property name="test.junit.output.format" value="plain"/>
<property name="test.junit.fork.mode" value="perTest" />
<property name="test.junit.printsummary" value="yes" />
<property name="test.junit.haltonfailure" value="no" />
<property name="test.junit.maxmemory" value="512m" />
<property name="build.encoding" value="UTF-8" />
<property name="javac.debug" value="on" />
<property name="javac.optimize" value="on" />
<property name="javac.deprecation" value="off" />
<property name="javac.version" value="1.6" />
<!-- Include project's build file -->
<import file="${project.dir}/build.xml"/>
<!--<ivy:settings file="${basedir}/ivy/ivysettings.xml" />-->
<!-- ====================================================== -->
<!-- path: classpath -->
<!-- ====================================================== -->
<path id="classpath">
<pathelement location="${build.classes.dir}"/>
<pathelement location="${conf.dir}"/>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- the unit test classpath: uses test.src.dir for configuration -->
<path id="test.classpath">
<pathelement location="${examples.build.classes.dir}"/>
<pathelement location="${conf.dir}"/>
<pathelement location="${test.build.classes.dir}" />
<pathelement location="${test.src.dir}"/>
<pathelement location="${build.dir}"/>
<pathelement location="${test.conf.dir}"/>
<path refid="classpath"/>
</path>
<!-- ====================================================== -->
<!-- target: init -->
<!-- ====================================================== -->
<target name="init" depends="ivy-init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${examples.build.dir}"/>
<mkdir dir="${examples.build.classes.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${test.build.classes.dir}"/>
<copy todir="${conf.dir}" verbose="true" failonerror="false">
<fileset dir="${conf.dir}" includes="**/*.template"/>
<mapper type="glob" from="*.template" to="*"/>
</copy>
<antcall target="init-module"/>
</target>
<target name="init-module" description="Modules can override this for post-init scripting"/>
<!-- ====================================================== -->
<!-- target: compile -->
<!-- ====================================================== -->
<target name="compile" depends="init, resolve">
<javac
encoding="${build.encoding}"
srcdir="${src.dir}"
includes="**/*.java"
destdir="${build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="yes">
<classpath refid="classpath"/>
</javac>
<antcall target="compile-module"/>
</target>
<target name="compile-module" description="Modules can override this for post-compile scripting"/>
<!-- ====================================================== -->
<!-- target: compile-examples -->
<!-- ====================================================== -->
<target name="compile-examples" depends="compile">
<javac
encoding="${build.encoding}"
srcdir="${examples.src.dir}"
includes="**/*.java"
destdir="${examples.build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="yes">
<classpath refid="classpath"/>
</javac>
</target>
<!-- ================================================================== -->
<!-- target: compile-test -->
<!-- ================================================================== -->
<target name="compile-test" depends="compile-examples, resolve-test">
<javac
encoding="${build.encoding}"
srcdir="${test.src.dir}"
includes="**/*.java"
destdir="${test.build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="yes">
<classpath refid="test.classpath"/>
</javac>
</target>
<!-- ================================================================== -->
<!-- target: jar -->
<!-- ================================================================== -->
<target name="jar" depends="compile, version" description="--> make a jar file for this project">
<jar destfile="${jar.file}">
<fileset dir="${build.classes.dir}" />
<!--<zipfileset dir="${conf.dir}" excludes="*.template"/>-->
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Version" value="${version}" />
</manifest>
<metainf dir="${project.dir}" includes="LICENSE.txt,NOTICE.txt" />
</jar>
</target>
<!-- ================================================================== -->
<!-- target: test-jar -->
<!-- ================================================================== -->
<target name="test-jar" depends="version, compile-test, jar" description="--> make a jar file for this project">
<jar destfile="${test.jar.file}">
<fileset dir="${examples.build.classes.dir}" />
<fileset dir="${test.build.classes.dir}" />
<fileset dir="${test.conf.dir}" excludes="*.template" />
<!--<zipfileset dir="${conf.dir}" excludes="*.template"/>-->
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Version" value="${version}" />
</manifest>
<metainf dir="${project.dir}" includes="LICENSE.txt,NOTICE.txt" />
</jar>
</target>
<target name="jar-snapshot" description="copies the jar files to append timestamp to artifact name">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<copy file="${jar.file}" tofile="${build.dir}/${module.name}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${module.name}-${now}.jar"/>
</target>
<target name="test-jar-snapshot" description="copies the jar files to append timestamp to artifact name">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<copy file="${jar.file}" tofile="${build.dir}/${module.name}-${now}.jar"/>
<copy file="${test.jar.file}" tofile="${build.dir}/${ant.project.name}-test-${version}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${module.name}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${ant.project.name}-test-${version}-${now}.jar"/>
</target>
<!-- ================================================================== -->
<!-- target: job -->
<!-- ================================================================== -->
<target name="job" depends="compile" description="--> make a job file for running on hadoop">
<jar destfile="${job.file}">
<fileset dir="${build.classes.dir}" />
<zipfileset dir="conf" excludes="*.template" />
<zipfileset dir="${lib.dir}" prefix="lib" includes="**/*.jar" excludes="hadoop-*.jar" followsymlinks="true"/>
<zipfileset dir="${lib.dir}" prefix="lib" includes="hadoop-gpl-compression*.jar" followsymlinks="true"/>
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version}" />
</manifest>
<metainf dir="${project.dir}" includes="LICENSE.txt,NOTICE.txt" />
</jar>
</target>
<!-- ================================================================== -->
<!-- target: test -->
<!-- ================================================================== -->
<target name="test" depends="compile-test" description="Run core unit tests">
<delete dir="${test.build.data}"/>
<mkdir dir="${test.build.data}"/>
<delete dir="${test.log.dir}"/>
<mkdir dir="${test.log.dir}"/>
<junit showoutput="${test.junit.output}"
printsummary="${test.junit.printsummary}"
haltonfailure="${test.junit.haltonfailure}"
fork="yes"
forkmode="${test.junit.fork.mode}"
maxmemory="${test.junit.maxmemory}"
dir="${basedir}" timeout="${test.junit.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="hadoop.log.dir" value="${test.log.dir}"/>
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.build.dir}" unless="testcase">
<fileset dir="${test.src.dir}"
includes="**/${test.include}.java"
excludes="**/${test.exclude}.java" />
</batchtest>
<batchtest todir="${test.build.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<!-- ================================================================== -->
<!-- D I S T R I B U T I O N -->
<!-- ================================================================== -->
<target name="package" depends="compile, jar, test-jar"
description="Build distribution">
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/lib"/>
<copy todir="${dist.dir}/lib" includeEmptyDirs="false">
<fileset dir="lib"/>
</copy>
<copy todir="${dist.dir}">
<fileset file="${jar.file}"/>
<fileset file="${test.jar.file}"/>
</copy>
<copy todir="${dist.dir}/conf">
<fileset dir="${conf.dir}" excludes="**/*.template"/>
</copy>
<copy todir="${dist.dir}/ivy">
<fileset dir="ivy"/>
</copy>
<copy todir="${dist.dir}">
<fileset dir=".">
<include name="*.txt" />
</fileset>
</copy>
<copy todir="${dist.dir}/src" includeEmptyDirs="true">
<fileset dir="src" excludes="**/*.template"/>
</copy>
<copy todir="${dist.dir}/" file="build.xml"/>
</target>
<!-- ================================================================== -->
<!-- Make release tarball -->
<!-- ================================================================== -->
<target name="tar" depends="package" description="Make release tarball">
<macro_tar param.destfile="${build.dir}/${final.name}.tar.gz">
<param.listofitems>
<tarfileset dir="${build.dir}" mode="664">
<exclude name="${name}/bin/*" />
<include name="${name}/**" />
</tarfileset>
<tarfileset dir="${build.dir}" mode="755">
<include name="${name}/bin/*" />
</tarfileset>
</param.listofitems>
</macro_tar>
</target>
<!-- ================================================================== -->
<!-- target: resolve -->
<!-- ================================================================== -->
<target name="resolve" depends="clean-lib" description="--> resolve and retrieve dependencies with ivy">
<mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
<!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
<ivy:resolve file="${ivy.dir}/${ivy.file}" conf="compile" log="download-only"/>
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision](-[classifier]).[ext]" symlink="true" log="quiet" conf="compile"/>
<!-- copy the libs in lib-ext, which are not ivy enabled, should change in the future -->
<copy todir="${lib.dir}/" failonerror="false">
<fileset dir="${lib-ext.dir}" includes="**/*.jar"/>
</copy>
</target>
<!-- ================================================================== -->
<!-- target: resolve-test -->
<!-- ================================================================== -->
<target name="resolve-test" depends="clean-lib" description="--> resolve and retrieve dependencies with ivy">
<mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
<!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
<ivy:resolve file="${ivy.dir}/${ivy.file}" conf="test" log="download-only"/>
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" symlink="true" log="quiet" conf="test"/>
<!-- copy the libs in lib-ext, which are not ivy enabled, should change in the future -->
<copy todir="${lib.dir}/" failonerror="false">
<fileset dir="${lib-ext.dir}" includes="**/*.jar"/>
</copy>
</target>
<!-- ================================================================== -->
<!-- target: report -->
<!-- ================================================================== -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: ivy-new-version -->
<!-- ================================================================== -->
<target name="ivy-new-version" depends="" 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.dir}/${ivy.file}" />
<ivy:buildnumber organisation="${ivy.organisation}" module="${ivy.module}"
revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
</target>
<!-- ================================================================== -->
<!-- target: local-version -->
<!-- ================================================================== -->
<target name="local-version">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
</target>
<!-- ================================================================== -->
<!-- target: version -->
<!-- ================================================================== -->
<target name="version" depends="ivy-new-version">
<!-- create version file in classpath for later inclusion in jar -->
<mkdir dir="${build.classes.dir}"/>
<echo message="version=${ivy.new.revision}" file="${build.classes.dir}/${ant.project.name}.properties" append="false" />
<!-- load generated version properties file -->
<property file="${classes.dir}/${ant.project.name}.properties" />
</target>
<!-- ================================================================== -->
<!-- target: publish -->
<!-- ================================================================== -->
<target name="publish" depends="version, clean-build, jar" description="--> publish this project in the ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
resolver="shared"
pubrevision="${version}"
status="release"/>
<echo message="project ${ant.project.name} released with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: publish-local -->
<!-- ================================================================== -->
<target name="publish-local" depends="local-version, jar" description="--> publish this project in the local ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact]-${version}.[ext]"
resolver="local"
pubrevision="${version}"
pubdate="${now}"
status="integration"
forcedeliver="true"
overwrite="true"
conf="compile"
/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: publish-local-test -->
<!-- ================================================================== -->
<target name="publish-local-test" depends="local-version, test-jar" description="--> publish this project in the local ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact]-${version}.[ext]"
resolver="local"
pubrevision="${version}"
pubdate="${now}"
status="integration"
forcedeliver="true"
overwrite="true"
/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: clean-local -->
<!-- ================================================================== -->
<target name="clean-local" depends="" description="--> cleans the local repository for the current module">
<ivy:info file="${ivy.dir}/${ivy.file}" />
<delete dir="${ivy.local.default.root}/${ivy.organisation}/${ivy.module}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean-lib -->
<!-- ================================================================== -->
<target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
<delete includeemptydirs="true" dir="${lib.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean-build -->
<!-- ================================================================== -->
<target name="clean-build" description="--> clean the project built files">
<delete includeemptydirs="true" dir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean -->
<!-- ================================================================== -->
<target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
</project>
Jump to Line
Something went wrong with that request. Please try again.