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.
This commit is contained in:
parent
3c9497788e
commit
139c6b84a1
29
build.xml
29
build.xml
|
|
@ -167,12 +167,29 @@
|
||||||
<property name="scala.target" value="core"/>
|
<property name="scala.target" value="core"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- define some key locations that might change based on how the build is run -->
|
<target name="git.describe">
|
||||||
<target name="init">
|
<exec executable="git" outputproperty="git.describe.output" resultproperty="git.describe.exit.value" failonerror="false">
|
||||||
<!-- define build version and timestamp -->
|
<arg line="describe" />
|
||||||
<exec executable="git" outputproperty="build.version" failonerror="true">
|
|
||||||
<arg line="rev-parse HEAD"/>
|
|
||||||
</exec>
|
</exec>
|
||||||
|
<condition property="git.describe.succeeded">
|
||||||
|
<equals arg1="${git.describe.exit.value}" arg2="0" />
|
||||||
|
</condition>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="tagged.build.version" depends="git.describe" if="git.describe.succeeded">
|
||||||
|
<property name="build.version" value="${git.describe.output}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="untagged.build.version" depends="git.describe" unless="git.describe.succeeded">
|
||||||
|
<exec executable="git" outputproperty="build.version" failonerror="true">
|
||||||
|
<arg line="rev-parse HEAD" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="generate.build.version" depends="tagged.build.version, untagged.build.version" />
|
||||||
|
|
||||||
|
<!-- define some key locations that might change based on how the build is run -->
|
||||||
|
<target name="init" depends="generate.build.version">
|
||||||
<tstamp>
|
<tstamp>
|
||||||
<format property="build.timestamp" pattern="yyyy/MM/dd HH:mm:ss"/>
|
<format property="build.timestamp" pattern="yyyy/MM/dd HH:mm:ss"/>
|
||||||
</tstamp>
|
</tstamp>
|
||||||
|
|
@ -394,7 +411,7 @@
|
||||||
docletpathref="doclet.classpath"
|
docletpathref="doclet.classpath"
|
||||||
classpathref="external.dependencies"
|
classpathref="external.dependencies"
|
||||||
classpath="${java.classes}"
|
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">
|
||||||
<sourcefiles>
|
<sourcefiles>
|
||||||
<union>
|
<union>
|
||||||
<fileset refid="modified.source.files"/>
|
<fileset refid="modified.source.files"/>
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class ResourceBundleExtractorDoclet {
|
||||||
*/
|
*/
|
||||||
public static boolean start(RootDoc rootDoc) throws IOException {
|
public static boolean start(RootDoc rootDoc) throws IOException {
|
||||||
PrintStream out = System.out;
|
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()) {
|
for(String[] options: rootDoc.options()) {
|
||||||
if(options[0].equals("-out")) {
|
if(options[0].equals("-out")) {
|
||||||
|
|
@ -79,6 +79,8 @@ public class ResourceBundleExtractorDoclet {
|
||||||
versionPrefix = options[1];
|
versionPrefix = options[1];
|
||||||
if(options[0].equals("-version-suffix"))
|
if(options[0].equals("-version-suffix"))
|
||||||
versionSuffix = options[1];
|
versionSuffix = options[1];
|
||||||
|
if (options[0].equals("-absolute-version"))
|
||||||
|
absoluteVersion = options[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceText.setProperty("build.timestamp",buildTimestamp);
|
resourceText.setProperty("build.timestamp",buildTimestamp);
|
||||||
|
|
@ -93,11 +95,11 @@ public class ResourceBundleExtractorDoclet {
|
||||||
if(isRequiredJavadocMissing(currentClass) && isWalker(currentClass))
|
if(isRequiredJavadocMissing(currentClass) && isWalker(currentClass))
|
||||||
undocumentedWalkers.add(currentClass.name());
|
undocumentedWalkers.add(currentClass.name());
|
||||||
|
|
||||||
renderHelpText(getClassName(currentClass),currentClass,versionPrefix,versionSuffix);
|
renderHelpText(getClassName(currentClass),currentClass,versionPrefix,versionSuffix,absoluteVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PackageDoc currentPackage: packages)
|
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");
|
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.
|
* @return Number of potential parameters; 0 if not supported.
|
||||||
*/
|
*/
|
||||||
public static int optionLength(String option) {
|
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 2;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -194,7 +196,7 @@ public class ResourceBundleExtractorDoclet {
|
||||||
* @param versionPrefix Text to add to the start of the version string.
|
* @param versionPrefix Text to add to the start of the version string.
|
||||||
* @param versionSuffix Text to add to the end 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.
|
// Extract overrides from the doc tags.
|
||||||
String name = null;
|
String name = null;
|
||||||
String version = 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.");
|
throw new ReviewedStingException("Only one display name tag can be used per package / walker.");
|
||||||
name = tag.text();
|
name = tag.text();
|
||||||
}
|
}
|
||||||
else if(tag.name().equals("@"+VERSION_TAGLET_NAME))
|
else if(tag.name().equals("@"+VERSION_TAGLET_NAME)) {
|
||||||
version = String.format("%s%s%s", (versionPrefix != null) ? versionPrefix : "",
|
if ( absoluteVersion != null ) {
|
||||||
tag.text(),
|
version = absoluteVersion;
|
||||||
(versionSuffix != null) ? versionSuffix : "");
|
}
|
||||||
|
else {
|
||||||
|
version = String.format("%s%s%s", (versionPrefix != null) ? versionPrefix : "",
|
||||||
|
tag.text(),
|
||||||
|
(versionSuffix != null) ? versionSuffix : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(tag.name().equals("@"+SummaryTaglet.NAME))
|
else if(tag.name().equals("@"+SummaryTaglet.NAME))
|
||||||
summary = tag.text();
|
summary = tag.text();
|
||||||
else if(tag.name().equals("@"+DescriptionTaglet.NAME))
|
else if(tag.name().equals("@"+DescriptionTaglet.NAME))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue