Added support for mustache instead of Velocity.
This commit is contained in:
parent
13dec4f063
commit
5efb2a9e1d
10 changed files with 199 additions and 133 deletions
172
src/main/resources/semver.mustache
Normal file
172
src/main/resources/semver.mustache
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* This file is automatically generated.
|
||||
* Do not modify! -- ALL CHANGES WILL BE ERASED!
|
||||
*/
|
||||
package {{packageName}};
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 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 = "+";
|
||||
|
||||
private final static String project = "{{project}}";
|
||||
private final static Date date = new Date({{epoch}}L);
|
||||
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 buildMeta = "{{buildMeta}}";
|
||||
|
||||
|
||||
/**
|
||||
* 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 Date 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())
|
||||
+ getPreReleaseWithPrefix + getBuildMetaWithPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return The pre-release version, if any
|
||||
*/
|
||||
public static int getPreRelease() {
|
||||
return preRelease;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build metadata.
|
||||
*
|
||||
* @return The build metadata, if any.
|
||||
*/
|
||||
public static String getBuildMeta() {
|
||||
return buildMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pre-release version with default prefix.
|
||||
*
|
||||
* @return The pre-release version, if any.
|
||||
*/
|
||||
public static String getPreReleaseWithPrefix() {
|
||||
return getPreReleaseWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pre-release version.
|
||||
*
|
||||
* @param prefix The prefix to prepend.
|
||||
* @return The pre-release version, if any.
|
||||
*/
|
||||
public static String getPreReleaseWithPrefix(final String prefix) {
|
||||
if (preRelease.length() > 0 && prefix.length() > 0) {
|
||||
return prefix + preRelease;
|
||||
} else {
|
||||
return preRelease;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build metadata with default prefix.
|
||||
*
|
||||
* @param prefix The prefix to prepend.
|
||||
* @return The build metadata, if any.
|
||||
*/
|
||||
public static String getBuildMetaWithPrefix() {
|
||||
return getBuildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build metadata.
|
||||
*
|
||||
* @param prefix Prefix to prepend.
|
||||
* @return The build metadata, if any.
|
||||
*/
|
||||
public static String getBuildMetaWithPrefix(final String prefix) {
|
||||
if (buildMeta.length() > 0 && prefix.length() > 0) {
|
||||
return prefix + buildMeta;
|
||||
} else {
|
||||
return buildMeta;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue