From: Ole Streicher <olebole@debian.org>
Date: Fri, 17 Feb 2017 15:27:12 +0100
Subject: Fix build.xml for use outside of starjava

This includes the following changes:

 * Rename the `extclasspath` elements to `path`. With ant >= 1.6, there is no
   difference (and before, the difference was not relevant for Debian)

 * Ignore local property files

 * Change the starlink installation dir to the standard Java path /usr/share/java/

 * Prefix the name by `starlink-`

 * Adjust the build and test classpaths for Debian (also for CI tests)

 * Set a class path in the jar manifest

 * Set the source file encoding (cp1252), but not the source version (deprecated)

 * Don't sign the jarfile
---
 build.xml | 103 ++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 56 insertions(+), 47 deletions(-)

diff --git a/build.xml b/build.xml
index 4f3a5dd..521f85f 100644
--- a/build.xml
+++ b/build.xml
@@ -37,12 +37,6 @@
  !-->
 
 <project name="Build file for TOPCAT" 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}/.stardev.properties"/>
-  <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 -->
@@ -55,13 +49,13 @@
    !-->
 
   <!-- Directory for the Starlink installation (usually /star/java)-->
-  <property name="star.dir" value="${basedir}/../../"/>
+  <property name="star.dir" value="/usr/share/java"/>
 
   <!-- 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"/>
+  <property name="star.jar.dir" value="${star.dir}"/>
 
   <!-- Directory that contains the locally built sources (usually
    !   /star/java/source for full distribution) -->
@@ -82,8 +76,8 @@
    !-->
 
   <!-- Define the package name and current versions -->
-  <property name="Name" value="TOPCAT"/>
-  <property name="name" value="topcat"/>
+  <property name="Name" value="Starjava TOPCAT"/>
+  <property name="name" value="starlink-topcat"/>
   <property name="version" value="4.6-2"/>
 
   <!-- The Java package name -->
@@ -122,6 +116,7 @@
   <!-- 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"/>
+  <mkdir dir="${src.jars.dir}"/>
 
   <!-- Directory containing any JNI source code -->
   <property name="src.jni.dir" value="${src.dir}/jni"/>
@@ -212,21 +207,39 @@
    !   class files in preference to installed ones (an extra user-define
    !   defined CLASSPATH can also be used as needed).
    !-->
-  <extclasspath id="installed.classpath">
-
-    <!-- Table -->
-    <pathelement location="${star.jar.dir}/table/table.jar"/>
-
-    <!-- TTOOLS -->
-    <pathelement location="${star.jar.dir}/ttools/ttools.jar"/>
-
-    <!-- Help -->
-    <pathelement location="${star.jar.dir}/help/jhall.jar"/>
-
-    <!-- Util -->
-    <pathelement location="${star.jar.dir}/util/util.jar"/>
+  <path id="installed.classpath">
+    <pathelement location="${star.jar.dir}/starlink-table.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-ttools.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-util.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-datanode.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-fits.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-task.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-vo.jar"/>
+    <pathelement location="${star.jar.dir}/starlink-votable.jar"/>
+    <pathelement location="${star.jar.dir}/jhall.jar"/>
+    <pathelement location="${star.jar.dir}/jel.jar"/>
+    <pathelement location="${star.jar.dir}/jsamp.jar"/>
+    <pathelement location="${star.jar.dir}/fits.jar"/>
+    <pathelement location="${star.jar.dir}/cds.moc.jar"/>
+	   <pathelement location="/usr/lib/jvm/default-java/lib/tools.jar"/>
+  </path>
 
-  </extclasspath>
+  <path id="jar.classpath">
+    <pathelement location="${dist.lib.pkg}/starlink-table.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-ttools.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-util.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-datanode.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-fits.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-task.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-vo.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-votable.jar"/>
+    <pathelement location="${dist.lib.pkg}/starlink-topcat_demo.jar"/>
+    <pathelement location="${dist.lib.pkg}/jhall.jar"/>
+    <pathelement location="${dist.lib.pkg}/jel.jar"/>
+    <pathelement location="${dist.lib.pkg}/jsamp.jar"/>
+    <pathelement location="${dist.lib.pkg}/fits.jar"/>
+    <pathelement location="${dist.lib.pkg}/cds.moc.jar"/>
+  </path>
 
   <!-- Generate the local build classpath. This is the most difficult
    !   part of handling the classpath. The local classes will be in
@@ -244,12 +257,7 @@
    !   doesn't work as expected add the additional classes/jars to
    !   the extra classpath.
    !-->
