You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/11/20 04:12:26 UTC
svn commit: r477015 - in /xmlgraphics/batik/trunk: build.xml
lib/build/svn-info-revision.xsl sources/org/apache/batik/Version.java
sources/org/apache/batik/Version.java.xsl
Author: cam
Date: Sun Nov 19 19:12:25 2006
New Revision: 477015
URL: http://svn.apache.org/viewvc?view=rev&rev=477015
Log:
1. Better Version number reporting. The svn revision number is now
stored in batik-util.jar's manifest, from where the Version class
can read it. For source distributions built with the src-zip or
src-tgz ant targets, the revision number will be stored in a file
called svn-revision. The build script then picks this up instead
of running svn info. (Suggestions welcome on a better place/name
for this file.) Version.java is back to being an ungenerated file.
Added:
xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl (with props)
xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java (contents, props changed)
- copied, changed from r476928, xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java.xsl
Removed:
xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java.xsl
Modified:
xmlgraphics/batik/trunk/build.xml
Modified: xmlgraphics/batik/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/build.xml?view=diff&rev=477015&r1=477014&r2=477015
==============================================================================
--- xmlgraphics/batik/trunk/build.xml (original)
+++ xmlgraphics/batik/trunk/build.xml Sun Nov 19 19:12:25 2006
@@ -280,7 +280,7 @@
</zip>
</target>
- <target name="src-zip" depends="init">
+ <target name="src-zip" depends="init, record-svn-revision">
<zip zipfile="${project}-src-${version}.zip">
<zipfileset dir="." prefix="${project}-${version}">
<include name="LICENSE"/>
@@ -291,6 +291,7 @@
<include name="build.bat"/>
<include name="build.sh"/>
<include name="build.xml"/>
+ <include name="svn-revision"/>
<include name="contrib/**"/>
<include name="lib/**"/>
<include name="resources/**"/>
@@ -303,6 +304,7 @@
<include name="xdocs/**"/>
</zipfileset>
</zip>
+ <delete file="svn-revision" failonerror="false"/>
</target>
<target name="dist-tgz" depends="build-tgz"/>
@@ -335,7 +337,7 @@
</tar>
</target>
- <target name="src-tgz" depends="init">
+ <target name="src-tgz" depends="init, record-svn-revision">
<tar tarfile="${project}-src-${version}.tar.gz" compression="gzip">
<tarfileset dir="." prefix="${project}-${version}">
<include name="LICENSE"/>
@@ -346,6 +348,7 @@
<include name="build.bat"/>
<include name="build.sh"/>
<include name="build.xml"/>
+ <include name="svn-revision"/>
<include name="contrib/**"/>
<include name="lib/**"/>
<include name="resources/**"/>
@@ -358,6 +361,7 @@
<include name="xdocs/**"/>
</tarfileset>
</tar>
+ <delete file="svn-revision" failonerror="false"/>
</target>
@@ -473,8 +477,19 @@
</jar>
</target>
- <!-- Runs 'svn status' to get the revision of the current working copy. -->
- <target name="update-version-init">
+
+ <target name="record-svn-revision" depends="determine-svn-revision"
+ if="svn-revision-determined">
+ <echo message="${svn-revision-number}" file="svn-revision"/>
+ </target>
+
+ <target name="determine-svn-revision"
+ depends="determine-svn-revision-svn-info,
+ determine-svn-revision-transform,
+ determine-svn-revision-from-file,
+ determine-svn-revision-set"/>
+
+ <target name="determine-svn-revision-svn-info">
<dirset id="dirs" dir="${src}/${package-prefix}">
<include name="**"/>
</dirset>
@@ -488,44 +503,42 @@
</condition>
</target>
- <!-- Transforms the output of 'svn status' into Version.java.new. -->
- <target name="update-version-transform" if="should-transform-svn-info">
- <java fork="yes" classname="org.apache.xalan.xslt.Process">
+ <target name="determine-svn-revision-transform"
+ if="should-transform-svn-info">
+ <java fork="yes" classname="org.apache.xalan.xslt.Process"
+ outputproperty="svn-revision-number"
+ errorproperty="svn-revision-transform-error"
+ resultproperty="svn-revision-transform-result">
<classpath>
<path refid="libs-build-classpath"/>
</classpath>
- <arg line="-in svn-info.xml -xsl ${src}/${package-prefix}/Version.java.xsl -out ${src}/${package-prefix}/Version.java.new"/>
+ <arg line="-in svn-info.xml -xsl ${lib}/build/svn-info-revision.xsl"/>
</java>
- <condition property="should-update-version-java">
+ <condition property="svn-revision-determined">
+ <equals arg1="${svn-revision-transform-result}" arg2="0"/>
+ </condition>
+ </target>
+
+ <target name="determine-svn-revision-from-file"
+ unless="svn-revision-determined">
+ <loadfile property="svn-revision-number" srcFile="svn-revision"
+ failonerror="false"/>
+ <condition property="svn-revision-determined">
<not>
- <filesmatch file1="${src}/${package-prefix}/Version.java"
- file2="${src}/${package-prefix}/Version.java.new"/>
+ <equals arg1="${svn-revision-suffix-string}" arg2=""/>
</not>
</condition>
</target>
- <!-- Copies the generated Version.java.new to Version.java if the file
- will actually change. -->
- <target name="update-version-write"
- if="should-update-version-java">
- <copy file="${src}/${package-prefix}/Version.java.new"
- tofile="${src}/${package-prefix}/Version.java"/>
- </target>
-
- <!-- Removes the generated Version.java.new. -->
- <target name="update-version-clean">
- <delete file="${src}/${package-prefix}/Version.java.new"/>
- <delete file="svn-info.xml"/>
- </target>
-
- <!-- Writes sources/org/apache/batik/Version.java with the working copy's
- revision number filled in. -->
- <target name="update-version"
- depends="update-version-init, update-version-transform,
- update-version-write, update-version-clean"/>
+ <target name="determine-svn-revision-set"
+ if="svn-revision-determined">
+ <property name="svn-revision-suffix" value="+r${svn-revision-number}"/>
+ <delete file="svn-info.xml" failonerror="false"/>
+ </target>
+
<target name ="compile-prepare"
- depends ="init, update-version">
+ depends ="init">
<mkdir dir="${dest}"/>
<echo message="debug ${debug}, optimize ${optimize}, deprecation ${deprecation}"/>
</target>
@@ -547,10 +560,9 @@
</target>
<target name="clean-compile"
- depends="init, update-version-clean"
+ depends="init"
description="Cleans the files generated by compile">
<delete dir="${dest}"/>
- <delete file="${src}/${package-prefix}/Version.java"/>
</target>
<target name="clean-apache"
@@ -570,7 +582,7 @@
<!-- Jars ............................................................... -->
- <target name="prepare-build">
+ <target name="prepare-build" depends="determine-svn-revision">
<mkdir dir="${build}"/>
<mkdir dir="${build}/docs"/>
<mkdir dir="${build}/lib"/>
@@ -612,8 +624,15 @@
<!-- All batik in a single jar (dependencies: none) -->
- <target name="all-jar" depends="compile, prepare-build" description="Creates a combined JAR file of the Batik libraries in ${build}/lib">
+ <target name="all-jar" depends="compile, prepare-build"
+ description="Creates a combined JAR file of the Batik libraries in ${build}/lib">
<jar jarfile="${build}/lib/${project}-all.jar">
+ <manifest>
+ <attribute name="Implementation-Title" value="Batik all-in-one JAR"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
+ <attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
+ </manifest>
<fileset dir="${dest}" excludes="**/.svn/">
<include name="**"/>
</fileset>
@@ -651,8 +670,9 @@
manifest="${src}/${project}-bean.mf">
<manifest>
<attribute name="Implementation-Title" value="Batik Java Bean"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="org/w3c/**"/>
@@ -698,6 +718,12 @@
<!-- Util, i18n (dependencies: none) -->
<target name="util-jar" depends="compile, prepare-build">
<jar jarfile="${build}/lib/${project}-util.jar">
+ <manifest>
+ <attribute name="Implementation-Title" value="Batik utility jar"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
+ <attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
+ </manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/i18n/*.class"/>
<include name="${package-prefix}/util/*.class"/>
@@ -981,6 +1007,7 @@
<attribute name="Implementation-Title" value="Batik XML Pretty Printer"/>
<attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/apps/svgpp/**/*.class"/>
@@ -997,8 +1024,9 @@
jarfile="${build}/${project}-slideshow.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik SVG Slide Show Tool"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/apps/slideshow/**/*.class"/>
@@ -1020,8 +1048,9 @@
jarfile="${build}/${project}-squiggle.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik Squiggle Viewer"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/apps/svgbrowser/**/*.class"/>
@@ -1045,8 +1074,9 @@
jarfile="${build}/extensions/${project}-squiggle-ext.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik Squiggle Viewer With Extensions"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${resources}" excludes="**/.svn/">
<include name="META-INF/services/**"/>
@@ -1067,8 +1097,9 @@
jarfile="${build}/${project}-rasterizer.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik SVG Rasterizer"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/apps/rasterizer/**/*.class"/>
@@ -1089,8 +1120,9 @@
jarfile="${build}/extensions/${project}-rasterizer-ext.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik SVG Rasterizer With Extensions"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${resources}" excludes="**/.svn/">
<include name="META-INF/services/**"/>
@@ -1104,8 +1136,9 @@
jarfile="${build}/${project}-ttf2svg.jar">
<manifest>
<attribute name="Implementation-Title" value="Batik TrueType to SVG Font Converter"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
<fileset dir="${dest}">
<include name="${package-prefix}/apps/ttf2svg/**/*.class"/>
@@ -1115,12 +1148,12 @@
<!-- batik.jar (dependencies: all) -->
<target name="root-jar" depends="compile, prepare-build">
- <jar manifest="${src}/${project}.mf"
- jarfile="${build}/${project}.jar">
+ <jar manifest="${src}/${project}.mf" jarfile="${build}/${project}.jar">
<manifest>
- <attribute name="Implementation-Title" value="Batik All Jar"/>
- <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}"/>
+ <attribute name="Implementation-Title" value="Batik"/>
+ <attribute name="Implementation-Version" value="${version}${revisionType}${revisionNumber}${svn-revision-suffix}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation (http://xmlgraphics.apache.org/batik/)"/>
+ <attribute name="Implementation-URL" value="http://xmlgraphics.apache.org/batik/"/>
</manifest>
</jar>
</target>
Added: xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl?view=auto&rev=477015
==============================================================================
--- xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl (added)
+++ xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl Sun Nov 19 19:12:25 2006
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+ $Id$
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:output method="text"/>
+
+ <xsl:template match="/">
+ <xsl:for-each select=".//@revision">
+ <xsl:sort data-type="number" order="descending"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="."/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>
Propchange: xmlgraphics/batik/trunk/lib/build/svn-info-revision.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Copied: xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java (from r476928, xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java.xsl)
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java?view=diff&rev=477015&p1=xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java.xsl&r1=476928&p2=xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java&r2=477015
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java.xsl (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java Sun Nov 19 19:12:25 2006
@@ -1,5 +1,4 @@
-<?xml version="1.0"?>
-<!--
+/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,36 +15,11 @@
See the License for the specific language governing permissions and
limitations under the License.
--->
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
- <xsl:output method="text"/>
-
- <xsl:variable name="revision">
- <xsl:for-each select=".//@revision">
- <xsl:sort data-type="number" order="descending"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <xsl:variable name="revision-string">
- <xsl:choose>
- <xsl:when test="$revision"><xsl:value-of select="$revision"/></xsl:when>
- <xsl:otherwise>unknown</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:template match="/">
- <xsl:text>/*</xsl:text>
- <xsl:value-of select="string(document('')/comment())"/><![CDATA[*/
+ */
package org.apache.batik;
/**
* This class defines the Batik version number.
- * NOTE: This file is automatically generated from Version.java.xsl.
*
* @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
* @version $Id$
@@ -53,16 +27,13 @@
public final class Version {
/**
- * The Subversion revision number from which this was compiled.
- */
- public static final String REVISION = "]]><xsl:value-of select="$revision-string"/><![CDATA[";
-
- /**
* Returns the Batik version.
* <p>
- * This is based on the 'HeadURL' keyword. This will be substituted with
+ * This is based on the Implementation-Version attribute in the
+ * batik-util.jar (which is where this Version class lives) and
+ * the 'HeadURL' SVN keyword. The keyword be substituted with
* the URL of this file, which is then inspected to determine if this
- * file was compiled from the trunk, a tag (a release verison), or a
+ * file was compiled from the trunk, a tag (a release version), or a
* branch. The format of the returned string will be one of the
* following:
* </p>
@@ -77,11 +48,11 @@
* </tr>
* <tr>
* <td>Trunk</td>
- * <td>SVN+<em>revision</em></td>
+ * <td><em>version</em>+r<em>revision</em></td>
* </tr>
* <tr>
* <td>Branch</td>
- * <td><em>branch-name</em> branch; SVN+<em>revision</em></td>
+ * <td><em>version</em>+r<em>revision</em>; <em>branch-name</em></td>
* </tr>
* <tr>
* <td>Unknown</td>
@@ -96,35 +67,33 @@
* </p>
*/
public static String getVersion() {
- String version = "development version";
+ String version = Version.class.getPackage().getImplementationVersion();
String headURL = "$HeadURL$";
String prefix = "$HeadURL: ";
- String suffix = "/sources/org/apache/batik/Version.java.xsl $";
+ String suffix = "/sources/org/apache/batik/Version.java $";
if (headURL.startsWith(prefix) && headURL.endsWith(suffix)) {
headURL = headURL.substring
(prefix.length(), headURL.length() - suffix.length());
- if (headURL.endsWith("/trunk")) {
- // SVN trunk
- version = "SVN+" + REVISION;
- } else {
+ if (!headURL.endsWith("/trunk")) {
int index1 = headURL.lastIndexOf('/');
int index2 = headURL.lastIndexOf('/', index1 - 1);
String name = headURL.substring(index1 + 1);
String type = headURL.substring(index2 + 1, index1);
String tagPrefix = "batik-";
if (type.equals("tags") && name.startsWith(tagPrefix)) {
- // Release
+ // Release, just use the tag name
version = name.substring(tagPrefix.length())
.replace('_', '.');
} else if (type.equals("branches")) {
// SVN branch
- version = name + "; SVN+" + REVISION;
+ version += "; " + name;
}
}
}
+ if (version == null) {
+ version = "development version";
+ }
return version;
}
}
-]]></xsl:template>
-</xsl:stylesheet>
Propchange: xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision HeadURL