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

733 lines (638 sloc) 28.21 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="pivot" default="build">
<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"/>
<!-- 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="folder.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.web" value="${ant.project.name}-web-${version}.jar" />
<property name="jar.web.server" value="${ant.project.name}-web-${version}.server.jar" />
<property name="jar.wtk" value="${ant.project.name}-wtk-${version}.jar" />
<property name="jar.wtk.terra" value="${ant.project.name}-wtk-${version}.terra.jar" />
<property name="jar.wtk.obsidian" value="${ant.project.name}-wtk-${version}.obsidian.jar" />
<property name="jar.tutorials" value="${ant.project.name}-tutorials-${version}.jar" />
<property name="jar.demos" value="${ant.project.name}-demos-${version}.jar" />
<property name="jar.tools" value="${ant.project.name}-tools-${version}.jar" />
<!-- Ant version check -->
<fail message="Building Pivot requires Apache Ant 1.7 or greater.">
<condition>
<not>
<contains string="${ant.version}" substring="1.7"/>
</not>
</condition>
</fail>
<!-- Compile macro -->
<macrodef name="compile">
<attribute name="project"/>
<attribute name="srcDir" default="src"/>
<element name="classpath-elements" optional="true" implicit="true"/>
<sequential>
<!-- JDK version check -->
<fail message="Building Pivot requires JDK 1.6 or greater.">
<condition>
<not>
<or>
<equals arg1="${ant.java.version}" arg2="1.6"/>
<equals arg1="${ant.java.version}" arg2="1.7"/>
</or>
</not>
</condition>
</fail>
<mkdir dir="@{project}/${folder.bin}"/>
<javac srcdir="@{project}/@{srcDir}"
destDir="@{project}/${folder.bin}"
includejavaruntime="true"
deprecation="${compiler.deprecation}"
debug="${compiler.debug}"
target="${compiler.target}"
encoding="${compiler.encoding}"
failonerror="true">
<compilerarg line="${compiler.arg}"/>
<classpath>
<classpath-elements/>
</classpath>
</javac>
</sequential>
</macrodef>
<!-- Test macro -->
<macrodef name="test">
<attribute name="project"/>
<element name="classpath-elements" optional="true" implicit="true"/>
<sequential>
<!-- JUnit check -->
<fail message="JUnit 4 not found. Please see the BUILD file for more information.">
<condition>
<not>
<available classname="org.junit.Test"/>
</not>
</condition>
</fail>
<compile project="@{project}" srcDir="test">
<classpath-elements/>
</compile>
<echo message="@{project}: Executing test cases"/>
<condition property="test.formatter">
<istrue value="${test.verbose}"/>
</condition>
<junit fork="true">
<classpath>
<classpath-elements/>
</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="jarFile"/>
<attribute name="title"/>
<element name="jar-elements" implicit="true"/>
<sequential>
<mkdir dir="${folder.lib}"/>
<jar destfile="${folder.lib}/@{jarFile}" index="${compiler.indexJars}">
<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>
<jar-elements/>
</jar>
</sequential>
</macrodef>
<macrodef name="clean-www">
<attribute name="project"/>
<sequential>
<delete dir="@{project}/www/lib"/>
<delete>
<fileset dir="@{project}/www">
<include name="*.html"/>
<include name="*.jnlp"/>
<exclude name="*.template.*"/>
<exclude name="index.html"/>
</fileset>
</delete>
</sequential>
</macrodef>
<!-- Aggregate targets -->
<target name="build" description="Compiles all packages"
depends="charts, core, web, wtk, tutorials, demos, tools"/>
<target name="package"
depends="charts-package, core-package, web-package, wtk-package, tutorials-package, demos-package, tools-package"/>
<target name="test"
depends="core-test, web-test, wtk-test"/>
<target name="clean" description="Removes all build artifacts"
depends="charts-clean, core-clean, web-clean, wtk-clean, tutorials-clean, demos-clean, tools-clean">
<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="charts/lib" includes="**/*.jar"/>
<fileset dir="web/lib" includes="**/*.jar"/>
<path refid="classpath.javalib"/>
</classpath>
<packageset dir="charts/src" includes="**/*"/>
<packageset dir="core/src" includes="**/*"/>
<packageset dir="web/src" includes="**/*"/>
<packageset dir="wtk/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>
<!-- Charts -->
<target name="charts" depends="core, wtk">
<compile project="charts">
<pathelement location="core/${folder.bin}"/>
<pathelement location="wtk/${folder.bin}"/>
</compile>
</target>
<target name="charts-package" depends="charts">
<package jarFile="${jar.charts}" title="Charts">
<fileset dir="charts/${folder.bin}"/>
<fileset dir="charts/src">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
</target>
<target name="charts-clean">
<delete dir="charts/${folder.bin}"/>
<delete file="${folder.lib}/${jar.charts}"/>
</target>
<!-- Core -->
<target name="core">
<compile project="core"/>
</target>
<target name="core-package" depends="core">
<package jarFile="${jar.core}" title="Core">
<fileset dir="core/${folder.bin}"/>
<fileset dir="core/src">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
</target>
<target name="core-clean">
<delete dir="core/${folder.bin}"/>
<delete file="${folder.lib}/${jar.core}"/>
</target>
<target name="core-test" depends="core">
<test project="core">
<pathelement location="core/${folder.bin}"/>
<pathelement location="core/test"/>
</test>
</target>
<!-- Web -->
<target name="web" depends="core">
<compile project="web">
<pathelement location="core/${folder.bin}"/>
<fileset dir="web/lib" includes="**/*.jar"/>
</compile>
</target>
<target name="web-package" depends="web">
<package jarFile="${jar.web}" title="Web Queries">
<fileset dir="web/${folder.bin}" excludes="org/apache/pivot/web/server/**"/>
<fileset dir="web/src">
<exclude name="org/apache/pivot/web/server/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
<package jarFile="${jar.web.server}" title="Web Queries Server">
<fileset dir="web/${folder.bin}" includes="org/apache/pivot/web/server/*"/>
<fileset dir="web/src">
<include name="org/apache/pivot/web/server/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
</target>
<target name="web-clean">
<delete dir="web/${folder.bin}"/>
<delete file="${folder.lib}/${jar.web}"/>
<delete file="${folder.lib}/${jar.web.server}"/>
<clean-www project="web"/>
</target>
<target name="web-test" depends="core, web, wtk">
<test project="web">
<pathelement location="core/${folder.bin}"/>
<pathelement location="web/${folder.bin}"/>
<fileset dir="web/lib" includes="**/*.jar"/>
</test>
</target>
<!-- WTK -->
<target name="wtk" depends="core">
<!-- Fail descriptively if the user's classpath is not set up correctly -->
<fail message="LiveConnect not found. Please see the BUILD file for more information.">
<condition>
<not>
<available classname="netscape.javascript.JSObject" classpathref="classpath.javalib"/>
</not>
</condition>
</fail>
<compile project="wtk">
<pathelement location="core/${folder.bin}"/>
<path refid="classpath.javalib"/>
</compile>
</target>
<target name="wtk-package" depends="wtk">
<package jarFile="${jar.wtk}" title="WTK">
<fileset dir="wtk/${folder.bin}">
<exclude name="org/apache/pivot/wtk/skin/terra/**"/>
<exclude name="org/apache/pivot/wtk/skin/obsidian/**"/>
</fileset>
<fileset dir="wtk/src">
<exclude name="org/apache/pivot/wtk/skin/terra/**"/>
<exclude name="org/apache/pivot/wtk/skin/obsidian/**"/>
<exclude name="META-INF/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
<package jarFile="${jar.wtk.terra}" title="WTK Terra Theme">
<fileset dir="wtk/${folder.bin}" includes="org/apache/pivot/wtk/skin/terra/**"/>
<fileset dir="wtk/src">
<include name="org/apache/pivot/wtk/skin/terra/**"/>
<include name="META-INF/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
<package jarFile="${jar.wtk.obsidian}" title="WTK Obsidian Theme">
<fileset dir="wtk/${folder.bin}" includes="org/apache/pivot/wtk/skin/obsidian/**"/>
<fileset dir="wtk/src">
<include name="org/apache/pivot/wtk/skin/obsidian/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
</target>
<target name="wtk-clean">
<delete dir="wtk/${folder.bin}"/>
<delete file="${folder.lib}/${jar.wtk}"/>
<delete file="${folder.lib}/${jar.wtk.terra}"/>
<delete file="${folder.lib}/${jar.wtk.obsidian}"/>
</target>
<target name="wtk-test" depends="core, wtk">
<compile project="wtk" srcDir="test">
<pathelement location="core/${folder.bin}"/>
<pathelement location="wtk/${folder.bin}"/>
</compile>
</target>
<!-- Tutorials -->
<target name="tutorials" depends="core, wtk, web">
<compile project="tutorials">
<pathelement location="core/${folder.bin}"/>
<pathelement location="web/${folder.bin}"/>
<pathelement location="wtk/${folder.bin}"/>
</compile>
</target>
<target name="tutorials-package" depends="tutorials">
<package jarFile="${jar.tutorials}" title="Tutorials">
<fileset dir="tutorials/${folder.bin}"/>
<fileset dir="tutorials/src">
<exclude name="**/*.java"/>
</fileset>
</package>
</target>
<target name="tutorials-clean">
<delete dir="tutorials/${folder.bin}"/>
<delete file="${folder.lib}/${jar.tutorials}"/>
<clean-www project="tutorials"/>
</target>
<!-- Demos -->
<target name="demos" depends="core, wtk, web">
<compile project="demos">
<pathelement location="core/${folder.bin}"/>
<pathelement location="web/${folder.bin}"/>
<pathelement location="wtk/${folder.bin}"/>
</compile>
</target>
<target name="demos-package" depends="demos">
<package jarFile="${jar.demos}" title="Demos">
<fileset dir="demos/${folder.bin}"/>
<fileset dir="demos/src">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</package>
</target>
<target name="demos-clean">
<delete dir="demos/${folder.bin}"/>
<delete file="${folder.lib}/${jar.demos}"/>
<clean-www project="demos"/>
</target>
<!-- Tools -->
<target name="tools" depends="core, wtk, web">
<compile project="tools">
<pathelement location="core/${folder.bin}"/>
<pathelement location="web/${folder.bin}"/>
<pathelement location="wtk/${folder.bin}"/>
</compile>
</target>
<target name="tools-package" depends="tools">
<package jarFile="${jar.tools}" title="Tools">
<fileset dir="tools/${folder.bin}"/>
<fileset dir="tools/src">
<exclude name="**/*.java"/>
</fileset>
</package>
</target>
<target name="tools-clean">
<delete dir="tools/${folder.bin}"/>
<delete file="${folder.lib}/${jar.tools}"/>
</target>
<!-- Package source distribution -->
<target name="dist" description="Generates source release in ${folder.dist}"
depends="trim-whitespace">
<mkdir dir="${folder.dist}/${folder.release}-src"/>
<!-- Copy the source files to the release folder -->
<copy todir="${folder.dist}/${folder.release}-src">
<fileset dir=".">
<include name="**/*"/>
<!-- Exclude hidden files and folders -->
<exclude name="**/.*/**"/>
<!-- Exclude project folder -->
<exclude name="project/**"/>
<!-- 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}/${folder.release}-src.zip" level="9">
<fileset dir="${folder.dist}" includes="${folder.release}-src/**"/>
</zip>
<checksum file="${folder.dist}/${folder.release}-src.zip" algorithm="md5"/>
<checksum file="${folder.dist}/${folder.release}-src.zip" algorithm="sha"/>
<!-- Create .tar.gz archive -->
<tar destfile="${folder.dist}/${folder.release}-src.tar" longfile="gnu">
<fileset dir="${folder.dist}" includes="${folder.release}-src/**"/>
</tar>
<gzip src="${folder.dist}/${folder.release}-src.tar" destfile="${folder.dist}/${folder.release}-src.tar.gz"/>
<delete file="${folder.dist}/${folder.release}-src.tar"/>
<checksum file="${folder.dist}/${folder.release}-src.tar.gz" algorithm="md5"/>
<checksum file="${folder.dist}/${folder.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}/${folder.release}/lib"/>
<mkdir dir="${folder.install}/${folder.release}/doc"/>
<mkdir dir="${folder.install}/${folder.release}/webapps"/>
<!-- Copy base files to the install folder -->
<copy todir="${folder.install}/${folder.release}">
<fileset dir=".">
<include name="DISCLAIMER"/>
<include name="LICENSE"/>
<include name="NOTICE"/>
<include name="README"/>
<include name="RELEASE-NOTES"/>
</fileset>
</copy>
<!-- Copy release binaries -->
<copy todir="${folder.install}/${folder.release}/lib">
<fileset dir="${folder.lib}">
<include name="${jar.charts}"/>
<include name="${jar.core}"/>
<include name="${jar.web}"/>
<include name="${jar.web.server}"/>
<include name="${jar.wtk}"/>
<include name="${jar.wtk.terra}"/>
<include name="${jar.tools}"/>
</fileset>
</copy>
<!-- Copy documentation -->
<copy todir="${folder.install}/${folder.release}/doc">
<fileset dir="${folder.doc}"/>
</copy>
<!-- Copy webapps -->
<copy todir="${folder.install}/${folder.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}/${folder.release}.zip" level="9">
<fileset dir="${folder.install}" includes="${folder.release}/**"/>
</zip>
<checksum file="${folder.install}/${folder.release}.zip" algorithm="md5"/>
<checksum file="${folder.install}/${folder.release}.zip" algorithm="sha"/>
<!-- Create .tar.gz archive -->
<tar destfile="${folder.install}/${folder.release}.tar" longfile="gnu">
<fileset dir="${folder.install}" includes="${folder.release}/**"/>
</tar>
<gzip src="${folder.install}/${folder.release}.tar" destfile="${folder.install}/${folder.release}.tar.gz"/>
<delete file="${folder.install}/${folder.release}.tar"/>
<checksum file="${folder.install}/${folder.release}.tar.gz" algorithm="md5"/>
<checksum file="${folder.install}/${folder.release}.tar.gz" algorithm="sha"/>
</target>
<!-- Generate deployment files -->
<target name="deploy" depends="clean, package">
<!-- Sign JARS -->
<mkdir dir="${folder.lib}/signed"/>
<copy todir="${folder.lib}/signed">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*.server.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"/>
<!-- Define filters for processing HTML files -->
<filter token="project_name" value="${ant.project.name}"/>
<filter token="version" value="${version}"/>
<!-- Deploy demos -->
<mkdir dir="demos/www/lib"/>
<copy todir="demos/www/lib">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*.server.jar"/>
</fileset>
</copy>
<!-- Generate demo HTML and JNLP files -->
<copy todir="demos/www" filtering="true">
<fileset dir="demos/www">
<include name="*.template.html"/>
</fileset>
<mapper type="glob" from="*.template.html" to="*.html"/>
</copy>
<copy todir="demos/www" filtering="true">
<fileset dir="demos/www">
<include name="*.template.jnlp"/>
</fileset>
<mapper type="glob" from="*.template.jnlp" to="*.jnlp"/>
</copy>
<!-- Generate demos WAR -->
<war destfile="${folder.lib}/${ant.project.name}-demos.war" webxml="demos/web.xml">
<fileset dir="demos/www">
<exclude name="*.template.html"/>
</fileset>
</war>
<!-- Deploy tutorials -->
<mkdir dir="tutorials/www/lib"/>
<copy todir="tutorials/www/lib">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*-demos*.jar"/>
<exclude name="*.server.jar"/>
</fileset>
</copy>
<!-- Generate tutorial HTML and JNLP files -->
<copy todir="tutorials/www" filtering="true">
<fileset dir="tutorials/www">
<include name="*.template.html"/>
</fileset>
<mapper type="glob" from="*.template.html" to="*.html"/>
</copy>
<copy todir="tutorials/www" filtering="true">
<fileset dir="tutorials/www">
<include name="*.template.jnlp"/>
</fileset>
<mapper type="glob" from="*.template.jnlp" to="*.jnlp"/>
</copy>
<!-- Generate tutorials WAR -->
<war destfile="${folder.lib}/${ant.project.name}-tutorials.war" webxml="tutorials/web.xml">
<fileset dir="tutorials/www">
<exclude name="*.template.html"/>
</fileset>
</war>
<!-- Deploy web test -->
<mkdir dir="web/www/lib"/>
<jar destfile="web/www/lib/${ant.project.name}-web-${version}.test.jar" index="${compiler.indexJars}">
<fileset dir="web/${folder.bin}"
includes="org/apache/pivot/web/test/**"
excludes="org/apache/pivot/web/test/server/**"/>
<fileset dir="web/test">
<exclude name="org/apache/pivot/web/test/server/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</fileset>
</jar>
<copy todir="web/www/lib">
<fileset dir="${folder.lib}">
<include name="*.jar"/>
<exclude name="*-charts*.jar"/>
<exclude name="*-demos*.jar"/>
<exclude name="*-tutorials*.jar"/>
<exclude name="*.server.jar"/>
</fileset>
</copy>
<!-- Generate web test HTML and JNLP files -->
<copy todir="web/www" filtering="true">
<fileset dir="web/www">
<include name="*.template.html"/>
</fileset>
<mapper type="glob" from="*.template.html" to="*.html"/>
</copy>
<copy todir="web/www" filtering="true">
<fileset dir="web/www">
<include name="*.template.jnlp"/>
</fileset>
<mapper type="glob" from="*.template.jnlp" to="*.jnlp"/>
</copy>
<!-- Generate web test WAR -->
<war destfile="${folder.lib}/${ant.project.name}_web_test.war" webxml="web/web.xml">
<fileset dir="web/www">
<exclude name="*.template.html"/>
</fileset>
<classes dir="web/${folder.bin}">
<include name="org/apache/pivot/web/test/server/**"/>
</classes>
<classes dir="web/test">
<include name="org/apache/pivot/web/test/server/**"/>
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
</classes>
<lib dir="${folder.lib}">
<include name="${jar.core}"/>
<include name="${jar.web.server}"/>
</lib>
</war>
</target>
<!-- Remove trailing white space in all source files -->
<target name="trim-whitespace">
<fileset id="trimfiles" dir=".">
<include name="BUILD"/>
<include name="DISCLAIMER"/>
<include name="LICENSE"/>
<include name="NOTICE"/>
<include name="README"/>
<include name="RELEASE-NOTES"/>
<include name="**/*.java"/>
<include name="**/*.html"/>
<include name="**/*.txt"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
<include name="**/*.wtkx"/>
<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>
Jump to Line
Something went wrong with that request. Please try again.