-  <extclasspath id="built.jarpath">
-    <pathelement location="${star.build.jar}/util/lib/util/util.jar"/>
-    <pathelement location="${star.build.jar}/table/lib/table/table.jar"/>
-    <pathelement location="${star.build.jar}/ttools/lib/ttools/ttools.jar"/>
-    <pathelement location="${star.build.jar}/help/lib/help/jhall.jar"/>
-  </extclasspath>
+  <path id="built.jarpath"/>
 
   <!-- "Local" third party jars. Normally these will be kept in their
    !   own third party package, but may be kept here temporarily, say
@@ -310,7 +318,10 @@
     <pathelement location="${tests.dir}"/>
     <pathelement location="${tests.etc.dir}"/>
     <pathelement location="${star.jar.dir}/xdoc/xdoc.jar"/>
+    <pathelement location="${build.etc}/demo"/>
     <path refid="classpath"/>
+    <pathelement location="${star.jar.dir}/${name}.jar"/>
+    <pathelement location="${star.jar.dir}/junit.jar"/>
   </path>
 
   <!-- Need installed JNIAST for javadoc fun and games - this seems to do it
@@ -422,7 +433,8 @@
            destdir="${build.classes}"
            debug="${debug}"
            deprecation="${deprecation}"
-           source="${source.version}"
+           encoding="cp1252"
+           includeantruntime="false"
            optimize="${optimize}">
 
       <classpath refid="classpath"/>
@@ -510,7 +522,7 @@
              public="true"
              destdir="${build.javadocs}"
              classpathref="classpath"
-             source="${source.version}">
+             encoding="cp1252">
       <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
         <include name="*.java"/>
         <exclude name="Sog.java"/>
@@ -671,6 +683,10 @@
           description="-> creates the package jar file(s)">
 
     <mkdir dir="${dist.lib.pkg}"/>
+    <manifestclasspath property="jar.class.path"
+                       jarfile="${dist.lib.pkg}/${name}.jar">
+      <classpath refid="jar.classpath" />
+    </manifestclasspath>
     <jar destfile="${dist.lib.pkg}/${name}.jar">
       <fileset dir="${build.classes}"/>
       <fileset dir="${build.javadocs}"/>
@@ -688,14 +704,6 @@
     <jar destfile="${dist.lib.pkg}/${name}_demo.jar"
          basedir="${build.etc}/demo"/>
 
-    <!-- Sign all jar files -->
-    <signjar alias="${webstart.alias}"
-             keystore="${webstart.keystore}"
-             keypass="${webstart.keypass}"
-             storepass="${webstart.storepass}">
-      <fileset dir="${dist.lib}" includes="**/*.jar **/*.zip"/>
-    </signjar>
-
   </target>
 
   <!--
@@ -1247,7 +1255,7 @@
              windowtitle="${Name} API"
              doctitle="${Name}"
              defaultexcludes="yes"
-             source="${source.version}"
+             encoding="cp1252"
              classpathref="classpath">
 
       <!-- Get a list of directories that name all the potential
@@ -1519,7 +1527,7 @@
              public="true"
              additionalparam="-gen -o ${build.docs}/general-javadocs.xml" 
              classpathref="classpath"
-             source="${source.version}">
+             encoding="cp1252">
       <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
         <include name="*.java"/>
         <exclude name="Sog.java"/>
@@ -1531,7 +1539,7 @@
              public="true"
              additionalparam="-act -o ${build.docs}/activation-javadocs.xml" 
              classpathref="classpath"
-             source="${source.version}">
+             encoding="cp1252">
       <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
         <include name="*.java"/>
         <exclude name="Sog.java"/>
@@ -1543,7 +1551,7 @@
              public="true"
              additionalparam="-gen -headonly -o ${build.docs}/general-classes-javadocs.xml"
              classpathref="classpath"
-             source="${source.version}">
+             encoding="cp1252">
       <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
         <include name="*.java"/>
         <exclude name="Sog.java"/>
@@ -1555,7 +1563,7 @@
              public="true"
              additionalparam="-act -headonly -o ${build.docs}/activation-classes-javadocs.xml"
              classpathref="classpath"
-             source="${source.version}">
+             encoding="cp1252">
       <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
         <include name="*.java"/>
         <exclude name="Sog.java"/>
@@ -1620,7 +1628,7 @@
    !   =================
    !-->
   <target name="compile-tests"
-          depends="build"
+          depends="build,build_demo"
           if="junit.present">
 
     <mkdir dir="${build.tests}"/>
@@ -1628,7 +1636,8 @@
     <javac srcdir="${tests.dir}"
            destdir="${build.tests}"
            debug="${debug}"
-           source="${source.version}"
+           encoding="cp1252"
+           includeantruntime="false"
            deprecation="${deprecation}" >
 
       <classpath refid="tests-classpath"/>
