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/07/04 12:47:42 UTC
svn commit: r418972 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
Author: cam
Date: Tue Jul 4 03:47:41 2006
New Revision: 418972
URL: http://svn.apache.org/viewvc?rev=418972&view=rev
Log:
1. Better version number reporting from org.apache.batik.Version.
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java (contents, props changed)
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java?rev=418972&r1=418971&r2=418972&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java Tue Jul 4 03:47:41 2006
@@ -25,27 +25,87 @@
* @version $Id$
*/
public final class Version {
- public static final String LABEL_DEVELOPMENT_BUILD
- = "development.build";
-
+
/**
- * @return the Batik version. This is based on the CVS tag.
- * If this Version is not part of a tagged release, then
- * the returned value is a constant reflecting a development
- * build.
+ * Returns the Batik version.
+ * <p>
+ * This is based on the 'HeadURL' keyword. This will 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
+ * branch. The format of the returned string will be one of the
+ * following:
+ * </p>
+ * <table>
+ * <tr>
+ * <th>Source</th>
+ * <th>Version string</th>
+ * <tr>
+ * </tr>
+ * <td>Release version</td>
+ * <td><em>version</em></td>
+ * <tr>
+ * </tr>
+ * <td>Trunk</td>
+ * <td>SVN+<em>yyyymmdd</em></td>
+ * <tr>
+ * </tr>
+ * <td>Branch</td>
+ * <td><em>branch-name</em> branch; SVN+<em>yyyymmdd</em></td>
+ * </tr>
+ * </tr>
+ * <td>Unknown</td>
+ * <td>development version</td>
+ * </tr>
+ * </table>
+ * <p>
+ * Prior to SVN+20060704 and release 1.6, the version string would
+ * be the straight tag (e.g. <code>"batik-1_6"</code>) or the
+ * string <code>"development.version"</code>.
+ * </p>
*/
public static String getVersion() {
- String tagName = "$Name$";
- if (tagName.startsWith("$Name:")) {
- tagName = tagName.substring(6, tagName.length()-1);
- } else {
- tagName = "";
- }
-
- if(tagName.trim().intern().equals("")){
- tagName = LABEL_DEVELOPMENT_BUILD;
+ String version = "development version";
+ String headURL = "$HeadURL$";
+ String prefix = "$HeadURL: ";
+ 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+" + getDate();
+ } else {
+ 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
+ version = name.substring(tagPrefix.length())
+ .replace('_', '.');
+ } else if (type.equals("branches")) {
+ // SVN branch
+ version = name + "; SVN+" + getDate();
+ }
+ }
}
- return tagName;
+ return version;
+ }
+
+ /**
+ * Returns the last modified date of this file in <em>YYYYMMDD</em>
+ * format.
+ */
+ protected static String getDate() {
+ String date = "$Date$";
+ String prefix = "$Date: ";
+ if (date.startsWith(prefix)) {
+ return date.substring(7, 11)
+ + date.substring(12, 14)
+ + date.substring(15, 17);
+ }
+ return "unknown";
}
}
Propchange: xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Tue Jul 4 03:47:41 2006
@@ -1 +1 @@
-Author Date Id Revision
+Author Date Id Revision HeadURL
Re: svn commit: r418972 - /xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java
Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi.
cam@apache.org:
> Author: cam
> Date: Tue Jul 4 03:47:41 2006
> New Revision: 418972
>
> URL: http://svn.apache.org/viewvc?rev=418972&view=rev
> Log:
> 1. Better version number reporting from org.apache.batik.Version.
>
> Modified:
> xmlgraphics/batik/trunk/sources/org/apache/batik/Version.java (contents, props changed)
With this change, to ensure that the version number is updated
appropriately in this class for future releases, the trunk should be
“tagged” by copying it to
https://svn.apache.org/.../batik/tags/batik-<version>, as the current
SVN version tags are, and then the source built from there.
--
Cameron McCormack, http://mcc.id.au/
xmpp:heycam@jabber.org ▪ ICQ 26955922 ▪ MSN cam@mcc.id.au
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org