From: Ole Streicher <olebole@debian.org>
Date: Wed, 15 Feb 2017 14:47:20 +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 | 60 ++++++++++++++++++++++++++----------------------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/build.xml b/build.xml
index a3ab727..7d85537 100644
--- a/build.xml
+++ b/build.xml
@@ -30,12 +30,6 @@
  !-->
 
 <project name="Build file for ARRAY" 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 -->
@@ -48,13 +42,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) -->
@@ -79,8 +73,8 @@
    !-->
 
   <!-- Define the package name and current versions -->
-  <property name="Name" value="ARRAY"/>
-  <property name="name" value="array"/>
+  <property name="Name" value="Starjava ARRAY"/>
+  <property name="name" value="starlink-array"/>
   <property name="version" value="0.2"/>
 
   <!-- The Java package name -->
@@ -186,12 +180,13 @@
    !   class files in preference to installed ones (an externally
    !   defined CLASSPATH can also be used as needed).
    !-->
-  <extclasspath id="installed.classpath">
-
-    <!-- Util -->
-    <pathelement location="${star.jar.dir}/util/util.jar"/>
+  <path id="installed.classpath">
+    <pathelement location="${star.jar.dir}/starlink-util.jar"/>
+  </path>
 
-  </extclasspath>
+  <path id="jar.classpath">
+    <pathelement location="${dist.lib.pkg}/starlink-util.jar"/>
+  </path>
 
   <!-- Generate the local build classpath. This is the most difficult
    !   part of handling the classpath. The local classes will be in
@@ -209,11 +204,7 @@
    !   first. If this doesn't work as expected add the additional
    !   classes/jars to the external classpath.
    !-->
-  <extclasspath id="built.jarpath">
-
-    <pathelement location="${star.build.dir}/util/lib/util/util.jar"/>
-
-  </extclasspath>
+  <path id="built.jarpath"/>
 
   <path id="built.classpath">
 
@@ -253,11 +244,13 @@
 
   <!-- JUnit tests classpath -->
   <path id="tests-classpath">
+    <pathelement location="${star.jar.dir}/junit.jar"/>
     <pathelement location="${build.classes}"/>
     <pathelement location="${build.tests}"/>
     <pathelement location="${tests.dir}"/>
     <pathelement location="${tests.etc.dir}"/>
     <path refid="classpath"/>
+    <pathelement location="${star.jar.dir}/${name}.jar"/>
   </path>
 
   <!-- Turn this path into a string which is passed to the tests -->
@@ -279,7 +272,6 @@
     <available property="util.present"
                classpathref="classpath"
                classname="uk.ac.starlink.util.GenericNioBuffer"/>
-    <fail message="No Util available" unless="util.present"/>
 
     <!-- Need JUnit for testcases, not essential -->
     <condition property="testframework.present">
@@ -354,13 +346,14 @@
 
 
   <!-- Build the java class files. -->
-  <target name="build_classes" depends="assemble_java">
+  <target name="build_classes" depends="assemble_java" unless="runonly.install">
     <mkdir dir="${build.classes}"/>
     <javac srcdir="${build.java}"
            destdir="${build.classes}"
            debug="${debug}"
            deprecation="${deprecation}"
-           source="${source.version}"
+           encoding="cp1252"
+           includeantruntime="false"
            optimize="${optimize}">
 
       <classpath refid="classpath"/>
@@ -378,7 +371,7 @@
    !   Some of these are copied direct from the source directory, some
    !   are generated by running java classes in the prep directory.
    !-->
-  <target name="assemble_java">
+  <target name="assemble_java" unless="runonly.install">
     <condition property="java.assembled">
       <and>
         <uptodate srcfile="${src.dir}/prep/WriteConvertWorker.java"
@@ -408,7 +401,8 @@
     <mkdir dir="${build.dir}/prep"/>
     <javac srcdir="${src.dir}/prep"
            destdir="${build.dir}/prep"
-           source="${source.version}">
+           encoding="cp1252"
+           includeantruntime="false">
     </javac>
     <java classname="WriteConvertWorker" 
           classpath="${build.dir}/prep"
@@ -434,6 +428,10 @@
           description="-> creates the package jar file">
 
     <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" basedir="${build.classes}">
       <manifest>
         <attribute name="Built-By" value="${user.name}"/>
@@ -443,13 +441,6 @@
 
     <zip destfile="${dist.lib.pkg}/${name}_src.zip" basedir="${build.java}"/>
 
-    <!-- Sign all jar files -->
-    <signjar jar="${dist.lib.pkg}/${name}.jar"
-             alias="${webstart.alias}"
-             keystore="${webstart.keystore}"
-             keypass="${webstart.keypass}"
-             storepass="${webstart.storepass}"/>
-
   </target>
 
 
@@ -809,7 +800,7 @@
              locale="en"
              windowtitle="${Name} API"
              doctitle="${Name}"
-             source="${source.version}"
+             encoding="cp1252"
              classpathref="classpath">
 
       <!-- Get a list of directories that name all the potential
@@ -879,7 +870,8 @@
     <javac srcdir="${tests.dir}"
            destdir="${build.tests}"
            debug="${debug}"
-           source="${source.version}"
+           encoding="cp1252"
+           includeantruntime="false"
            deprecation="${deprecation}" >
       <classpath refid="tests-classpath"/>
     </javac>
