Permalink
Fetching contributors…
Cannot retrieve contributors at this time
403 lines (354 sloc) 16.9 KB
<!--
Ant Build for ThreeTen
@author Fabio Kung (fabio.kung@gmail.com)
@author Michael Nascimento Santos
@author Oliver Fischer (o.b.fischer@swe-blog.net)
@author Stephen Colebourne
@author Richard Warburton
-->
<project name="threeten" default="dist">
<description>
ThreeTen date and time API, reference implementation for JSR 310
</description>
<property file="build.properties" />
<property file="version.properties"/>
<tstamp />
<property name="jarName" value="threeten-${version.full}.jar" />
<property name="jarNameSources" value="threeten-sources-${version.full}.jar" />
<property name="jarNameJavadoc" value="threeten-javadoc-${version.full}.jar" />
<property name="jarCoreName" value="threeten-core-${version.full}.jar" />
<property name="jarExtraName" value="threeten-extra-${version.full}.jar" />
<property name="jarOpenJDKName" value="threeten-openjdk-${version.full}.jar" />
<property name="jarOracleName" value="threeten-oracle-${version.full}.jar" />
<property name="jarAllName" value="threeten-all-${version.full}.jar" />
<property name="distFileName" value="threeten-${version.full}.zip"/>
<macrodef name="get-dependency">
<attribute name="group" />
<attribute name="artifact" />
<attribute name="version" />
<attribute name="variant" default="" />
<attribute name="dest" />
<sequential>
<get
src="${maven.repo.url}/@{group}/@{artifact}/@{version}/@{artifact}-@{version}@{variant}.jar"
dest="@{dest}/@{artifact}-@{version}@{variant}.jar"
verbose="true"
usetimestamp="true" ignoreerrors="true"/>
</sequential>
</macrodef>
<path id="main.path">
<pathelement location="${core.main.classes}" />
<pathelement location="${extra.main.classes}" />
<pathelement location="${oracle.main.classes}" />
<pathelement location="${ojdk.main.classes}" />
<pathelement location="${lib.main}/${tzdb.outputjar}"/>
</path>
<path id="test.commonpath">
<pathelement location="${core.test.classes}" />
<pathelement location="${extra.test.classes}" />
<pathelement location="${oracle.test.classes}" />
<pathelement location="${ojdk.test.classes}" />
<pathelement location="${lib.main}/${tzdb.outputjar}"/>
<fileset dir="lib/test">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.path">
<path refid="main.path" />
<path refid="test.commonpath" />
</path>
<path id="tck.path">
<pathelement location="${tck.implementation}" />
<path refid="test.commonpath" />
</path>
<property name="tck.groups" value="tck" />
<path id="coverage.path">
<path refid="main.path" />
<pathelement location="${core.test.classes}" />
<pathelement location="${lib.main}/${tzdb.outputjar}"/>
<fileset dir="lib/test">
<include name="**/*.jar" />
</fileset>
</path>
<path id="emma.lib" >
<pathelement location="${lib.coverage}/emma-2.0.5312.jar" />
<pathelement location="${lib.coverage}/emma_ant-2.0.5312.jar" />
</path>
<!-- ==================================================================== -->
<target name="resolve-deps">
<mkdir dir="${lib.main}" />
<mkdir dir="${lib.optional}" />
<mkdir dir="${lib.test}" />
<mkdir dir="${lib.coverage}" />
<get-dependency group="org/testng" artifact="testng" version="5.8" variant="-jdk15" dest="${lib.test}" />
<get-dependency group="emma" artifact="emma" version="2.0.5312" dest="${lib.coverage}" />
<get-dependency group="emma" artifact="emma_ant" version="2.0.5312" dest="${lib.coverage}" />
</target>
<target name="init" depends="resolve-deps">
</target>
<target name="clean" description="clean up">
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<!-- ==================================================================== -->
<target name="compile-core" depends="init">
<mkdir dir="${core.main.classes}"/>
<javac srcdir="${core.main}" destdir="${core.main.classes}" debug="true" includeantruntime="false">
<classpath refid="main.path"/>
</javac>
</target>
<target name="compile-extra" depends="compile-core">
<mkdir dir="${extra.main.classes}"/>
<javac srcdir="${extra.main}" destdir="${extra.main.classes}" includeantruntime="false">
<classpath location="${core.main.classes}"/>
<classpath refid="main.path"/>
</javac>
</target>
<target name="compile-openjdk" depends="compile-core">
<mkdir dir="${ojdk.main.classes}"/>
<javac srcdir="${ojdk.main}" destdir="${ojdk.main.classes}" nowarn="true" bootclasspath="${java.home}/lib/rt.jar" includeantruntime="false">
<classpath refid="main.path"/>
</javac>
</target>
<target name="compile-oracle" depends="compile-core">
<mkdir dir="${oracle.main.classes}"/>
<javac srcdir="${oracle.main}" destdir="${oracle.main.classes}" includeantruntime="false">
<classpath location="${core.main.classes}"/>
<classpath refid="main.path"/>
</javac>
</target>
<target name="compile-tzdb" depends="compile-core">
<mkdir dir="${tzdata.main.workarea}"/>
<copy todir="${tzdata.main.workarea}">
<fileset dir="${tzdata.main}" includes="tzdata*.tar.gz"/>
<mapper type="glob" from="tzdata*.tar.gz" to="*/tzdb.tar.gz" />
</copy>
<subant genericantfile="build.xml" target="tzdb-unpack">
<dirset dir="${tzdata.main.workarea}" includes="*" />
</subant>
<java classpath="${core.main.classes}" classname="javax.time.zone.TZDBZoneRulesCompiler" fork="true" failonerror="true">
<arg line="-srcdir ${tzdata.main.workarea}" />
<arg line="-dstdir ${lib.optional}" />
<arg line="${tzdb.files}" />
</java>
<copy todir="${lib.main}">
<fileset dir="${lib.optional}" includes="${tzdb.outputjar}"/>
</copy>
<delete file="${lib.optional}/${tzdb.outputjar}" />
</target>
<target name="tzdb-unpack">
<echo message="${basedir}"></echo>
<gunzip src="${basedir}/tzdb.tar.gz" />
<untar src="${basedir}/tzdb.tar" dest="${basedir}" />
<delete file="${basedir}/tzdb.tar" />
</target>
<target name="compile" depends="compile-core, compile-extra, compile-oracle, compile-openjdk, compile-tzdb" description="compile all sources" />
<!-- ==================================================================== -->
<target name="javadoc" depends="init" description="generates javadoc for the api">
<mkdir dir="${build.javadoc}"/>
<javadoc sourcepath="${core.main};${ojdk.main};${oracle.main}" destdir="${build.javadoc}"
classpathref="main.path"
windowtitle="ThreeTen date and time API"
failonerror="true"
packagenames="javax.time**/*,java.util**/*"
overview="${core.main}/javax/time/overview.html" />
</target>
<!-- ==================================================================== -->
<target name="compile-core-tests" depends="compile-core">
<mkdir dir="${core.test.classes}" />
<javac srcdir="${core.test}" destdir="${core.test.classes}" classpathref="test.path" includeantruntime="false" />
</target>
<target name="compile-extra-tests" depends="compile-extra,compile-core-tests">
<mkdir dir="${extra.test.classes}" />
<javac srcdir="${extra.test}" destdir="${extra.test.classes}" classpathref="test.path" includeantruntime="false" />
</target>
<target name="test-core" depends="compile-core-tests,compile-tzdb">
<taskdef resource="testngtasks" classpathref="test.path" />
<testng classpathref="test.path" outputDir="${core.test.classes}" sourceDir="${core.test}" haltonfailure="true" verbose="2">
<jvmarg value="-Xmx512M" />
<jvmarg value="-Duser.language=en" />
<jvmarg value="-Duser.country=UK" />
<classfileset dir="${core.test.classes}" includes="**/Test*.class" excludes="java/util/*" />
</testng>
</target>
<target name="test-extra" depends="compile-extra-tests,compile-tzdb">
<taskdef resource="testngtasks" classpathref="test.path" />
<testng classpathref="test.path" outputDir="${extra.test.classes}" sourceDir="${extra.test}" haltonfailure="true" verbose="2">
<jvmarg value="-Xmx512M" />
<jvmarg value="-Duser.language=en" />
<jvmarg value="-Duser.country=UK" />
<classfileset dir="${extra.test.classes}" includes="**/Test*.class" excludes="java/util/*" />
</testng>
</target>
<target name="test" depends="test-core,test-extra" description="run tests" />
<target name="check-sigtest-downloaded">
<available property="sigtest.exists" file="${sigtest.loc}"/>
</target>
<target name="download-sigtest" depends="check-sigtest-downloaded" unless="${sigtest.exists}">
<get
src="${sigtest.dist.origin}"
dest="${sigtest.dist.file}"
verbose="true"
usetimestamp="true" />
<unzip
src="${sigtest.dist.file}"
dest="${lib.test}">
<patternset>
<include name="${sigtest.dist.jarloc}" />
</patternset>
<mapper type="flatten"/>
</unzip>
<delete file="${sigtest.dist.file}" />
</target>
<target name="tdtck" description="Setup task definitions for the TCK" depends="download-sigtest" >
<taskdef name="setup-sigtest-task" classname="com.sun.tdk.signaturetest.ant.ASetup"
classpath="${sigtest.loc}"/>
<taskdef name="test-sigtest-task" classname="com.sun.tdk.signaturetest.ant.ATest"
classpath="${sigtest.loc}"/>
<property name="tck-signatures" value="${build.test}/jsr310.sig" />
<property name="tck-rt-jar" value="${java.home}/lib/rt.jar" />
</target>
<target name="setup-sigtest"
description="generates the signatures file from the reference implementation"
depends="tdtck">
<setup-sigtest-task package="javax.time" failonerror="true" apiVersion="openapi-v2"
filename="${tck-signatures}">
<classpath>
<pathelement location="${tck-rt-jar}"/>
<pathelement location="${build}/${jarName}"/>
</classpath>
<!--<exclude class="com.acme.openapi.NotTested"/>-->
</setup-sigtest-task>
</target>
<target name="run-sigtest"
description="compares the reference implementation sigtest results with a specified path"
depends="tdtck">
<test-sigtest-task failonerror="true" apiVersion="openapi-v2"
filename="${tck-signatures}" backward="true" output="st_report.txt">
<package name="javax.time" />
<!--<exclude class="com.acme.openapi.NotTested"/>-->
<classpath>
<pathelement location="${tck-rt-jar}"/>
<pathelement location="${tck.implementation}"/>
</classpath>
</test-sigtest-task>
</target>
<target name="runtck" depends="compile-core-tests" >
<taskdef resource="testngtasks" classpathref="tck.path" />
<testng classpathref="tck.path" outputDir="${core.test.classes}" sourceDir="${core.test}" haltonfailure="true" verbose="2" groups="tck">
<jvmarg value="-Xmx512M" />
<jvmarg value="-Duser.language=en" />
<jvmarg value="-Duser.country=UK" />
<classfileset dir="${core.test.classes}" includes="**/Test*.class" excludes="java/util/*" />
</testng>
</target>
<target name="tck" depends="compile-tzdb,runtck,run-sigtest" description="run tck acceptance criteria" />
<!-- ==================================================================== -->
<macrodef name="do-coverage">
<attribute name="runclass" />
<attribute name="htmlout" />
<attribute name="txtout" />
<sequential>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<mkdir dir="${build.coverage}" />
<emmajava libclasspathref="emma.lib"
fullmetadata="yes"
sourcepath="${core.main}"
classname="@{runclass}"
classpathref="coverage.path">
<jvmarg value="-Xmx512M" />
<filter includes="javax.time.*" excludes="*Test*, *Mock*, *Performance*, *Examples*" />
<txt outfile="${build.coverage}/@{txtout}" />
<html outfile="${build.coverage}/@{htmlout}" metrics="method:90,block:90,line:90,class:95" />
</emmajava>
</sequential>
</macrodef>
<target name="tck-coverage" depends="compile-core-tests" description="tck coverage">
<do-coverage runclass="javax.time.AllTCK" htmlout="tck.html" txtout="tck.txt" />
</target>
<target name="coverage" depends="compile-core-tests" description="test coverage">
<do-coverage runclass="javax.time.AllTest" htmlout="coverage.html" txtout="coverage.txt" />
</target>
<!-- ==================================================================== -->
<target name="jar-core" depends="compile-core">
<jar jarfile="${build}/${jarCoreName}">
<fileset dir="${core.main.classes}"/>
</jar>
</target>
<target name="jar-extra" depends="compile-extra">
<jar jarfile="${build}/${jarExtraName}">
<fileset dir="${extra.main.classes}"/>
</jar>
</target>
<target name="jar-openjdk" depends="compile-openjdk">
<jar jarfile="${build}/${jarOpenJDKName}">
<fileset dir="${ojdk.main.classes}"/>
</jar>
</target>
<target name="jar-oracle" depends="compile-oracle">
<jar jarfile="${build}/${jarOracleName}">
<fileset dir="${oracle.main.classes}"/>
</jar>
</target>
<target name="jar-all" depends="compile">
<jar jarfile="${build}/${jarAllName}">
<fileset dir="${core.main.classes}"/>
<fileset dir="${extra.main.classes}"/>
<fileset dir="${ojdk.main.classes}"/>
<fileset dir="${oracle.main.classes}"/>
</jar>
</target>
<target name="jar-main" depends="compile">
<jar jarfile="${build}/${jarName}">
<fileset dir="${core.main.classes}"/>
<fileset dir="${ojdk.main.classes}"/>
<fileset dir="${oracle.main.classes}"/>
</jar>
</target>
<target name="jar-main-sources">
<jar jarfile="${build}/${jarNameSources}">
<fileset dir="${core.main}"/>
<fileset dir="${ojdk.main}"/>
<fileset dir="${oracle.main}"/>
</jar>
</target>
<target name="jar-main-javadoc" depends="javadoc">
<jar jarfile="${build}/${jarNameJavadoc}">
<fileset dir="${build.javadoc}"/>
</jar>
</target>
<target name="jar" depends="jar-core,jar-extra,jar-openjdk,jar-oracle,jar-all,jar-main,jar-main-sources,jar-main-javadoc" description="build jar files" />
<!-- ==================================================================== -->
<target name="dist" depends="jar" description="generate the distribution">
<copy todir="${dist.workarea}/${src}">
<fileset dir="${src}"/>
</copy>
<copy todir="${dist.workarea}/lib" flatten="true">
<fileset dir="${lib.main}" includes="${tzdb.outputjar}" />
<fileset dir="${build}" includes="${jarName}" />
</copy>
<copy todir="${dist.workarea}/lib-optional" flatten="true">
<fileset dir="${lib.optional}" includes="*.jar" />
<fileset dir="${build}" includes="*.jar" />
</copy>
<delete file="${dist.workarea}/lib-optional/${jarName}" />
<copy todir="${dist.workarea}/nbproject">
<fileset dir="nbproject"/>
</copy>
<copy file=".classpath" todir="${dist.workarea}" />
<copy file=".project" todir="${dist.workarea}" />
<copy file="build.xml" todir="${dist.workarea}" />
<copy file="build.properties" todir="${dist.workarea}" />
<copy file="checkstyle.xml" todir="${dist.workarea}" />
<copy file="LICENSE.txt" todir="${dist.workarea}" />
<copy file="LICENSE_OpenJDK.txt" todir="${dist.workarea}" />
<copy file="LICENSE_Oracle.txt" todir="${dist.workarea}" />
<copy file="README.txt" todir="${dist.workarea}" />
<copy file="TODO.txt" todir="${dist.workarea}" />
<zip destfile="${dist}/${distFileName}" basedir="${dist.workarea}" />
</target>
<!-- ==================================================================== -->
<target name="examples" depends="compile-core-tests" description="outputs some examples to system out">
<java classname="javax.time.Examples" classpathref="test.path" fork="true"/>
</target>
</project>