Added separator, pre-release and metada prefixes.
This commit is contained in:
parent
e8c00828f3
commit
45a90d1353
7 changed files with 207 additions and 35 deletions
|
@ -12,11 +12,6 @@ import java.util.Date
|
|||
* @author <a href="https://github.com/ethauvin/semver">Semantic Version Annotation Processor</a>
|
||||
*/
|
||||
object {{className}} {
|
||||
@JvmField
|
||||
val PRERELEASE_PREFIX = "-"
|
||||
@JvmField
|
||||
val BUILDMEATA_PREFIX = "+"
|
||||
|
||||
@JvmField
|
||||
val PROJECT = "{{project}}"
|
||||
@JvmField
|
||||
|
@ -30,13 +25,19 @@ object {{className}} {
|
|||
@JvmField
|
||||
val PRERELEASE = "{{preRelease}}"
|
||||
@JvmField
|
||||
val PRERELEASE_PREFIX = "{{preReleasePrefix}}"
|
||||
@JvmField
|
||||
val BUILDMETA = "{{buildMeta}}"
|
||||
@JvmField
|
||||
val BUILDMEATA_PREFIX = "{{buildMetaPrefix}}"
|
||||
@JvmField
|
||||
val SEPARATOR = "{{separator}}"
|
||||
|
||||
/**
|
||||
* The full version string formatted as [MAJOR].[MINOR].[PATCH]-[PRERELEASE]+[BUILDMETA]
|
||||
* The full version string formatted as [MAJOR][SEPARATOR][MINOR][SEPARATOR][PATCH][[PRERELEASE_PREFIX][PRERELEASE]][[BUILDMETA_PREFIX][BUILDMETA]]
|
||||
*/
|
||||
@JvmField
|
||||
val VERSION = "$MAJOR.$MINOR.$PATCH" + preReleaseWithPrefix() + buildMetaWithPrefix()
|
||||
val VERSION = "$MAJOR$SEPARATOR$MINOR$SEPARATOR$PATCH" + preReleaseWithPrefix() + buildMetaWithPrefix()
|
||||
|
||||
/**
|
||||
* Returns the pre-release version with prefix.
|
||||
|
@ -47,7 +48,7 @@ object {{className}} {
|
|||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun preReleaseWithPrefix(prefix: String = PRERELEASE_PREFIX): String {
|
||||
return if (PRERELEASE.isNotEmpty() && prefix.isNotEmpty()) {
|
||||
return if (PRERELEASE.isNotEmpty()) {
|
||||
"$prefix$PRERELEASE"
|
||||
} else {
|
||||
PRERELEASE
|
||||
|
@ -63,10 +64,10 @@ object {{className}} {
|
|||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun buildMetaWithPrefix(prefix: String = BUILDMEATA_PREFIX): String {
|
||||
return if (BUILDMETA.isNotEmpty() && prefix.isNotEmpty()) {
|
||||
return if (BUILDMETA.isNotEmpty()) {
|
||||
"$prefix$BUILDMETA"
|
||||
} else {
|
||||
BUILDMETA
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,23 +12,23 @@ import java.util.Date;
|
|||
* @author <a href="https://github.com/ethauvin/semver">Semantic Version Annotation Processor</a>
|
||||
*/
|
||||
public final class {{className}} {
|
||||
public final static String PRERELEASE_PREFIX = "-";
|
||||
public final static String BUILDMETA_PREFIX = "+";
|
||||
|
||||
public final static String PROJECT = "{{project}}";
|
||||
public final static Date BUILDDATE = new Date({{epoch}}L);
|
||||
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 PRERELEASE_PREFIX = "{{preReleasePrefix}}";
|
||||
public final static String BUILDMETA = "{{buildMeta}}";
|
||||
public final static String BUILDMETA_PREFIX = "{{buildMetaPrefix}}";
|
||||
public final static String SEPARATOR = "{{separator}}";
|
||||
|
||||
/**
|
||||
* The full version string.
|
||||
* <p>
|
||||
* Formatted as:
|
||||
* <blockquote>
|
||||
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
|
||||
* <code>[MAJOR][SEPARATOR][MINOR][SEPARATOR][PATCH][[PRERELEASE_PREFIX][PRERELEASE]][[BUILDMETA_PREFIX][BUILDMETA]]</code>
|
||||
* </blockquote>
|
||||
* <p>
|
||||
* For example:
|
||||
|
@ -39,10 +39,8 @@ public final class {{className}} {
|
|||
* <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();
|
||||
public final static String VERSION = Integer.toString(MAJOR) + SEPARATOR + Integer.toString(MINOR) + SEPARATOR
|
||||
+ Integer.toString(PATCH) + preReleaseWithPrefix() + buildMetaWithPrefix();
|
||||
|
||||
/**
|
||||
* Disables the default constructor.
|
||||
|
@ -70,7 +68,7 @@ public final class {{className}} {
|
|||
* @return The build metadata, if any.
|
||||
*/
|
||||
public static String buildMetaWithPrefix(final String prefix) {
|
||||
if (BUILDMETA.length() > 0 && prefix.length() > 0) {
|
||||
if (BUILDMETA.length() > 0) {
|
||||
return prefix + BUILDMETA;
|
||||
} else {
|
||||
return BUILDMETA;
|
||||
|
@ -93,10 +91,10 @@ public final class {{className}} {
|
|||
* @return The pre-release version, if any.
|
||||
*/
|
||||
public static String preReleaseWithPrefix(final String prefix) {
|
||||
if (PRERELEASE.length() > 0 && prefix.length() > 0) {
|
||||
if (PRERELEASE.length() > 0) {
|
||||
return prefix + PRERELEASE;
|
||||
} else {
|
||||
return PRERELEASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue