Apache pivot ant build script
<?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="pivot" default="compile"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<path id="classpath.javalib">
<fileset dir="${java.home}/lib" includes="**/*.jar"/>
</path>
<!-- Properties that affect the directories that are created as part of the build -->
<property name="folder.bin" value="ant-bin"/>
<property name="folder.dist" value="dist"/>
<property name="folder.doc" value="doc"/>
<property name="folder.install" value="install"/>
<property name="folder.lib" value="lib"/>
<property name="folder.deploy" value="deploy"/>
<!-- Keystore properties -->
<property name="keystore.location" value="etc/pivot.keystore"/>
<property name="keystore.alias" value="pivot"/>
<property name="keystore.passwd" value="apache"/>
<!-- Compiler properties -->
<property name="compiler.deprecation" value="true"/>
<property name="compiler.debug" value="false"/>
<property name="compiler.target" value="1.6"/>
<property name="compiler.encoding" value="UTF-8"/>
<property name="compiler.indexJars" value="true"/>
<property name="compiler.arg" value="-Xlint"/>
<!-- Test properties -->
<property name="test.verbose" value="false"/>
<!-- Dynamic properties -->
<property file="build.properties"/>
<property name="release" value="apache-${ant.project.name}-${version}"/>
<!-- Jar file names -->
<property name="jar.charts" value="${ant.project.name}-charts-${version}.jar" />
<property name="jar.core" value="${ant.project.name}-core-${version}.jar" />
<property name="jar.demos" value="${ant.project.name}-demos-${version}.jar" />
<property name="jar.tools" value="${ant.project.name}-tools-${version}.jar" />
<property name="jar.tutorials" value="${ant.project.name}-tutorials-${version}.jar" />
<property name="jar.web" value="${ant.project.name}-web-${version}.jar" />
<property name="jar.web-server" value="${ant.project.name}-web-server-${version}.jar" />
<property name="jar.wtk" value="${ant.project.name}-wtk-${version}.jar" />
<property name="jar.wtk-terra" value="${ant.project.name}-wtk-terra-${version}.jar" />
<!-- Ant version check -->
<fail>
<condition>
<not>
<contains string="${ant.version}" substring="1.7"/>
</not>
</condition>
Error:
Building Pivot requires Apache Ant 1.7 or greater. Please see the BUILD
file for more information.
</fail>
<!-- Compile macro -->
<macrodef name="compile">
<attribute name="project"/>
<sequential>
<!-- JDK version check -->
<fail>
<condition>
<not>
<or>
<equals arg1="${ant.java.version}" arg2="1.6"/>
<equals arg1="${ant.java.version}" arg2="1.7"/>
</or>
</not>
</condition>
Error:
Building Pivot requires JDK 1.6 or greater. Please see the
BUILD file for more information.
</fail>
<!-- JUnit check -->
<fail>
<condition>
<not>
<available classname="org.junit.Test"/>
</not>
</condition>
Error:
JUnit 4 was not found on your classpath. Please see the BUILD
file for more information.
</fail>
<mkdir dir="@{project}/${folder.bin}"/>
<javac destDir="@{project}/${folder.bin}"
includejavaruntime="true"
deprecation="${compiler.deprecation}"
debug="${compiler.debug}"
target="${compiler.target}"
encoding="${compiler.encoding}"
failonerror="true">
<src>
<dirset dir="@{project}">
<include name="src"/>
<include name="test"/>
</dirset>
</src>
<compilerarg line="${compiler.arg}"/>
<classpath>
<path refid="classpath.javalib"/>
<dirset dir="${basedir}" includes="**/${folder.bin}"/>
<fileset dir="@{project}" includes="lib/**/*.jar"/>
</classpath>
</javac>
</sequential>
</macrodef>
<!-- Test macro -->
<macrodef name="test">
<attribute name="project"/>
<sequential>
<echo message="@{project}: Executing test cases..."/>
<condition property="test.formatter">
<istrue value="${test.verbose}"/>
</condition>
<junit fork="true">
<classpath>
<path refid="classpath.javalib"/>
<dirset dir="${basedir}" includes="**/${folder.bin}"/>
<dirset dir="@{project}" includes="test"/>
<fileset dir="@{project}" includes="lib/**/*.jar"/>
</classpath>
<formatter type="brief" usefile="false" if="test.formatter"/>
<batchtest>
<fileset dir="@{project}/test" includes="**/*Test.java"/>
</batchtest>
</junit>
</sequential>
</macrodef>
<!-- Package macro -->
<macrodef name="package">
<attribute name="project"/>
<attribute name="jarFile"/>
<attribute name="title"/>
<sequential>
<mkdir dir="${folder.lib}"/>
<jar destfile="${folder.lib}/@{jarFile}" index="${compiler.indexJars}">
<metainf dir="${basedir}">
<include name="LICENSE"/>
<include name="NOTICE"/>
<include name="README"/>
</metainf>
<manifest>
<attribute name="Sealed" value="true"/>
<attribute name="Implementation-Vendor-Id" value="org.apache"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
<attribute name="Implementation-Title" value="Apache Pivot @{title}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="@{project}/${folder.bin}">
<exclude name="**/test/**"/>
</fileset>
<fileset dir="@{project}/src">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</jar>
</sequential>
</macrodef>
<!-- Clean macro -->
<macrodef name="clean">
<attribute name="project"/>
<sequential>
<delete includeemptydirs="true">
<fileset dir="@{project}">
<include name="${folder.bin}/**"/>
<include name="${folder.deploy}/**"/>
</fileset>
<fileset dir="${basedir}">
<include name="${folder.lib}/${ant.project.name}-@{project}-${version}.jar"/>
</fileset>
</delete>
</sequential>
</macrodef>
<!-- Compile all classes (tests included) -->
<target name="compile" description="Compiles all projects"
depends="charts, core, demos, tests, tools, tutorials, web, web-server, wtk, wtk-terra"/>
<!-- Package JAR files -->
<target name="package" description="Packages all projects into JAR files" depends="compile">
<package project="charts" jarFile="${jar.charts}" title="Charts"/>
<package project="core" jarFile="${jar.core}" title="Core"/>
<package project="demos" jarFile="${jar.demos}" title="Demos"/>
<package project="tools" jarFile="${jar.tools}" title="Tools"/>
<package project="tutorials" jarFile="${jar.tutorials}" title="Tutorials"/>
<package project="web" jarFile="${jar.web}" title="Web Queries"/>
<package project="web-server" jarFile="${jar.web-server}" title="Web Queries Server"/>
<package project="wtk" jarFile="${jar.wtk}" title="WTK"/>
<package project="wtk-terra" jarFile="${jar.wtk-terra}" title="WTK Terra Theme Provider"/>
</target>
<!-- Run unit tests -->
<target name="test" description="Executes unit tests" depends="compile">
<test project="core"/>
<test project="web"/>
</target>
<!-- Clean -->
<target name="clean" description="Removes all build artifacts">
<clean project="charts"/>
<clean project="core"/>
<clean project="demos"/>
<clean project="tests"/>
<clean project="tools"/>
<clean project="tutorials"/>
<clean project="web"/>
<clean project="web-server"/>
<clean project="wtk"/>
<clean project="wtk-terra"/>
<delete dir="${folder.dist}"/>
<delete dir="${folder.doc}"/>
<delete dir="${folder.install}"/>
<delete dir="${folder.lib}"/>
</target>
<!-- Javadoc -->
<target name="doc" description="Generates API documentation in ${folder.doc}">
<javadoc packagenames="org.apache.pivot.*" destdir="${folder.doc}"
author="true" version="true" use="true"
classpath="${java.class.path}">
<classpath>
<fileset dir="web-server/lib" includes="**/*.jar"/>
<path refid="classpath.javalib"/>
</classpath>
<packageset dir="charts/src" includes="**/*"/>
<packageset dir="core/src" includes="**/*"/>
<packageset dir="tools/src" includes="**/*"/>
<packageset dir="web/src" includes="**/*"/>
<packageset dir="web-server/src" includes="**/*"/>
<packageset dir="wtk/src" includes="**/*"/>
<packageset dir="wtk-terra/src" includes="**/*"/>
<link href="http://java.sun.com/javase/6/docs/api"/>
<link href="http://java.sun.com/j2ee/1.4/docs/api"/>
</javadoc>
</target>
<!-- Individual compile targets resolve inter-project dependency -->
<target name="charts" depends="core, wtk">
<compile project="charts"/>
</target>
<target name="core">
<compile project="core"/>
</target>
<target name="demos" depends="core, wtk, web">
<compile project="demos"/>
</target>
<target name="tests" depends="core, web, wtk, wtk-terra">
<compile project="tests"/>
</target>
<target name="tools" depends="core, wtk">
<compile project="tools"/>
</target>
<target name="tutorials" depends="core, wtk, web, tools">
<compile project="tutorials"/>
</target>
<target name="web" depends="core">
<compile project="web"/>
</target>
<target name="web-server" depends="core, web">
<compile project="web-server"/>
</target>
<target name="wtk" depends="core">
<fail>
<condition>
<not>
<available classname="netscape.javascript.JSObject"
classpathref="classpath.javalib"/>
</not>
</condition>
Error:
LiveConnect was not found on your classpath. Please see the BUILD
file for more information.
</fail>
<compile project="wtk"/>
</target>
<target name="wtk-terra" depends="core, wtk">
<compile project="wtk-terra"/>
</target>
<!-- Package source distribution -->
<target name="dist" description="Generates source release in ${folder.dist}"
depends="clean, trim-whitespace">
<mkdir dir="${folder.dist}/${release}-src"/>
<!-- Copy the source files to the release folder -->
<copy todir="${folder.dist}/${release}-src">
<fileset dir="${basedir}">
<include name="**/*"/>
<!-- Exclude hidden files and folders -->
<exclude name="**/.*/**"/>
<!-- Exclude folders containing compilation artifacts -->
<exclude name="**/${folder.bin}/**"/>
<exclude name="${folder.dist}/**"/>
<exclude name="${folder.doc}/**"/>
<exclude name="${folder.install}/**"/>
<exclude name="${folder.lib}/**"/>
</fileset>
</copy>
<!-- Create .zip archive -->
<zip destfile="${folder.dist}/${release}-src.zip" level="9">
<fileset dir="${folder.dist}" includes="${release}-src/**"/>
</zip>
<checksum file="${folder.dist}/${release}-src.zip" algorithm="md5"/>
<checksum file="${folder.dist}/${release}-src.zip" algorithm="sha"/>
<!-- Create .tar.gz archive -->
<tar destfile="${folder.dist}/${release}-src.tar" longfile="gnu">
<fileset dir="${folder.dist}" includes="${release}-src/**"/>
</tar>
<gzip src="${folder.dist}/${release}-src.tar"
destfile="${folder.dist}/${release}-src.tar.gz"/>
<delete file="${folder.dist}/${release}-src.tar"/>
<checksum file="${folder.dist}/${release}-src.tar.gz" algorithm="md5"/>
<checksum file="${folder.dist}/${release}-src.tar.gz" algorithm="sha"/>
</target>
<!-- Package binary distribution -->
<target name="install" description="Generates binary release in ${folder.install}"
depends="clean, package, doc, deploy">
<mkdir dir="${folder.install}/${release}/lib"/>
<mkdir dir="${folder.install}/${release}/doc"/>
<mkdir dir="${folder.install}/${release}/webapps"/>
<!-- Copy base files to the install folder -->
<copy todir="${folder.install}/${release}">
<fileset dir="${basedir}">
<include name="LICENSE"/>
<include name="NOTICE"/>
<include name="README"/>
<include name="RELEASE-NOTES"/>
</fileset>
</copy>
<!-- Copy release binaries -->
<copy todir="${folder.install}/${release}/lib">
<fileset dir="${folder.lib}">
<include name="${jar.charts}"/>
<include name="${jar.core}"/>
<include name="${jar.tools}"/>
<include name="${jar.web}"/>
<include name="${jar.web-server}"/>
<include name="${jar.wtk}"/>
<include name="${jar.wtk-terra}"/>
</fileset>
</copy>
<!-- Copy documentation -->
<copy todir="${folder.install}/${release}/doc">
<fileset dir="${folder.doc}"/>
</copy>
<!-- Copy webapps -->
<copy todir="${folder.install}/${release}/webapps">
<fileset dir="${folder.lib}">
<include name="${ant.project.name}-demos.war"/>
<include name="${ant.project.name}-tutorials.war"/>
</fileset>
</copy>
<!-- Create .zip archive -->
<zip destfile="${folder.install}/${release}.zip" level="9">
<fileset dir="${folder.install}" includes="${release}/**"/>
</zip>
<checksum file="${folder.install}/${release}.zip" algorithm="md5"/>
<checksum file="${folder.install}/${release}.zip" algorithm="sha"/>
<!-- Create .tar.gz archive -->
<tar destfile="${folder.install}/${release}.tar" longfile="gnu">
<fileset dir="${folder.install}" includes="${release}/**"/>
</tar>
<gzip src="${folder.install}/${release}.tar" destfile="${folder.install}/${release}.tar.gz"/>
<delete file="${folder.install}/${release}.tar"/>
<checksum file="${folder.install}/${release}.tar.gz" algorithm="md5"/>
<checksum file="${folder.install}/${release}.tar.gz" algorithm="sha"/>
</target>
<!-- Generate deployment files -->
<target name="deploy" depends="package">
<!-- Sign JARS -->
<mkdir dir="${folder.lib}/signed"/>
<copy todir="${folder.lib}/signed">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
</fileset>
</copy>
<signjar keystore="${keystore.location}" storepass="${keystore.passwd}"
alias="${keystore.alias}" preservelastmodified="true" lazy="true">
<path>
<fileset dir="${folder.lib}/signed" includes="*.jar" />
</path>
</signjar>
<copy todir="${folder.lib}">
<fileset dir="${folder.lib}/signed" includes="*.jar" />
<mapper type="glob" from="*.jar" to="*.signed.jar"/>
</copy>
<delete dir="${folder.lib}/signed"/>
<!-- Deploy demos -->
<mkdir dir="demos/${folder.deploy}/lib"/>
<copy todir="demos/${folder.deploy}/lib">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*-server*.jar"/>
</fileset>
</copy>
<!-- Transform demos index -->
<xslt basedir="demos/www"
destdir="demos/${folder.deploy}"
extension=".html"
force="true"
style="demos/xsl/index.xsl"
includes="index.xml"/>
<!-- Transform demos html -->
<xslt basedir="demos/www"
destdir="demos/${folder.deploy}"
extension=".html"
force="true"
style="demos/xsl/demo.html.xsl"
includes="*.xml"
excludes="index.xml">
<param name="version" expression="${version}"/>
<param name="root" expression="${ant.project.name}-demos"/>
</xslt>
<!-- Transform demos jnlp -->
<xslt basedir="demos/www"
destdir="demos/${folder.deploy}"
extension=".jnlp"
force="true"
style="demos/xsl/demo.jnlp.xsl"
includes="*.xml"
excludes="index.xml">
<param name="version" expression="${version}"/>
<param name="root" expression="${ant.project.name}-demos"/>
</xslt>
<!-- Copy static demo files to deploy folder -->
<copy todir="demos/${folder.deploy}">
<fileset dir="demos/www" excludes="**/*.xml"/>
</copy>
<!-- Generate demos WAR -->
<war destfile="${folder.lib}/${ant.project.name}-demos.war" webxml="demos/web.xml">
<fileset dir="demos/${folder.deploy}"/>
</war>
<!-- Deploy tutorials -->
<mkdir dir="tutorials/${folder.deploy}/lib"/>
<copy todir="tutorials/${folder.deploy}/lib">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*-demos*.jar"/>
<exclude name="*-server*.jar"/>
</fileset>
</copy>
<!-- Transform tutorials index -->
<xslt basedir="tutorials/www"
destdir="tutorials/${folder.deploy}"
extension=".html"
force="true"
style="tutorials/xsl/index.xsl"
includes="index.xml"/>
<!-- Transform tutorials html -->
<xslt basedir="tutorials/www"
destdir="tutorials/${folder.deploy}"
extension=".html"
force="true"
style="tutorials/xsl/tutorial.xsl"
includes="*.xml"
excludes="index.xml">
<param name="version" expression="${version}"/>
</xslt>
<!-- Copy static tutorial files to deploy folder -->
<copy todir="tutorials/${folder.deploy}">
<fileset dir="tutorials/www" excludes="**/*.xml"/>
</copy>
<!-- Generate tutorials WAR -->
<war destfile="${folder.lib}/${ant.project.name}-tutorials.war" webxml="tutorials/web.xml">
<fileset dir="tutorials/${folder.deploy}"/>
</war>
</target>
<!-- Installs JARs to local Maven repository -->
<target name="maven-install" depends="clean, package">
<artifact:install file="pom.xml">
<artifact:pom file="pom.xml"/>
</artifact:install>
<artifact:install file="lib/pivot-core-${version}.jar">
<artifact:pom file="core/pom.xml"/>
</artifact:install>
<artifact:install file="lib/pivot-web-${version}.jar">
<artifact:pom file="web/pom.xml"/>
</artifact:install>
<artifact:install file="lib/pivot-wtk-${version}.jar">
<artifact:pom file="wtk/pom.xml"/>
</artifact:install>
<artifact:install file="lib/pivot-wtk-terra-${version}.jar">
<artifact:pom file="wtk-terra/pom.xml"/>
</artifact:install>
<artifact:install file="lib/pivot-charts-${version}.jar">
<artifact:pom file="charts/pom.xml"/>
</artifact:install>
</target>
<!-- Remove trailing white space in all source files -->
<target name="trim-whitespace">
<fileset id="trimfiles" dir=".">
<include name="BUILD"/>
<include name="LICENSE"/>
<include name="NOTICE"/>
<include name="README"/>
<include name="RELEASE-NOTES"/>
<include name="**/*.java"/>
<include name="**/*.html"/>
<include name="**/*.jsp"/>
<include name="**/*.txt"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
<include name="**/*.wtkx"/>
<include name="**/*.wtkd"/>
<include name="**/*.json"/>
</fileset>
<replaceregexp match="[\t]" replace=" " flags="gm" byline="true">
<fileset refid="trimfiles"/>
</replaceregexp>
<replaceregexp match="[\t ]+$" replace="" flags="gm" byline="true">
<fileset refid="trimfiles"/>
</replaceregexp>
</target>
</project>
File: build.properties
# 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.
version=1.4
Related examples in the same category