Switched to new semver mustache template.
This commit is contained in:
parent
492bf96e02
commit
8a8de137d1
4 changed files with 160 additions and 283 deletions
|
@ -13,45 +13,20 @@ import java.time.*;
|
||||||
* Annotation Processor</a>
|
* Annotation Processor</a>
|
||||||
*/
|
*/
|
||||||
public final class ReleaseInfo {
|
public final class ReleaseInfo {
|
||||||
private final static String buildmeta = "018";
|
private final static String DEFAULT_PRERELEASE_PREFIX = "-";
|
||||||
private final static LocalDateTime date =
|
private final static String DEFAULT_BUILDMETA_PREFIX = "+";
|
||||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(1491238266337L), ZoneId.systemDefault());
|
|
||||||
private final static int major = 0;
|
public final static String project = "mobibot";
|
||||||
private final static int minor = 7;
|
public final static LocalDateTime buildDate =
|
||||||
private final static int patch = 0;
|
LocalDateTime.ofInstant(Instant.ofEpochMilli(1492880264977L), ZoneId.systemDefault());
|
||||||
private final static String prerelease = "beta";
|
public final static int major = 0;
|
||||||
private final static String project = "mobibot";
|
public final static int minor = 7;
|
||||||
|
public final static int patch = 1;
|
||||||
|
public final static String preRelease = "beta";
|
||||||
|
public final static String buildMeta = "018";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables the default constructor.
|
* The full version string.
|
||||||
*
|
|
||||||
* @throws UnsupportedOperationException If the constructor is called.
|
|
||||||
*/
|
|
||||||
private ReleaseInfo()
|
|
||||||
throws UnsupportedOperationException {
|
|
||||||
throw new UnsupportedOperationException("Illegal constructor call.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the build date.
|
|
||||||
*
|
|
||||||
* @return The build date.
|
|
||||||
*/
|
|
||||||
public static LocalDateTime getBuildDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the project name.
|
|
||||||
*
|
|
||||||
* @return The project name, if any.
|
|
||||||
*/
|
|
||||||
public static String getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full version string.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Formatted as:
|
* Formatted as:
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
|
@ -65,94 +40,65 @@ public final class ReleaseInfo {
|
||||||
* <li><code>1.0.0+20160124144700</code></li>
|
* <li><code>1.0.0+20160124144700</code></li>
|
||||||
* <li><code>1.0.0-alpha+001</code></li>
|
* <li><code>1.0.0-alpha+001</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
|
||||||
* @return The version string.
|
|
||||||
*/
|
*/
|
||||||
public static String getVersion() {
|
public final static String version = Integer.toString(major) + '.'
|
||||||
return Integer.toString(getMajor()) + '.'
|
+ Integer.toString(minor) + '.'
|
||||||
+ Integer.toString(getMinor()) + '.'
|
+ Integer.toString(patch)
|
||||||
+ Integer.toString(getPatch())
|
+ preReleaseWithPrefix() + buildMetaWithPrefix();
|
||||||
+ getPreRelease(true) + getBuildMetadata(true);
|
|
||||||
|
/**
|
||||||
|
* Disables the default constructor.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException If the constructor is called.
|
||||||
|
*/
|
||||||
|
private ReleaseInfo()
|
||||||
|
throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the major version.
|
* Returns the build metadata with default prefix.
|
||||||
*
|
*
|
||||||
* @return The major version.
|
* @return The build metadata, if any.
|
||||||
*/
|
*/
|
||||||
public static int getMajor() {
|
public static String buildMetaWithPrefix() {
|
||||||
return major;
|
return buildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the minor version.
|
|
||||||
*
|
|
||||||
* @return The minor version.
|
|
||||||
*/
|
|
||||||
public static int getMinor() {
|
|
||||||
return minor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the patch version.
|
|
||||||
*
|
|
||||||
* @return The patch version.
|
|
||||||
*/
|
|
||||||
public static int getPatch() {
|
|
||||||
return patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the pre-release version.
|
|
||||||
*
|
|
||||||
* @param isHyphen Prepend a hyphen, if <code>true</code>.
|
|
||||||
* @return The pre-release version, if any.
|
|
||||||
*/
|
|
||||||
public static String getPreRelease(final boolean isHyphen) {
|
|
||||||
if (prerelease.length() > 0) {
|
|
||||||
if (isHyphen) {
|
|
||||||
return '-' + prerelease;
|
|
||||||
} else {
|
|
||||||
return prerelease;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the pre-release version.
|
|
||||||
*
|
|
||||||
* @return The pre-release version, if any.
|
|
||||||
*/
|
|
||||||
public static String getPreRelease() {
|
|
||||||
return getPreRelease(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the build metadata.
|
* Returns the build metadata.
|
||||||
*
|
*
|
||||||
* @param isPlus Prepend a plus sign, if <code>true</code>.
|
* @param prefix Prefix to prepend.
|
||||||
* @return The build metadata, if any.
|
* @return The build metadata, if any.
|
||||||
*/
|
*/
|
||||||
public static String getBuildMetadata(final boolean isPlus) {
|
public static String buildMetaWithPrefix(final String prefix) {
|
||||||
if (buildmeta.length() > 0) {
|
if (buildMeta.length() > 0 && prefix.length() > 0) {
|
||||||
if (isPlus) {
|
return prefix + buildMeta;
|
||||||
return '+' + buildmeta;
|
|
||||||
} else {
|
} else {
|
||||||
return buildmeta;
|
return buildMeta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the build metadata.
|
* Returns the pre-release version with default prefix.
|
||||||
*
|
*
|
||||||
* @return The build metadata, if any.
|
* @return The pre-release version, if any.
|
||||||
*/
|
*/
|
||||||
public static String getBuildMetadata() {
|
public static String preReleaseWithPrefix() {
|
||||||
return getBuildMetadata(false);
|
return preReleaseWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pre-release version.
|
||||||
|
*
|
||||||
|
* @param prefix The prefix to prepend.
|
||||||
|
* @return The pre-release version, if any.
|
||||||
|
*/
|
||||||
|
public static String preReleaseWithPrefix(final String prefix) {
|
||||||
|
if (preRelease.length() > 0 && prefix.length() > 0) {
|
||||||
|
return prefix + preRelease;
|
||||||
|
} else {
|
||||||
|
return preRelease;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -69,7 +69,7 @@ public class Mobibot extends PircBot {
|
||||||
|
|
||||||
// The info strings.
|
// The info strings.
|
||||||
private static final String[] INFO_STRS = {
|
private static final String[] INFO_STRS = {
|
||||||
ReleaseInfo.getProject() + " v" + ReleaseInfo.getVersion() + " by Erik C. Thauvin (erik@thauvin.net)",
|
ReleaseInfo.project + " v" + ReleaseInfo.version + " by Erik C. Thauvin (erik@thauvin.net)",
|
||||||
"http://www.mobitopia.org/mobibot/"
|
"http://www.mobitopia.org/mobibot/"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ public class Mobibot extends PircBot {
|
||||||
// The version strings.
|
// The version strings.
|
||||||
private static final String[] VERSION_STRS = {
|
private static final String[] VERSION_STRS = {
|
||||||
"Version: "
|
"Version: "
|
||||||
+ ReleaseInfo.getVersion()
|
+ ReleaseInfo.version
|
||||||
+ " ("
|
+ " ("
|
||||||
+ Utils.isoLocalDate(ReleaseInfo.getBuildDate()) + ')',
|
+ Utils.isoLocalDate(ReleaseInfo.buildDate) + ')',
|
||||||
"Platform: "
|
"Platform: "
|
||||||
+ System.getProperty("os.name")
|
+ System.getProperty("os.name")
|
||||||
+ " ("
|
+ " ("
|
||||||
|
|
104
version.mustache
Normal file
104
version.mustache
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* This file is automatically generated.
|
||||||
|
* Do not modify! -- ALL CHANGES WILL BE ERASED!
|
||||||
|
*/
|
||||||
|
package {{packageName}};
|
||||||
|
|
||||||
|
import java.time.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides semantic version information.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
|
||||||
|
* Annotation Processor</a>
|
||||||
|
*/
|
||||||
|
public final class {{className}} {
|
||||||
|
private final static String DEFAULT_PRERELEASE_PREFIX = "-";
|
||||||
|
private final static String DEFAULT_BUILDMETA_PREFIX = "+";
|
||||||
|
|
||||||
|
public final static String project = "{{project}}";
|
||||||
|
public final static LocalDateTime buildDate =
|
||||||
|
LocalDateTime.ofInstant(Instant.ofEpochMilli({{epoch}}L), ZoneId.systemDefault());
|
||||||
|
public final static int major = {{major}};
|
||||||
|
public final static int minor = {{minor}};
|
||||||
|
public final static int patch = {{patch}};
|
||||||
|
public final static String preRelease = "{{preRelease}}";
|
||||||
|
public final static String buildMeta = "{{buildMeta}}";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full version string.
|
||||||
|
* <p>
|
||||||
|
* Formatted as:
|
||||||
|
* <blockquote>
|
||||||
|
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
|
||||||
|
* </blockquote>
|
||||||
|
* <p>
|
||||||
|
* For example:
|
||||||
|
* <ul>
|
||||||
|
* <li><code>1.0.0</code></li>
|
||||||
|
* <li><code>1.0.0-beta</code></li>
|
||||||
|
* <li><code>1.0.0+20160124144700</code></li>
|
||||||
|
* <li><code>1.0.0-alpha+001</code></li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public final static String version = Integer.toString(major) + '.'
|
||||||
|
+ Integer.toString(minor) + '.'
|
||||||
|
+ Integer.toString(patch)
|
||||||
|
+ preReleaseWithPrefix() + buildMetaWithPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the default constructor.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException If the constructor is called.
|
||||||
|
*/
|
||||||
|
private {{className}}()
|
||||||
|
throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build metadata with default prefix.
|
||||||
|
*
|
||||||
|
* @return The build metadata, if any.
|
||||||
|
*/
|
||||||
|
public static String buildMetaWithPrefix() {
|
||||||
|
return buildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build metadata.
|
||||||
|
*
|
||||||
|
* @param prefix Prefix to prepend.
|
||||||
|
* @return The build metadata, if any.
|
||||||
|
*/
|
||||||
|
public static String buildMetaWithPrefix(final String prefix) {
|
||||||
|
if (buildMeta.length() > 0 && prefix.length() > 0) {
|
||||||
|
return prefix + buildMeta;
|
||||||
|
} else {
|
||||||
|
return buildMeta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pre-release version with default prefix.
|
||||||
|
*
|
||||||
|
* @return The pre-release version, if any.
|
||||||
|
*/
|
||||||
|
public static String preReleaseWithPrefix() {
|
||||||
|
return preReleaseWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pre-release version.
|
||||||
|
*
|
||||||
|
* @param prefix The prefix to prepend.
|
||||||
|
* @return The pre-release version, if any.
|
||||||
|
*/
|
||||||
|
public static String preReleaseWithPrefix(final String prefix) {
|
||||||
|
if (preRelease.length() > 0 && prefix.length() > 0) {
|
||||||
|
return prefix + preRelease;
|
||||||
|
} else {
|
||||||
|
return preRelease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
173
version.vm
173
version.vm
|
@ -1,173 +0,0 @@
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Available variables:
|
|
||||||
##
|
|
||||||
## $packageName - The package name. (string)
|
|
||||||
## $className - The class name. (string)
|
|
||||||
## $project - The project name. (string)
|
|
||||||
## $epoch - The build epoch/unix time. (long)
|
|
||||||
## $major - The major version. (int)
|
|
||||||
## $minor - The minor version. (int)
|
|
||||||
## $patch - The patch version. (int)
|
|
||||||
## $prerelease - The pre-release version. (string)
|
|
||||||
## $buildmeta - The build metadata version. (string)
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
/*
|
|
||||||
* This file is automatically generated.
|
|
||||||
* Do not modify! -- ALL CHANGES WILL BE ERASED!
|
|
||||||
*/
|
|
||||||
package ${packageName};
|
|
||||||
|
|
||||||
import java.time.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides semantic version information.
|
|
||||||
*
|
|
||||||
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
|
|
||||||
* Annotation Processor</a>
|
|
||||||
*/
|
|
||||||
public final class ${className} {
|
|
||||||
private final static String buildmeta = "${buildmeta}";
|
|
||||||
private final static LocalDateTime date =
|
|
||||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(${epoch}L), ZoneId.systemDefault());
|
|
||||||
private final static int major = ${major};
|
|
||||||
private final static int minor = ${minor};
|
|
||||||
private final static int patch = ${patch};
|
|
||||||
private final static String prerelease = "${prerelease}";
|
|
||||||
private final static String project = "${project}";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the default constructor.
|
|
||||||
*
|
|
||||||
* @throws UnsupportedOperationException If the constructor is called.
|
|
||||||
*/
|
|
||||||
private ${className}()
|
|
||||||
throws UnsupportedOperationException {
|
|
||||||
throw new UnsupportedOperationException("Illegal constructor call.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the build date.
|
|
||||||
*
|
|
||||||
* @return The build date.
|
|
||||||
*/
|
|
||||||
public static LocalDateTime getBuildDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the project name.
|
|
||||||
*
|
|
||||||
* @return The project name, if any.
|
|
||||||
*/
|
|
||||||
public static String getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full version string.
|
|
||||||
* <p>
|
|
||||||
* Formatted as:
|
|
||||||
* <blockquote>
|
|
||||||
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
|
|
||||||
* </blockquote>
|
|
||||||
* <p>
|
|
||||||
* For example:
|
|
||||||
* <ul>
|
|
||||||
* <li><code>1.0.0</code></li>
|
|
||||||
* <li><code>1.0.0-beta</code></li>
|
|
||||||
* <li><code>1.0.0+20160124144700</code></li>
|
|
||||||
* <li><code>1.0.0-alpha+001</code></li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @return The version string.
|
|
||||||
*/
|
|
||||||
public static String getVersion() {
|
|
||||||
return Integer.toString(getMajor()) + '.'
|
|
||||||
+ Integer.toString(getMinor()) + '.'
|
|
||||||
+ Integer.toString(getPatch())
|
|
||||||
+ getPreRelease(true) + getBuildMetadata(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the major version.
|
|
||||||
*
|
|
||||||
* @return The major version.
|
|
||||||
*/
|
|
||||||
public static int getMajor() {
|
|
||||||
return major;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the minor version.
|
|
||||||
*
|
|
||||||
* @return The minor version.
|
|
||||||
*/
|
|
||||||
public static int getMinor() {
|
|
||||||
return minor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the patch version.
|
|
||||||
*
|
|
||||||
* @return The patch version.
|
|
||||||
*/
|
|
||||||
public static int getPatch() {
|
|
||||||
return patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the pre-release version.
|
|
||||||
*
|
|
||||||
* @param isHyphen Prepend a hyphen, if <code>true</code>.
|
|
||||||
* @return The pre-release version, if any.
|
|
||||||
*/
|
|
||||||
public static String getPreRelease(final boolean isHyphen) {
|
|
||||||
if (prerelease.length() > 0) {
|
|
||||||
if (isHyphen) {
|
|
||||||
return '-' + prerelease;
|
|
||||||
} else {
|
|
||||||
return prerelease;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the pre-release version.
|
|
||||||
*
|
|
||||||
* @return The pre-release version, if any.
|
|
||||||
*/
|
|
||||||
public static String getPreRelease() {
|
|
||||||
return getPreRelease(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the build metadata.
|
|
||||||
*
|
|
||||||
* @param isPlus Prepend a plus sign, if <code>true</code>.
|
|
||||||
* @return The build metadata, if any.
|
|
||||||
*/
|
|
||||||
public static String getBuildMetadata(final boolean isPlus) {
|
|
||||||
if (buildmeta.length() > 0) {
|
|
||||||
if (isPlus) {
|
|
||||||
return '+' + buildmeta;
|
|
||||||
} else {
|
|
||||||
return buildmeta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the build metadata.
|
|
||||||
*
|
|
||||||
* @return The build metadata, if any.
|
|
||||||
*/
|
|
||||||
public static String getBuildMetadata() {
|
|
||||||
return getBuildMetadata(false);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue