Commit 449f3ccb authored by Ole Streicher's avatar Ole Streicher

Import Upstream version 0.1+2016.09.08

jar.class.path=../tamfits/tamfits.jar \
../array/array.jar ../hdx/hdx.jar ../ndx/ndx.jar ../jniast/jniast.jar \
<?xml version="1.0"?>
! FITS build file
! This file describes how to build the FITS package from a source
! release. It requires Apache ANT and a Java Development Kit.
! In addition FITS may have requirements for other "core" and
! "third-party" packages to complete the compilation and any
! testing.
! The main targets are:
! build -> compiles the source code
! clean -> cleans up build and dist products
! deinstall -> undo the install target
! dist -> creates the local binary distribution
! export -> creates the full distribution archives
! export-runonly -> creates the runonly distribution archives
! export-source -> creates the source distribution archives
! install -> install distribution into Starlink tree
! install-runonly -> install a runonly distribution into Starlink tree
! jars -> creates the package jar file
! javadocs -> creates the API documentation
! javadoc-sources -> make source files for release API documention
!! test targets yet to be done.
! Authors:
! Peter W. Draper (2-JUL-2002)
! Mark Taylor (13-AUG-2002)
! Version:
! $Id$
<project name="Build file for FITS" default="build" basedir=".">
<!-- If either or both of these files exist then any properties
! contained within them will override those defined here. -->
<property file="${user.home}/"/>
<property file=".properties"/>
<!-- Properties will also be set for all environment variables
! (PATH becomes "env.PATH"), generally not a good
! idea as names are OS dependent -->
<property environment="env"/>
! =================
! Global Properties
! =================
<!-- Directory for the Starlink installation (usually /star/java)-->
<property name="star.dir" value="${basedir}/../../"/>
<!-- Directory to install into (install target, usually /star/java)-->
<property name="star.install" value="${star.dir}"/>
<!-- Directory that contains the Starlink jar tree -->
<property name="star.jar.dir" value="${star.dir}/lib"/>
<!-- Directory that contains the locally built sources (usually
! /star/java/source for full distribution) -->
<property name="" value="${basedir}/../"/>
<!-- Directory that any archives should be placed into. The local
! directory by default -->
<property name="star.archive.dir" value="${basedir}"/>
<!-- URL and package-list for linking against full Java docs -->
<property name="javaapi.url" value=""/>
<property name="javaapi.lis" value="${}/src/docs/javaapi/"/>
<!-- Directory containing native libraries. -->
<property name="star.lib.arch" value="${star.install}/lib/${os.arch}"/>
! ================
! Local Properties
! ================
<!-- Define the package name and current versions -->
<property name="Name" value="FITS"/>
<property name="name" value="fits"/>
<property name="version" value="0.1"/>
<!-- The Java package name -->
<property name="" value=""/>
<!-- Compilation options -->
<property name="debug" value="true"/>
<property name="deprecation" value="false"/>
<property name="optimize" value="true"/>
<property name="source.version" value="1.5"/>
<!-- Extra task options, if any -->
<property name="" value="false"/>
<!-- JUnit test options -->
<property name="junit.fork" value="true"/>
<property name="junit.filtertrace" value="off"/>
<property name="junit.summary" value="no"/>
<!-- Directory containing the package source -->
<property name="src.dir" value="${basedir}/src"/>
<!-- Directory containing the java source (top of the namespace)-->
<property name="java.dir" value="${src.dir}/main"/>
<!-- Directory containing miscellaneous docs -->
<property name="" value="${src.dir}/docs"/>
<!-- Directory containing any script required to execute or setup package-->
<property name="script.dir" value="${src.dir}/script"/>
<!-- Directory containing any third-party jars that should be
! distributed (normally these would belong in a proper package)-->
<property name="src.jars.dir" value="${src.dir}/lib"/>
<!-- Directories for JUnit test cases and related files -->
<property name="tests.dir" value="${src.dir}/testcases"/>
<property name="tests.etc.dir" value="${src.dir}/etc/testcases"/>
<!-- File types that should not be passed through a filterchain when
! copying -->
<property name="unfiltered.files" value="**/*.gif,**/*.jpg,**/*.ico"/>
<!-- Directories to receive the various build components -->
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="" value="${build.dir}/java"/>
<property name="build.tests" value="${build.dir}/testcases"/>
<property name="build.tests.javadocs" value="${build.dir}/javadocs.test/"/>
<!-- Distribution directories, these are created in the current
! directory, unless dist.dir is redefined. Files that will be
! installed under a package name prefixed directory should be
! placed in the ".pkg" variants. Note some build components may
! be placed directly here for efficiency-->
<property name="dist.dir" value="${basedir}"/>
<property name="dist.bin" value="${dist.dir}/bin"/>
<property name="dist.lib" value="${dist.dir}/lib"/>
<property name="dist.src" value="${dist.dir}/src"/>
<property name="" value="${dist.dir}/docs"/>
<property name="dist.etc" value="${dist.dir}/etc"/>
<property name="dist.bin.pkg" value="${dist.bin}/${name}"/>
<property name="dist.lib.pkg" value="${dist.lib}/${name}"/>
<property name="" value="${}/${name}"/>
<property name="dist.etc.pkg" value="${dist.etc}/${name}"/>
<property name="dist.javadocs" value="${}/${name}/javadocs"/>
<!-- Version for zipped/tarred export files. -->
<property name="dist.version" value="${name}-${version}"/>
<!-- File for logging the files that are copied by the install target -->
<property name="install.log" value=".${name}.install"/>
<property name="install.overwrite" value="true"/>
<!-- Local webstart properties. Note this needs a local keystore,
! assumed to be called keystore in $, .. by
! default. -->
<property name="webstart.codebase"
<property name="webstart.alias" value="Starlink-UK"/>
<property name="webstart.keystore" value="${}/keystore"/>
<property name="webstart.keypass" value="Vroomfondel"/>
<property name="webstart.storepass" value="Majikthise"/>
<property name="webstart.starlink_logo" value="starlink_logo_med.gif"/>
<property name="" value="${name}"/>
<!-- Add any local ANT tasks that are required (these should be
! moved to ANT if useful beyond the needs of this package) -->
! =========
! =========
<!-- Name all the jar files that we directly depend on. These will be
! used to produce a full CLASSPATH that is equivalent to that
! generated when these are referenced as optional bundled packages.
! It's best to have a classpath (rather than use the extension
! mechanism) during development as this allows us to compile
! without having to work these dependencies out anyway (may
! be fixed in Java1.5) plus we can execute against locally built
! class files in preference to installed ones (an extra user-define
! defined CLASSPATH can also be used as needed).
<extclasspath id="installed.classpath">
<!-- JUnit -->
<pathelement location="${star.jar.dir}/junit/junit.jar"/>
<!-- TAMFITS -->
<pathelement location="${star.jar.dir}/tamfits/tamfits.jar"/>
<!-- Array -->
<pathelement location="${star.jar.dir}/array/array.jar"/>
<!-- NDX -->
<pathelement location="${star.jar.dir}/ndx/ndx.jar"/>
<!-- JNIAST -->
<pathelement location="${star.jar.dir}/jniast/jniast.jar"/>
<!-- Table -->
<pathelement location="${star.jar.dir}/table/table.jar"/>
<!-- Util -->
<pathelement location="${star.jar.dir}/util/util.jar"/>
<!-- Generate the local build classpath. This is the most difficult
! part of handling the classpath. The local classes will be in
! the "build/classes" part of each package, plus third party
! packages will have their jar files in the "dist" directories.
! Having the third party jars not installed means that building a
! classpath based on their manifest class-paths will not resolve
! all references (these may be to other third party jars, that
! are normally resolved using relative URLs). The way that this
! is resolved is simply to locate all "build/classes" directories
! and all jar files in the "dist" parts and just add these all
! to the classpath. Known third party dependencies are added
! after the "build/classes" directories using the "extclasspath"
! type, just so that they will be referred to first. If this
! doesn't work as expected add the additional classes/jars to
! the extra classpath.
<extclasspath id="built.jarpath">
<pathelement location="${}/junit/lib/junit/junit.jar"/>
<pathelement location="${}/tamfits/lib/tamfits/tamfits.jar"/>
<pathelement location="${}/array/lib/array/array.jar"/>
<pathelement location="${}/ndx/lib/ndx/ndx.jar"/>
<pathelement location="${}/jniast/lib/jniast/jniast.jar"/>
<pathelement location="${}/table/lib/table/table.jar"/>
<pathelement location="${}/util/lib/util/util.jar"/>
<path id="built.classpath">
<!-- All locally built classes -->
<dirset dir="${}">
<include name="*/build/classes"/>
<!-- Directly dependent third party jars -->
<path refid="built.jarpath"/>
<!-- Finally add all "dist" jar files to make sure everything is
! resolved, including relative URLs out of the local package -->
<fileset dir="${}">
<include name="*/lib/*/*.jar"/>
<!-- Note in passing a more elegant way to resolve these jars
! would be to extend <extclasspath> to go looking for dependent
! jars using an additional URL resolving mechanism-->
<!-- Extra user-defined classpath. This is set by the property
! "extra.class.path" (which can be defined locally using say
! -Dextra.class.path=$CLASSPATH on the command line or by setting
! the property in either of the properties files.-->
<property name="extra.class.path" value=""/>
<path id="local.classpath" path="${extra.class.path}"/>
<!-- Unification of all classpaths using extra, built, installed order-->
<path id="classpath">
<path refid="local.classpath"/>
<path refid="built.classpath"/>
<path refid="installed.classpath"/>
<!-- JUnit tests classpath -->
<path id="tests-classpath">
<pathelement location="${build.classes}"/>
<pathelement location="${build.tests}"/>
<pathelement location="${tests.dir}"/>
<pathelement location="${tests.etc.dir}"/>
<path refid="classpath"/>
<!-- Turn this path into a string which is passed to the tests -->
<property name="tests-classpath.value" refid="tests-classpath"/>
<property name="build.tests.loc" location="${build.tests}"/>
! =========================================
! Check availability of direct dependencies
! =========================================
! (could also use this to check optional elements).
! If any of the required dependencies are not present then
! this throws a <fail> and exits the build.
<target name="check_packages"
<!-- Need TAMFITS -->
<available property="tamfits.present"
<fail message="No TAMFITS available" unless="tamfits.present"/>
<!-- Need Array -->
<available property="array.present"
<fail message="No Array available" unless="array.present"/>
<!-- Need NDX -->
<available property="ndx.present"
<fail message="No NDX available" unless="ndx.present"/>
<!-- Need JNIAST -->
<available property="jniast.present"
<fail message="No JNIAST available" unless="jniast.present"/>
<!-- Need Table -->
<available property="table.present"
<fail message="No Table available" unless="table.present"/>
<available property="util.present"
<fail message="No Util available" unless="util.present"/>
<!-- Would like JUnit for testing -->
<available property="junit.present"
! =================
! Prepare the build
! =================
! Do any jobs that are required before any other target can proceed.
<target name="prepare">
<format property="year" pattern="yyyy"/>
<!-- This is a filterchain that can be used to copy-edit files
! that require the package version, current date and/or time -->
<filterchain id="filters">
<token key="VERSION" value="${version}"/>
<token key="DATE" value="${TODAY}"/>
<token key="TIME" value="${TSTAMP}"/>
! ==============
! Build the code
! ==============
! The results of the compilation are placed in the build.classes
! directory. Other files that are also needed in the classes tree
! (i.e. resources like images) should also be copied into place here.
<target name="build"
depends="prepare, check_packages"
description="-> compiles the source code">
<mkdir dir="${build.classes}"/>
<javac srcdir="${java.dir}"
<classpath refid="classpath"/>
<!-- Exclude any Java files in the source tree that should not be
! compiled -->
<exclude name="**/README*"/>
! ============================
! Create the package jar files
! ============================
! Creates a jar file from the build.classes directory tree. If
! jars of sub-components are also required these should be also
! created here. Note this requires a manifest file that defines the
! jars that we directly depend on (using relative URLs) on and, if
! appropriate, defines the application entrance point. The jar
! files should be placed directly in the distribution directories.
<target name="jars"
description="-> creates the package jar file">
<mkdir dir="${dist.lib.pkg}"/>
<jar destfile="${dist.lib.pkg}/${name}.jar"
<attribute name="Built-By" value="${}"/>
<attribute name="Class-Path" value="${jar.class.path}"/>
<zip destfile="${dist.lib.pkg}/${name}" basedir="${java.dir}"/>
<!-- Sign all jar files -->
<signjar jar="${dist.lib.pkg}/${name}.jar"
! ========================================
! Make package JNLP file for Java webstart
! ========================================
<target name="webstart"
description="-> create webstart descriptor files">
<!-- Create a webstart JNLP file for this package, this goes into
! "dist.lib" -->
<mkdir dir="${dist.lib}"/>
<jnlp toFile="${dist.lib}/${name}.jnlp" href="${name}.jnlp"
<vendor>Starlink UK</vendor>
<homepage href="${}"/>
<icon href="${webstart.starlink_logo}"/>
<description>"Starlink FITS classes - Webstart edition"</description>
<j2se version="1.5+"/>
<jar href="fits/fits.jar"/>
<extension name="TAMFITS" href="tamfits.jnlp"/>
<extension name="ARRAY" href="array.jnlp"/>
<extension name="HDX" href="hdx.jnlp"/>
<extension name="NDX" href="ndx.jnlp"/>
<extension name="JNIAST" href="jniast.jnlp"/>
<extension name="TABLE" href="table.jnlp"/>
! =================================
! Configures the local distribution
! =================================
! Completes the creation of the local distribution into the
! directory "dist.dir" (usually the current directory).
! Installations and exports are based on the state of this
! distribution, so it must be performed before installation or
! export. If the "runonly.install" parameter is set then this
! target is skipped (needed for releases that do not have
! source). Much of the work of getting the distribution
! directories into the correct state is performed by the dependency
! targets.
<target name="dist"
description="-> configures the local binary distribution">
<!-- Make sure all the distribution directories exist -->
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.lib.pkg}"/>
<mkdir dir="${}"/>
<!-- Set permissions on contents of distribution directories -->
<chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
<chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
! ========================
! Create the full releases
! ========================
! Creates the full "zip", "tar" and "bzip" archives of the
! products of the "dist" target and the source directory.
! The archives are designed to be unpacked such that the resultant
! directory layout can be either used as a local distribution, or
! installed into a Starlink tree (installation requires the
! Starlink modified version of ANT, use as a local distribution
! may need special handling of the extension path). This version
! can also be used to rebuild the package from source.
! The archive names are ${dist.version}.<ext>.
<target name="export"
description="-> creates the full distribution archives">
<antcall target="create_archives">
<param name="source.required" value="true"/>
<param name="binary.required" value="true"/>
<param name="" value="${dist.version}"/>
! ==========================
! Create the source releases
! ==========================
! Creates the source only "zip", "tar" and "bzip" archives.
! These can be used to rebuild the package (requires the Starlink
! modified version of ANT).
! The archive names are ${dist.version}-src.<ext>.
<target name="export-source"
description="-> creates the source distribution archives">
<antcall target="create_archives">
<param name="source.required" value="true"/>
<param name="" value="${dist.version}-src"/>
! ===========================
! Create the runonly releases
! ===========================
! Creates the runonly "zip", "tar" and "bzip" archives of the
! products of the "dist" target. The archives are designed to be
! unpacked such that the resultant directory layout can be either
! used as a local distribution, or installed into a Starlink tree
! (installation requires the Starlink modified version of ANT).
! The archive names are ${dist.version}-bin.<ext>.
<target name="export-runonly"
description="-> creates the runonly distribution archives">
<antcall target="create_archives">
<param name="binary.required" value="true"/>
<param name="" value="${dist.version}-bin"/>
! Create release archives of the various types required. Use this
! by an <antcall> and set the property "" to define what
! name to use for the outfile files. The archives are written into
! the directory ${star.archive.dir} (the local directory by default).
! If the property "binary.required" is set then the files needed
! for a run-only release are included and if "source.required" is
! defined the source code is also included.
<target name="create_archives"
<mkdir dir="${star.archive.dir}"/>
<zip destfile="${star.archive.dir}/${}.zip">
<!-- All releases have the documentation and build file -->
<zipfileset dir="${}" prefix="${name}/docs"/>
<zipfileset dir="${dist.dir}" includes="build.xml" prefix="${name}"/>
<!--<zipfileset dir="${dist.bin}" prefix="${name}/bin">
<include name="**" if="binary.required"/>
<zipfileset dir="${dist.lib}" prefix="${name}/lib">
<include name="**" if="binary.required"/>
<!--<zipfileset dir="${dist.etc}" prefix="${name}/etc">
<include name="**" if="binary.required"/>
<zipfileset dir="${src.dir}" prefix="${name}/src">
<include name="**" if="source.required"/>
<!-- Exclude local development support from distribution-->
<exclude name="local/**" if="source.required"/>
<!-- Note: creating a tar file with empty directories doesn't
! work, so the directory structure may be incomplete -->
<tar longfile="gnu" destfile="${}.tar">
<!-- All releases have the documentation and build file -->
<tarfileset dir="${}" prefix="${name}/docs"/>
<tarfileset dir="${dist.dir}" prefix="${name}">
<include name="build.xml"/>
<!--<tarfileset dir="${dist.bin}" prefix="${name}/bin">
<include name="**" if="binary.required"/>
<tarfileset dir="${dist.lib}" prefix="${name}/lib">
<include name="**" if="binary.required"/>
<!--<tarfileset dir="${dist.etc}" prefix="${name}/etc">
<include name="**" if="binary.required"/>
<tarfileset dir="${src.dir}" prefix="${name}/src">
<include name="**" if="source.required"/>
<exclude name="local/**" if="source.required"/>
<gzip zipfile="${star.archive.dir}/${}.tar.gz"
<bzip2 zipfile="${star.archive.dir}/${}.tar.bz2"
<delete file="${}.tar"/>
! ============================================
! Cleans up build and distribution directories
! ============================================
<target name="clean"
description="-> cleans up build and dist products">
<delete dir="${build.dir}"/>
<delete dir="${dist.bin}"/>
<delete dir="${dist.lib}"/>
<delete dir="${}"/>
<delete dir="${dist.etc}"/>
! ================================
! Install into the "Starlink" tree
! ================================
! Installs the "dist" target products into another set of
! directories.
! An installed system is potentially "undoable" as the copied names
! and package-specific directories are logged to "${install.log}".
<target name="install"
description="-> install distribution into Starlink tree">
<!-- Installation based directories (based on "star.install")-->
<property name="star.bin" value="${star.install}/bin"/>
<property name="star.lib" value="${star.install}/lib"/>
<property name="star.etc" value="${star.install}/etc"/>
<property name="" value="${star.install}/docs"/>
<property name="star.bin.pkg" value="${star.bin}/${name}"/>
<property name="star.lib.pkg" value="${star.lib}/${name}"/>
<property name="star.etc.pkg" value="${star.etc}/${name}"/>
<property name="" value="${}/${name}"/>
<mkdir dir="${star.install}"/>
<mkdir dir="${star.lib.pkg}"/>
<mkdir dir="${}"/>
<loggedcopy todir="${star.lib}"
<fileset dir="${dist.lib}">
<include name="**/*.jnlp"/>
<include name="**/*.jar"/>
<include name="**/*.zip"/>
<!-- Also remove the package-specific directory.
! Note exact format is required.-->
<echo file="${install.log}" append="true">${star.lib.pkg}
<loggedcopy todir="${}"
<fileset dir="${}" excludes="${unfiltered.files}"/>
<filterchain refid="filters"/>
<loggedcopy todir="${}" filtering="false"
<fileset dir="${}" includes="${unfiltered.files}"/>
<echo file="${install.log}" append="true">${}
! ========================================
! Install runonly into the "Starlink" tree
! ========================================
! Do an install using only the contents of a binary release (a