Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

623 lines (529 sloc) 21.915 kb
<project name="bixo-core" default="compile">
<!--
Copyright 2009-2012 Scale Unlimited
Licensed 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.
-->
<property name="root.dir" value="${basedir}" />
<property file="${root.dir}/build.properties" />
<!-- ================================================================== -->
<!-- General cleaning sources -->
<!-- ================================================================== -->
<target name="clean" description="--> clean the project">
<echo>cleaning ${ant.project.name}</echo>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build.dir}" excludes="classes-*-eclipse/" />
</delete>
</target>
<target name="clean-eclipse-build">
<echo>cleaning ${ant.project.name}</echo>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build.dir}" includes="classes-*-eclipse/" />
</delete>
</target>
<!-- ================================================================== -->
<!-- Maven -->
<!-- ================================================================== -->
<target name="mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
<path id="maven.ant.tasks.classpath" path="${lib.dir}/maven-ant-tasks-2.0.10.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
classpathref="maven.ant.tasks.classpath"/>
<condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
<isset property="maven.repo.local"/>
</condition>
<echo>maven.repo.local=${maven.repo.local}</echo>
<artifact:localRepository id="local.repository" path="${maven.repo.local}"/>
<artifact:pom file="pom.xml" id="maven.project"/>
<artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
</target>
<target name="mvn-install" xmlns:artifact="urn:maven-artifact-ant" depends="mvn-init">
<artifact:install file="${build.dir}/${jar.name}">
<pom refid="maven.project"/>
</artifact:install>
</target>
<target name="mvn-deploy" xmlns:artifact="urn:maven-artifact-ant" depends="mvn-init">
<fail unless="repoUrl">
You must specify the repoUrl (-DrepoUrl=xxx) when deploying!
</fail>
<artifact:deploy file="${build.dir}/${jar.name}">
<remoteRepository url="${repoUrl}"/>
<pom refid="maven.project"/>
</artifact:deploy>
</target>
<!-- ================================================================== -->
<!-- Build sources -->
<!-- ================================================================== -->
<target name="compile"
depends="mvn-init"
description="--> compile main classes">
<mkdir dir="${build.dir.main-classes}" />
<javac encoding="${build.encoding}"
srcdir="${main.src.dir}"
includes="**/*.java"
destdir="${build.dir.main-classes}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="false">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="compile.classpath" />
</javac>
</target>
<!-- ================================================================== -->
<!-- Unit Tests -->
<!-- ================================================================== -->
<target name="compile-test" depends="compile">
<echo>*** Building Unit Tests Sources ***</echo>
<mkdir dir="${build.dir.test-classes}" />
<path id="test.path">
<pathelement location="${build.dir.main-classes}" />
</path>
<javac encoding="${build.encoding}"
srcdir="${test.src.dir}"
includes="**/*.java"
destdir="${build.dir.test-classes}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="false">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="test.classpath" />
<classpath refid="test.path" />
</javac>
</target>
<target name="test"
depends="compile-test"
description="--> run unit tests">
<delete dir="${build.dir.test-reports}" />
<mkdir dir="${build.dir.test-reports}" />
<junit showoutput="false"
printsummary="yes"
haltonfailure="no"
fork="yes"
maxmemory="256m"
dir="${basedir}"
errorProperty="tests.failed"
failureProperty="tests.failed">
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${reports.dir}/bixo_coverage.ser" />
<classpath>
<pathelement location="${instrumented.dir}" />
<pathelement location="${build.dir.main-classes}" />
<pathelement location="${build.dir.test-classes}" />
<pathelement location="${test.res.dir}" />
<path refid="test.classpath" />
</classpath>
<formatter type="plain" />
<batchtest fork="yes"
todir="${build.dir.test-reports}"
unless="longrunning">
<fileset dir="${test.src.dir}">
<include name="**/*Test.java" />
<exclude name="**/Abstract*.java" />
<exclude name="**/*LRTest.java" />
</fileset>
</batchtest>
<batchtest fork="yes"
todir="${build.dir.test-reports}"
if="longrunning">
<fileset dir="${test.src.dir}">
<include name="**/*LRTest.java" />
<exclude name="**/Abstract*.java" />
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<target name="test-lr"
unless="skip.lr"
description="--> run unit tests that take a long time">
<antcall target="test">
<param name="longrunning" value="true" />
</antcall>
</target>
<!-- ================================================================== -->
<!-- Integration Tests -->
<!-- ================================================================== -->
<target name="compile-integration-test" depends="compile">
<echo>*** Building Integration Tests Sources ***</echo>
<mkdir dir="${build.dir.it-classes}" />
<path id="test.path">
<pathelement location="${build.dir.main-classes}" />
<pathelement location="${build.dir.test-classes}" />
<pathelement location="${build.dir.it-classes}" />
</path>
<javac encoding="${build.encoding}"
srcdir="${it.src.dir}"
includes="**/*.java"
destdir="${build.dir.it-classes}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}"
includeAntRuntime="false">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="test.classpath" />
<classpath refid="test.path" />
</javac>
</target>
<target name="test-it"
unless="skip.it"
depends="compile, compile-test, compile-integration-test"
description="--> run integration tests">
<delete dir="${build.dir.it-reports}" />
<mkdir dir="${build.dir.it-reports}" />
<junit showoutput="no"
printsummary="yes"
haltonfailure="no"
fork="yes"
maxmemory="256m"
dir="${basedir}"
errorProperty="tests.failed"
failureProperty="tests.failed">
<classpath>
<pathelement location="${build.dir.main-classes}" />
<pathelement location="${build.dir.test-classes}" />
<pathelement location="${build.dir.it-classes}" />
<pathelement location="${main.res.dir}" />
<pathelement location="${it.res.dir}" />
<path refid="test.classpath" />
<fileset file="${build.dir}/${ant.project.name}.jar" />
</classpath>
<formatter type="plain" />
<batchtest fork="yes" todir="${build.dir.it-reports}">
<fileset dir="${it.src.dir}">
<include name="**/*Test*.java" unless="testcase" />
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<!-- ================================================================== -->
<!-- Build jar -->
<!-- ================================================================== -->
<target name="jar"
depends="test, test-lr, test-it"
description="--> create the bixo-core jar with no dependencies">
<tstamp>
<format property="timestamp" pattern="MMM dd yyyy, HH:mm:ss" />
</tstamp>
<jar jarfile="${build.dir}/${jar.name}"
basedir="${build.dir.main-classes}">
<manifest>
<section name="bixo">
<attribute name="Implementation-Vendor"
value="openbixo.org" />
<attribute name="Implementation-Title"
value="${ant.project.name}" />
<attribute name="Implementation-Version"
value="${version}" />
<attribute name="Compile-Time" value="${timestamp}" />
<attribute name="Compiled-By" value="${user.name}" />
<!-- TODO as soon we can extract the version from git we need to add this
-->
</section>
</manifest>
</jar>
</target>
<!-- ================================================================== -->
<!-- Java Doc -->
<!-- ================================================================== -->
<target name="doc" depends="compile" description="--> create javadoc">
<mkdir dir="${build.javadoc}" />
<javadoc packagenames="${javadoc.package}"
destdir="${build.javadoc}"
author="true"
version="true"
use="true"
windowtitle="${name} ${version} API"
doctitle="${name} ${version} API"
bottom="Copyright &amp;copy; ${javadoc.year} Bixo Labs">
<packageset dir="${main.src.dir}" />
<link href="${javadoc.link.java}" />
<classpath>
<path refid="compile.classpath" />
</classpath>
<group title="${javadoc.title}" packages="${javadoc.package}*" />
</javadoc>
</target>
<!-- ================================================================== -->
<!-- Hadoop job jar -->
<!-- ================================================================== -->
<target name="job"
depends="test, test-lr, test-it"
description="--> create a Hadoop ready jar including all libraries we depend on">
<!-- Always clear out lib, since we have a different set of libraries for the job jar -->
<delete dir="${build.dir}/lib" />
<copy todir="${build.dir}/lib" flatten="true">
<path refid="runtime.classpath" />
</copy>
<jar destfile="${build.dir}/${job.name}" compress="true">
<fileset dir="${build.dir.main-classes}" />
<fileset dir="${build.dir}" includes="lib/" />
<manifest>
<attribute name="Main-Class" value="${job.main.class}" />
</manifest>
</jar>
</target>
<!-- ================================================================== -->
<!-- Install in local Maven repository -->
<!-- ================================================================== -->
<target name="install"
depends="jar, mvn-install"
description="--> install SNAPSHOT jar to local repository">
</target>
<!-- ================================================================== -->
<!-- Deploy to Maven repo -->
<!-- ================================================================== -->
<target name="deploy"
depends="install, test-examples, test-contrib, mvn-deploy"
description="--> deploy SNAPSHOT jar to shared repository">
</target>
<!-- ================================================================== -->
<!-- Generate a distribution -->
<!-- ================================================================== -->
<target name="dist"
depends="test-all, jar, doc, jar-examples"
description="--> create a tarball distribution">
<delete dir="${build.dir.dist}" />
<!-- create target directory -->
<mkdir dir="${build.dir.dist}" />
<mkdir dir="${build.dir.dist}/bin" />
<mkdir dir="${build.dir.dist}/doc" />
<mkdir dir="${build.dir.dist}/doc/javadoc" />
<mkdir dir="${build.dir.dist}/doc/reports" />
<mkdir dir="${build.dir.dist}/lib" />
<mkdir dir="${build.dir.dist}/runtime" />
<mkdir dir="${build.dir.dist}/src" />
<mkdir dir="${build.dir.dist}/examples" />
<mkdir dir="${build.dir.dist}/examples/src" />
<mkdir dir="${build.dir.dist}/examples/lib" />
<mkdir dir="${build.dir.dist}/examples/doc" />
<!-- copy launch script to target -->
<copy todir="${build.dir.dist}/bin">
<fileset dir="${basedir}/bin" />
</copy>
<chmod perm="oug+x">
<fileset dir="${build.dir.dist}/bin" />
</chmod>
<!-- copy javadoc to target dir -->
<copy todir="${build.dir.dist}/doc/javadoc">
<fileset dir="${build.javadoc}" />
</copy>
<!-- copy libs -->
<copy todir="${build.dir.dist}/lib" flatten="true">
<fileset dir="${basedir}/lib" />
</copy>
<!-- copy runtime -->
<copy todir="${build.dir.dist}/runtime" flatten="true">
<path refid="runtime.classpath" />
</copy>
<!-- copy src -->
<copy todir="${build.dir.dist}/src">
<fileset dir="${basedir}/src" />
</copy>
<!-- copy project jar to dist dir -->
<copy todir="${build.dir.dist}">
<fileset file="${build.dir}/${jar.name}" />
</copy>
<!-- copy documents -->
<copy todir="${build.dir.dist}">
<fileset file="${basedir}/README" />
</copy>
<copy todir="${build.dir.dist}/doc">
<fileset file="${basedir}/doc/eclipse-formatter.properties" />
</copy>
<!-- copy the build file, build properties and pom file -->
<copy todir="${build.dir.dist}">
<fileset file="${basedir}/build.xml" />
<fileset file="${basedir}/build.properties" />
<fileset file="${basedir}/pom.xml" />
</copy>
<!-- copy the examples files -->
<copy todir="${build.dir.dist}/examples">
<fileset file="${basedir}/examples/pom.xml" />
<fileset file="${basedir}/examples/build.properties" />
<fileset file="${basedir}/examples/build.xml" />
<fileset file="${basedir}/examples/README" />
</copy>
<copy todir="${build.dir.dist}/examples/src">
<fileset dir="${basedir}/examples/src" />
</copy>
<copy todir="${build.dir.dist}/examples/lib">
<fileset dir="${basedir}/examples/lib" />
</copy>
<copy todir="${build.dir.dist}/examples/doc">
<fileset dir="${basedir}/examples/doc" />
</copy>
<!-- copy bixo-examples jar to dist dir -->
<copy todir="${build.dir.dist}">
<fileset file="${basedir}/examples/build/*.jar" />
</copy>
<tar longfile="gnu" compression="gzip" destfile="${build.release.file}">
<tarfileset dir="${build.dir.dist}">
<include name="**" />
<exclude name="bin/*" />
</tarfileset>
<tarfileset dir="${build.dir.dist}" mode="755">
<include name="bin/*" />
</tarfileset>
</tar>
</target>
<!-- ================================================================== -->
<!-- Generating eclipse file -->
<!-- ================================================================== -->
<target name="eclipse"
depends="mvn-init, clean-eclipse"
description="--> create the Eclipse project files">
<taskdef name="eclipse"
classname="prantl.ant.eclipse.EclipseTask"
classpathref="compile.classpath" />
<mkdir dir="${build.dir.main-classes-eclipse}" />
<mkdir dir="${build.dir.test-classes-eclipse}" />
<mkdir dir="${build.dir.it-classes-eclipse}" />
<eclipse>
<settings>
<jdtcore compilercompliance="6.0" />
<resources encoding="UTF-8" />
</settings>
<project name="${ant.project.name}" />
<classpath>
<container path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" />
<source path="${basedir}/src/main/java"
output="${build.dir.main-classes-eclipse}" />
<source path="${basedir}/src/main/resources"
output="${build.dir.main-classes-eclipse}" />
<source path="${basedir}/src/test/java"
output="${build.dir.test-classes-eclipse}" />
<source path="${basedir}/src/test/resources"
output="${build.dir.test-classes-eclipse}" />
<source path="${basedir}/src/it/java"
output="${build.dir.it-classes-eclipse}" />
<source path="${basedir}/src/it/resources"
output="${build.dir.it-classes-eclipse}" />
<source path="${basedir}/${tool.src.dir}"
output="${build.dir.tool-classes-eclipse}" />
<source path="${basedir}/${tool.res.dir}"
output="${build.dir.tool-classes-eclipse}" />
<!-- extras -->
<!-- we do not yet have extra modules, but it is just a question of time :) -->
<output path="${build.dir.main-classes-eclipse}" />
<library pathref="test.classpath" exported="false" />
</classpath>
</eclipse>
<concat destfile="${root.dir}/.settings/org.eclipse.jdt.core.prefs"
append="true">
<filelist dir="${root.dir}/doc/" files="eclipse-formatter.properties" />
</concat>
</target>
<target name="clean-eclipse"
description="--> clean the Eclipse project files">
<delete file=".classpath" />
<delete file=".eclipse" />
<delete file=".project" />
<delete dir=".settings" />
</target>
<!-- ================================================================== -->
<!-- Multi project build -->
<!-- ================================================================== -->
<macrodef name="iterate">
<attribute name="target" />
<sequential>
<subant target="@{target}">
<property name="root.dir" value="${basedir}" />
<!-- extras should go into a sub folder extras
<fileset dir="extras" includes="*/build.xml" />
-->
</subant>
</sequential>
</macrodef>
<target name="clean-all" description="--> clean all files">
<antcall target="clean" />
<!-- <antcall target="clean-eclipse" /> -->
<antcall target="clean-eclipse-build"/>
<antcall target="clean-examples" />
<antcall target="clean-contrib" />
</target>
<target name="test-all"
depends="test, test-lr, test-it, test-examples, test-contrib"
description="--> run all tests">
</target>
<target name="compile-all"
depends="compile, compile-test, compile-integration-test, compile-examples, compile-contrib"
description="--> compile all files including tests, examples and contrib">
</target>
<!-- ================================================================== -->
<!-- Examples targets -->
<!-- ================================================================== -->
<target name="compile-examples"
depends="mvn-install"
description="--> compile examples">
<subant target="compile">
<fileset dir="./examples" includes="build.xml"/>
</subant>
</target>
<target name="test-examples"
description="--> run tests on examples">
<subant target="test">
<fileset dir="./examples" includes="build.xml"/>
</subant>
</target>
<target name="clean-examples"
description="--> clean all examples">
<subant target="clean">
<fileset dir="./examples" includes="build.xml"/>
</subant>
</target>
<target name="jar-examples"
depends="clean-examples"
description="--> build examples jar">
<subant target="jar">
<fileset dir="./examples" includes="build.xml"/>
</subant>
</target>
<!-- ================================================================== -->
<!-- Contrib targets -->
<!-- ================================================================== -->
<target name="compile-contrib"
depends="mvn-install"
description="--> compile contrib examples">
<subant target="compile">
<fileset dir="./contrib" includes="*/build.xml"/>
</subant>
</target>
<target name="test-contrib"
description="--> run tests on contrib examples">
<subant target="test">
<fileset dir="./contrib" includes="*/build.xml"/>
</subant>
</target>
<target name="clean-contrib"
description="--> clean all contrib examples">
<subant target="clean">
<fileset dir="./contrib" includes="*/build.xml"/>
</subant>
</target>
</project>
Jump to Line
Something went wrong with that request. Please try again.