diff options
-rwxr-xr-x | build.bat | 6 | ||||
-rwxr-xr-x | build.sh | 6 | ||||
-rw-r--r-- | build.xml | 135 | ||||
-rwxr-xr-x | docs/bugtests/runtests.sh | 5 | ||||
-rwxr-xr-x | docs/examples/runtests.bat | 5 | ||||
-rwxr-xr-x | docs/examples/runtests.sh | 6 | ||||
-rwxr-xr-x | docs/examples/svg/makedoc.bat | 7 | ||||
-rwxr-xr-x | docs/examples/svg/makedoc.sh | 5 | ||||
-rwxr-xr-x | docs/xml-docs/makedoc.bat | 5 | ||||
-rwxr-xr-x | docs/xml-docs/makedoc.sh | 5 | ||||
-rw-r--r-- | lib/buildtools.jar | bin | 36751 -> 39687 bytes | |||
-rw-r--r-- | lib/xerces-1.2.3.jar | bin | 1499244 -> 766079 bytes | |||
-rw-r--r-- | src/org/apache/fop/tools/anttasks/Manifest.java | 239 |
13 files changed, 359 insertions, 65 deletions
@@ -5,9 +5,9 @@ echo ---------------- if "%JAVA_HOME%" == "" goto error - -set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;lib\ant.jar;lib\w3c.jar;lib\buildtools.jar;lib\xerces-1.2.3.jar;lib\xalan-2.0.0.jar:lib\xalanj1compat.jar:lib\bsf.jar:lib\jimi-1.0.jar -set ANT_HOME=.\lib +set LIBDIR=lib +set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;%LIBDIR%\ant.jar;%LIBDIR%\w3c.jar;%LIBDIR%\buildtools.jar;%LIBDIR%\xerces-1.2.3.jar;%LIBDIR%\xalan-2.0.0.jar:%LIBDIR%\xalanj1compat.jar:%LIBDIR%\bsf.jar:%LIBDIR%\jimi-1.0.jar +set ANT_HOME=%LIBDIR% echo Building with classpath %LOCALCLASSPATH% @@ -12,9 +12,9 @@ if [ "$JAVA_HOME" = "" ] ; then echo "location of the Java Virtual Machine you want to use." exit 1 fi - -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:./lib/ant.jar:./lib/w3c.jar:./lib/buildtools.jar:./lib/xerces-1.2.3.jar:./lib/xalan-2.0.0.jar:./lib/xalanj1compat.jar:./lib/bsf.jar:./lib/jimi-1.0.jar -ANT_HOME=./lib +LIBDIR=lib +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar +ANT_HOME=$LIBDIR echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo @@ -114,6 +114,44 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <project default="package" basedir="."> + <fileset dir="${basedir}" id="dist.bin"> + <include name="conf/**"/> + <include name="docs/**"/> + <include name="hyph/**"/> + <include name="CHANGES"/> + <include name="LICENSE"/> + <include name="README"/> + <include name="STATUS"/> + <exclude name="src/**"/> + <exclude name="dist/**"/> + <exclude name="build/**"/> + <exclude name="lib/**"/> + </fileset> + + <fileset dir="${basedir}" id="dist.bin.lib"> + <include name="lib/xerces-1.2.3.jar"/> + <include name="lib/xalan-2.0.0.jar"/> + <include name="lib/xalanj1compat.jar"/> + <include name="lib/w3c.jar"/> + <include name="lib/jimi*"/> + </fileset> + + <fileset dir="${basedir}" id="dist.src"> + <exclude name="lib/classes/**"/> + <exclude name="lib/org/**"/> + <exclude name="lib/src/**"/> + <exclude name="build/**"/> + <include name="src/**"/> + <include name="conf/**"/> + <include name="docs/**"/> + <include name="lib/**"/> + <include name="CHANGES"/> + <include name="LICENSE"/> + <include name="README"/> + <include name="STATUS"/> + <include name="build*"/> + </fileset> + <!-- =================================================================== --> <!-- Initialization target --> <!-- =================================================================== --> @@ -121,7 +159,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <tstamp/> <property name="Name" value="Fop"/> <property name="name" value="fop"/> - <property name="version" value="0.17.0"/> + <property name="version" value="0.18.0-DEV"/> <property name="year" value="1999-2001"/> <echo message="------------------- ${Name} ${version} [${year}] ----------------"/> @@ -149,7 +187,9 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <property name="build.docs" value="./build/docs"/> <property name="build.javadocs" value="./build/javadocs"/> - <property name="dist.dir" value="./dist"/> + <!-- <property name="dist.dir" value="./dist"/> --> + <property name="dist.bin.dir" value="./dist-bin"/> + <property name="dist.src.dir" value="./dist-src"/> <property name="properties.dir" value="org/apache/fop/fo/properties"/> <property name="fonts.dir" value="org/apache/fop/render/pdf/fonts"/> @@ -214,7 +254,11 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <taskdef name="serHyph" classname="org.apache.fop.tools.anttasks.SerializeHyphPattern"/> <taskdef name="xslt" classname="org.apache.fop.tools.anttasks.Xslt"/> - + <taskdef name="manifest" classname="org.apache.fop.tools.anttasks.Manifest"/> + + <property name="main.class" value="org.apache.fop.apps.Fop"/> + <property name="runtime.classpath" value="lib/xerces-1.2.3.jar lib/xalan-2.0.0.jar lib/xalanj1compat.jar lib/w3c.jar lib/jimi-1.0.jar"/> + <filter filtersfile="${build.src}/codegen/filter"/> </target> @@ -482,7 +526,12 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <!-- =================================================================== --> <target name="package" depends="compile,hyphenation"> <echo message="Creating the jar file ${build.dir}/${name}.jar"/> - <jar jarfile="${build.dir}/${name}.jar" + <manifest file="${build.dir}/Manifest.txt" overwrite="yes" + mainclass="${main.class}" + classpath="${runtime.classpath}" + impltitle="${Name}" implversion="${version}" + implvendor="Apache Software Foundation (http://xml.apache.org/fop/)"/> + <jar jarfile="${build.dir}/${name}.jar" manifest="${build.dir}/Manifest.txt" basedir="${build.dest}" includes="org/**,conf/**,hyph/**"/> </target> @@ -503,23 +552,6 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <chmod file="${lib.dir}/bin/antRun" perm="ugo+rx" /> </target> - <!-- =================================================================== --> - <!-- Copying the documentation files --> - <!-- =================================================================== --> - <target name="docs" depends="prepare-docs"> - <echo message="Copying doc files "/> - <copy todir="${build.docs}"> - <fileset dir="${docs.dir}"/> - </copy> - <copy todir="${build.dir}/${lib.dir}"> - <fileset dir="${lib.dir}"/> - </copy> - - <copy file="build.xml" tofile="${build.dir}/build.xml" /> - <copy file="${basedir}/README" tofile="${build.dir}/README" /> - <copy file="${basedir}/STATUS" tofile="${build.dir}/STATUS" /> - <copy file="${basedir}/LICENSE" tofile="${build.dir}/LICENSE" /> - </target> <!-- =================================================================== --> <!-- Creates the API documentation --> @@ -541,28 +573,42 @@ Sometimes ant gives out this warnings, but the build is finished without any pro <!-- =================================================================== --> <!-- Creates the distribution --> <!-- =================================================================== --> - <target name="dist" depends="package, docs, javadocs"> - <echo message="Building the distribution files (zip,tar)"/> - <mkdir dir="${dist.dir}"/> - <mkdir dir="${dist.dir}/conf"/> - <mkdir dir="${dist.dir}/hyph"/> - <copy file="${basedir}/build.sh" tofile="${dist.dir}/build.sh" /> - <chmod file="${dist.dir}/build.sh" perm="ugo+rx" /> - <copy file="${basedir}/build.bat" tofile="${dist.dir}/build.bat" /> - <copy todir="${dist.dir}"> - <fileset dir="${build.dir}" excludes="**/classes/**, **/${ignore_this}"/> + <target name="dist" depends="dist-src, dist-bin"/> + + <target name="dist-bin" depends="package, javadocs"> + <echo message="Building the binary distribution files (zip,tar)"/> + <mkdir dir="${dist.bin.dir}"/> + <copy todir="${dist.bin.dir}"> + <fileset refid="dist.bin"/> + <fileset refid="dist.bin.lib"/> </copy> - <copy todir="${dist.dir}/hyph"> - <fileset dir="${hyph.dir}"/> + <copy todir="${dist.bin.dir}" file="build/fop.jar"/> + + <zip zipfile="${Name}-${version}-bin.zip" basedir="${dist.bin.dir}" includes="**"/> + <tar tarfile="${Name}-${version}-bin.tar" basedir="${dist.bin.dir}" includes="**"/> + <gzip zipfile="${Name}-${version}-bin.tar.gz" src="${Name}-${version}-bin.tar" /> + <delete file="${Name}-${version}-bin.tar"/> + + </target> + + + <target name="dist-src" depends="package, javadocs"> + <echo message="Building the source distribution files (zip,tar)"/> + <mkdir dir="${dist.src.dir}"/> + <copy todir="${dist.src.dir}"> + <fileset refid="dist.src"/> </copy> - <copy todir="${dist.dir}/conf"> - <fileset dir="${conf.dir}"/> + <copy todir="${dist.src.dir}/javadocs"> + <fileset dir="${build.javadocs}"/> </copy> + <copy todir="${dist.src.dir}" file="build/fop.jar"/> + <chmod file="${dist.src.dir}/build.sh" perm="ugo+rx" /> + + <zip zipfile="${Name}-${version}-src.zip" basedir="${dist.src.dir}" includes="**"/> + <tar tarfile="${Name}-${version}-src.tar" basedir="${dist.src.dir}" includes="**"/> + <gzip zipfile="${Name}-${version}-src.tar.gz" src="${Name}-${version}-src.tar" /> + <delete file="${Name}-${version}-src.tar"/> - <zip zipfile="${Name}-${version}.zip" basedir="${dist.dir}" includes="**"/> - <tar tarfile="${Name}-${version}.tar" basedir="${dist.dir}" includes="**"/> - <gzip zipfile="${Name}-${version}.tar.gz" src="${Name}-${version}.tar" /> - <delete file="${Name}-${version}.tar"/> </target> <!-- =================================================================== --> @@ -573,10 +619,13 @@ Sometimes ant gives out this warnings, but the build is finished without any pro </target> <target name="distclean" depends="clean"> - <delete dir="${dist.dir}"/> - <delete file="${Name}-${version}.tar.gz"/> - <delete file="${Name}-${version}.tar"/> - <delete file="${Name}-${version}.zip"/> + <delete dir="${dist.src.dir}"/> + <delete dir="${dist.bin.dir}"/> + <delete> + <fileset dir="${basedir}" includes="${Name}-${version}*.tar.gz"/> + <fileset dir="${basedir}" includes="${Name}-${version}*.tar"/> + <fileset dir="${basedir}" includes="${Name}-${version}*.zip"/> + </delete> </target> </project> diff --git a/docs/bugtests/runtests.sh b/docs/bugtests/runtests.sh index 9e72861f2..98f812039 100755 --- a/docs/bugtests/runtests.sh +++ b/docs/bugtests/runtests.sh @@ -13,8 +13,9 @@ if [ "$JAVA_HOME" = "" ] ; then exit 1 fi -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:../../lib/ant.jar:../../lib/buildtools.jar:../../build/fop.jar:../../lib/w3c.jar -ANT_HOME=../../lib +LIBDIR=../../lib/ +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar +ANT_HOME=$LIBDIR echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo diff --git a/docs/examples/runtests.bat b/docs/examples/runtests.bat index 8fe5ea89d..f1570fe0a 100755 --- a/docs/examples/runtests.bat +++ b/docs/examples/runtests.bat @@ -6,8 +6,9 @@ echo ---------------- if "%JAVA_HOME%" == "" goto error -set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;..\..\lib\ant.jar;..\..\lib\buildtools.jar;..\..\lib\w3c.jar;..\..\build\fop.jar -set ANT_HOME=..\..\lib +set LIBDIR=..\..\lib +set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;%LIBDIR%\ant.jar;%LIBDIR%\w3c.jar;%LIBDIR%\buildtools.jar;%LIBDIR%\xerces-1.2.3.jar;%LIBDIR%\xalan-2.0.0.jar:%LIBDIR%\xalanj1compat.jar:%LIBDIR%\bsf.jar:%LIBDIR%\jimi-1.0.jar;%LIBDIR%\..\build\fop.jar +set ANT_HOME=%LIBDIR% echo Starting Tests ... diff --git a/docs/examples/runtests.sh b/docs/examples/runtests.sh index 9e72861f2..415fadcdf 100755 --- a/docs/examples/runtests.sh +++ b/docs/examples/runtests.sh @@ -12,9 +12,9 @@ if [ "$JAVA_HOME" = "" ] ; then echo "location of the Java Virtual Machine you want to use." exit 1 fi - -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:../../lib/ant.jar:../../lib/buildtools.jar:../../build/fop.jar:../../lib/w3c.jar -ANT_HOME=../../lib +LIBDIR=../../lib +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar:$LIBDIR/../build/fop.jar +ANT_HOME=$LIBDIR echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo diff --git a/docs/examples/svg/makedoc.bat b/docs/examples/svg/makedoc.bat index c699a5ed2..27b252fe7 100755 --- a/docs/examples/svg/makedoc.bat +++ b/docs/examples/svg/makedoc.bat @@ -4,9 +4,10 @@ echo Building Fop documentation (pdf) echo ---------------- if "%JAVA_HOME%" == "" goto error - -set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;..\..\..\lib\ant.jar;..\..\..\lib\xml.jar;..\..\..\lib\buildtools.jar;..\..\..\build\fop.jar;..\..\..\lib\w3c.jar -set ANT_HOME=..\..\..\lib +set LIBDIR=..\..\..\lib +set LIBDIR=lib +set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;%LIBDIR%\ant.jar;%LIBDIR%\w3c.jar;%LIBDIR%\buildtools.jar;%LIBDIR%\xerces-1.2.3.jar;%LIBDIR%\xalan-2.0.0.jar:%LIBDIR%\xalanj1compat.jar:%LIBDIR%\bsf.jar:%LIBDIR%\jimi-1.0.jar;%LIBDIR%\..\build\fop.jar +set ANT_HOME=%LIBDIR% %JAVA_HOME%\bin\java.exe -Dant.home=%ANT_HOME% -classpath %LOCALCLASSPATH%;%CLASSPATH% org.apache.tools.ant.Main %1 %2 %3 %4 %5 diff --git a/docs/examples/svg/makedoc.sh b/docs/examples/svg/makedoc.sh index dcf1fd303..f77f7a853 100755 --- a/docs/examples/svg/makedoc.sh +++ b/docs/examples/svg/makedoc.sh @@ -13,8 +13,9 @@ if [ "$JAVA_HOME" = "" ] ; then exit 1 fi -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:../../../lib/ant.jar:../../../lib/w3c.jar:../../../lib/buildtools.jar:../../../build/fop.jar -ANT_HOME=../../../lib +LIBDIR=../../../lib/ +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar:$LIBDIR/../build/fop.jar +ANT_HOME=$LIBDIR echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo diff --git a/docs/xml-docs/makedoc.bat b/docs/xml-docs/makedoc.bat index 020cca058..07c506245 100755 --- a/docs/xml-docs/makedoc.bat +++ b/docs/xml-docs/makedoc.bat @@ -6,8 +6,9 @@ echo ---------------- if "%JAVA_HOME%" == "" goto error -set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;..\..\lib\ant.jar;..\..\lib\w3c.jar;..\..\lib\buildtools.jar;..\..\build\fop.jar;..\..\lib\stylebook.jar -set ANT_HOME=.\lib +set LIBDIR=..\..\lib +set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;%LIBDIR%\ant.jar;%LIBDIR%\w3c.jar;%LIBDIR%\buildtools.jar;%LIBDIR%\xerces-1.2.3.jar;%LIBDIR%\xalan-2.0.0.jar:%LIBDIR%\xalanj1compat.jar:%LIBDIR%\bsf.jar:%LIBDIR%\jimi-1.0.jar;%LIBDIR%\stylebook.jar;%LIBDIR%\..\build\fop.jar +set ANT_HOME=%LIBDIR% %JAVA_HOME%\bin\java.exe -Dant.home=%ANT_HOME% -classpath %LOCALCLASSPATH%;%CLASSPATH% org.apache.tools.ant.Main %1 %2 %3 %4 %5 diff --git a/docs/xml-docs/makedoc.sh b/docs/xml-docs/makedoc.sh index c0876902c..cc776c36b 100755 --- a/docs/xml-docs/makedoc.sh +++ b/docs/xml-docs/makedoc.sh @@ -13,8 +13,9 @@ if [ "$JAVA_HOME" = "" ] ; then exit 1 fi -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:../../lib/ant.jar:../../lib/w3c.jar:../../lib/buildtools.jar:../../build/fop.jar:../../lib/stylebook.jar -ANT_HOME=../../lib +LIBDIR=../../lib +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar:$LIBDIR/stylebook.jar:$LIBDIR/../build/fop.jar +ANT_HOME=$LIBDIR echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo diff --git a/lib/buildtools.jar b/lib/buildtools.jar Binary files differindex f639cc07e..ac38eb58d 100644 --- a/lib/buildtools.jar +++ b/lib/buildtools.jar diff --git a/lib/xerces-1.2.3.jar b/lib/xerces-1.2.3.jar Binary files differindex 7afa8dcb2..5e0f019ed 100644 --- a/lib/xerces-1.2.3.jar +++ b/lib/xerces-1.2.3.jar diff --git a/src/org/apache/fop/tools/anttasks/Manifest.java b/src/org/apache/fop/tools/anttasks/Manifest.java new file mode 100644 index 000000000..3e285a7be --- /dev/null +++ b/src/org/apache/fop/tools/anttasks/Manifest.java @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources." + */ + +package org.apache.fop.tools.anttasks; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.BuildException; + +import java.io.*; +import java.text.SimpleDateFormat; +import java.net.InetAddress; +import java.util.Date; +import java.util.Properties; + + + +/** + * Creates a manifest file for packing into a jar. + * <P> + * Attributes are as follows: + * <dl> + * <dt>file</dt> <dd>the manifest file to write out to (required)</dd> + * <dt>overwrite</dt> <dd>if set to yes or true, overwrite the given + * manifest file. Default is no</dd> + * <dt>version</dt> <dd>manifest version. Defaults to "1.0"</dd> + * <dt>spectitle</dt> <dd>the specification title</dd> + * <dt>specversion</dt> <dd>the specification version</dd> + * <dt>specvendor</dt> <dd>the specification vendor</dd> + * <dt>impltitle</dt> <dd>the implementation title</dd> + * <dt>implversion</dt> <dd>the implementation version.</dd> + * <dt>implvendor</dt> <dd>the implementation vendor</dd> + * <dt>mainclass</dt> <dd>the class to run when java -jar is invoked</dd> + * <dt>classpath</dt> <dd>the classpath to use when java -jar is invoked</dd> + * <dt>createdby</dt> <dd>the string to set the Created-By field to</dd> + * <dt>buildid</dt> <dd>A build identifier. Defaults to a build identifier + * containing <tt>date + " ("+username+"@"+hostname+" ["+os+" "+version+" "+arch+"]</tt> </dd> + * </dl> + * + * @author Kelly A. Campbell + */ + +public class Manifest extends Task +{ + public static final String MANIFEST_VERSION = "Manifest-Version: "; + public static final String CREATED_BY = "Created-By: "; + public static final String REQUIRED_VERSION = "Required-Version: "; + + public static final String SPECIFICATION_TITLE = "Specification-Title: "; + public static final String SPECIFICATION_VERSION = "Specification-Version: "; + public static final String SPECIFICATION_VENDOR = "Specification-Vendor: "; + public static final String IMPL_TITLE = "Implementation-Title: "; + public static final String IMPL_VERSION = "Implementation-Version: "; + public static final String IMPL_VENDOR = "Implementation-Vendor: "; + public static final String BUILD_ID = "Build-ID: "; + public static final String MAIN_CLASS = "Main-Class: "; + public static final String CLASS_PATH = "Class-Path: "; + + + private String _manifestVersion = "1.0"; + private String _spectitle; + private String _specvers; + private String _specvend; + private String _impltitle; + private String _implvers; + private String _implvend; + private String _mainclass; + private String _classpath; + private String _createdby; + private String _buildid; + + private String _manifestFilename; + private Boolean _overwrite = Boolean.FALSE; + + public void setFile(String s) + { + _manifestFilename = s; + } + + public void setOverwrite(Boolean b) + { + _overwrite = b; + } + + public void setSpectitle(String s) + { + _spectitle = s; + } + public void setSpecversion(String s) + { + _specvers = s; + } + public void setSpecvendor(String s) + { + _specvend = s; + } + public void setImpltitle(String s) + { + _impltitle = s; + } + public void setImplversion(String s) + { + _implvers = s; + } + public void setImplvendor(String s) + { + _implvend = s; + } + public void setMainclass(String s) + { + _mainclass = s; + } + public void setClasspath(String s) + { + _classpath = s; + } + public void setCreatedby(String s) + { + _createdby = s; + } + public void setBuildid(String s) + { + _buildid = s; + } + + /** + * Main task method which runs this task and creates the manifest file. + * @exception BuildException if one of the required attributes isn't set + */ + public void execute () + throws BuildException + { + // System.out.println("Executing manifest task"); + + PrintWriter out; + try { + if (_manifestFilename != null) { + // open the file for writing + File f = new File(_manifestFilename); + if (f.exists()) { + if (_overwrite.booleanValue()) { + f.delete(); + } + else { + throw new BuildException("Will not overwrite existing file: "+_manifestFilename+". Use overwrite='yes' if you wish to overwrite the file."); + } + } + System.out.println("creating "+f); + + f.createNewFile(); + out = new PrintWriter(new FileOutputStream(f)); + + } + else { + throw new BuildException("Manifest task requires a 'file' attribute"); + } + } + catch (IOException ex) { + throw new BuildException(ex); + } + + // setup the implementation versionn (buildID) + if (_buildid == null || _buildid.trim().equals("")) { + _buildid = createBuildID(); + } + if (_createdby == null || _createdby.trim().equals("")) { + _createdby = getCreator(); + } + + print(out, MANIFEST_VERSION, _manifestVersion); + print(out, CREATED_BY, _createdby); + + print(out, SPECIFICATION_TITLE, _spectitle); + print(out, SPECIFICATION_VERSION, _specvers); + print(out, SPECIFICATION_VENDOR, _specvend); + print(out, IMPL_TITLE, _impltitle); + print(out, IMPL_VERSION, _implvers); + print(out, IMPL_VENDOR, _implvend); + print(out, BUILD_ID, _buildid); + print(out, MAIN_CLASS, _mainclass); + print(out, CLASS_PATH, _classpath); + + out.flush(); + out.close(); + + } + + protected void print(PrintWriter out, String header, String value) + { + if (value != null && !value.trim().equals("")) { + out.println(header+value); + // System.out.println("manifest: "+header+value); + } + } + + private static String createBuildID() + { + Date d = new Date(); + SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd-HHmmss-z"); + String date = f.format(d); + String hostname, username, os, version, arch; + try { + hostname = InetAddress.getLocalHost().getHostName(); + } + catch (Exception ex) { + hostname = "unknown"; + } + username = System.getProperty("user.name"); + os = System.getProperty("os.name"); + version = System.getProperty("os.version"); + arch = System.getProperty("os.arch"); + String buildid = date + " ("+username+"@"+hostname+" ["+os+" "+version+" "+arch+"])"; + return buildid; + + } + + private static String getCreator() + { + try { + Properties props = new Properties(); + InputStream in = org.apache.tools.ant.Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); + if (in != null) { + props.load(in); + in.close(); + + return "Ant "+props.getProperty("VERSION"); + } + else { + return null; + } + } + catch (IOException ex) { + return null; + } + } + +} |