From 139c6b84a15d4318fd59f4c4c7922c628e4cc336 Mon Sep 17 00:00:00 2001 From: David Roazen Date: Tue, 28 Jun 2011 08:37:05 -0400 Subject: [PATCH] Modified build.xml and the help extractor doclet to use the output of "git describe" as an absolute version number (if the repository has at least one tag), using the raw SHA-1 hash value as a fallback version number in the case where there are no tags. --- build.xml | 29 +++++++++++++++---- .../help/ResourceBundleExtractorDoclet.java | 26 +++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/build.xml b/build.xml index 4cdae6f1e..8e5ab11f3 100644 --- a/build.xml +++ b/build.xml @@ -167,12 +167,29 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -394,7 +411,7 @@ docletpathref="doclet.classpath" classpathref="external.dependencies" classpath="${java.classes}" - additionalparam="-build-timestamp "${build.timestamp}" -version-suffix .${build.version} -out ${basedir}/${resource.path} -quiet"> + additionalparam="-build-timestamp "${build.timestamp}" -absolute-version ${build.version} -out ${basedir}/${resource.path} -quiet"> diff --git a/public/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java b/public/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java index 84b0942e5..4afac69c3 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java @@ -66,7 +66,7 @@ public class ResourceBundleExtractorDoclet { */ public static boolean start(RootDoc rootDoc) throws IOException { PrintStream out = System.out; - String buildTimestamp = null, versionPrefix = null, versionSuffix = null; + String buildTimestamp = null, versionPrefix = null, versionSuffix = null, absoluteVersion = null; for(String[] options: rootDoc.options()) { if(options[0].equals("-out")) { @@ -79,6 +79,8 @@ public class ResourceBundleExtractorDoclet { versionPrefix = options[1]; if(options[0].equals("-version-suffix")) versionSuffix = options[1]; + if (options[0].equals("-absolute-version")) + absoluteVersion = options[1]; } resourceText.setProperty("build.timestamp",buildTimestamp); @@ -93,11 +95,11 @@ public class ResourceBundleExtractorDoclet { if(isRequiredJavadocMissing(currentClass) && isWalker(currentClass)) undocumentedWalkers.add(currentClass.name()); - renderHelpText(getClassName(currentClass),currentClass,versionPrefix,versionSuffix); + renderHelpText(getClassName(currentClass),currentClass,versionPrefix,versionSuffix,absoluteVersion); } for(PackageDoc currentPackage: packages) - renderHelpText(currentPackage.name(),currentPackage,versionPrefix,versionSuffix); + renderHelpText(currentPackage.name(),currentPackage,versionPrefix,versionSuffix,absoluteVersion); resourceText.store(out,"Strings displayed by the Sting help system"); @@ -117,7 +119,7 @@ public class ResourceBundleExtractorDoclet { * @return Number of potential parameters; 0 if not supported. */ public static int optionLength(String option) { - if(option.equals("-build-timestamp") || option.equals("-version-prefix") || option.equals("-version-suffix") || option.equals("-out")) { + if(option.equals("-build-timestamp") || option.equals("-version-prefix") || option.equals("-version-suffix") || option.equals("-out") || option.equals("-absolute-version") ) { return 2; } return 0; @@ -194,7 +196,7 @@ public class ResourceBundleExtractorDoclet { * @param versionPrefix Text to add to the start of the version string. * @param versionSuffix Text to add to the end of the version string. */ - private static void renderHelpText(String elementName, Doc element, String versionPrefix, String versionSuffix) { + private static void renderHelpText(String elementName, Doc element, String versionPrefix, String versionSuffix, String absoluteVersion) { // Extract overrides from the doc tags. String name = null; String version = null; @@ -210,10 +212,16 @@ public class ResourceBundleExtractorDoclet { throw new ReviewedStingException("Only one display name tag can be used per package / walker."); name = tag.text(); } - else if(tag.name().equals("@"+VERSION_TAGLET_NAME)) - version = String.format("%s%s%s", (versionPrefix != null) ? versionPrefix : "", - tag.text(), - (versionSuffix != null) ? versionSuffix : ""); + else if(tag.name().equals("@"+VERSION_TAGLET_NAME)) { + if ( absoluteVersion != null ) { + version = absoluteVersion; + } + else { + version = String.format("%s%s%s", (versionPrefix != null) ? versionPrefix : "", + tag.text(), + (versionSuffix != null) ? versionSuffix : ""); + } + } else if(tag.name().equals("@"+SummaryTaglet.NAME)) summary = tag.text(); else if(tag.name().equals("@"+DescriptionTaglet.NAME))