diff --git a/.idea/modules/examples-kotlin_main.iml b/.idea/modules/examples-kotlin_main.iml index f6c1db1..7ea61a1 100644 --- a/.idea/modules/examples-kotlin_main.iml +++ b/.idea/modules/examples-kotlin_main.iml @@ -5,6 +5,13 @@ + + diff --git a/.idea/modules/examples-kotlin_test.iml b/.idea/modules/examples-kotlin_test.iml index f6c1db1..de16718 100644 --- a/.idea/modules/examples-kotlin_test.iml +++ b/.idea/modules/examples-kotlin_test.iml @@ -5,6 +5,20 @@ + + diff --git a/README.md b/README.md index 0b0e976..5d1758d 100644 --- a/README.md +++ b/README.md @@ -55,18 +55,21 @@ public class A { ### Default Template -The [default template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache) implements the following static fields: +The [default template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache ) implements the following static fields: -Field | Description | Example -:--------------|:---------------------------------|:----------------- -`PROJECT` | The project name, if any. | `MyProject` -`BUILDDATE` | The build date. | [`java.util.Date`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html) -`VERSION` | The full version string. | `1.2.3-alpha+001` -`MAJOR` | The major version. | `1` -`MINOR` | The minor version. | `2` -`PATCH` | The patch version. | `3` -`PRERELEASE` | The pre-release version, if any. | `alpha` -`BUILDMETA` | The build metadata, if any. | `001` +Field | Description | Example +:------------------|:---------------------------------|:----------------- +`PROJECT` | The project name, if any. | `MyProject` +`BUILDDATE` | The build date. | [`java.util.Date`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html) +`VERSION` | The full version string. | `1.2.3-alpha+001` +`MAJOR` | The major version. | `1` +`MINOR` | The minor version. | `2` +`PATCH` | The patch version. | `3` +`PRERELEASE` | The pre-release version, if any. | `alpha` +`PRERELASE_PREFIX` | The pre-release prefix | `-` +`BUILDMETA` | The build metadata, if any. | `001` +`BUILDMETA_PREFIX` | The metadata prefix. | `+` +`SEPARATOR` | The version separator. | `.` And the following methods/functions: @@ -97,17 +100,20 @@ public final class {{className}} { ``` The mustache variables automatically filled in by the processor are: -Variable | Description | Type -:-----------------|:----------------------------|:-------- -`{{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` +Variable | Description | Type +:----------------------|:----------------------------|:-------- +`{{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` +`{{preReleasePrefix}}` | The pre-release prefix. | `String` +`{{buildMeta}}` | The build metadata version. | `String` +`{{buildMetaPrefix}}` | The metadata prefix. | `String` +`{{separator}}` | The version separator. | `String` Please also look at this [example](https://github.com/ethauvin/mobibot/blob/master/version.mustache) using [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) @@ -115,20 +121,23 @@ Please also look at this [example](https://github.com/ethauvin/mobibot/blob/mast The following annotation elements and properties are available: -Element | Property | Description | Default -:-------------|:---------------------|:----------------------------------|:------------------------- -`project` | `version.project` | The project name. | -`major` | `version.major` | The major version number. | `1` -`minor` | `version.major` | The minor version number. | `0` -`patch` | `version.patch` | The patch version number. | `0` -`preRelease` | `version.prerelease` | The pre-release version. | -`buildMeta` | `version.buildmeta` | The build metadata version. | -`packageName` | | The package name. | _Same as annotated class_ -`className` | | The name of the generated class. | `GeneratedVersion` -`properties` | | The properties file. | -`template` | | The template file. | `version.mustache` -`type` | | Either `java` or `kt` for Kotlin. | `java` -`keysPrefix` | | The prefix for all property keys. | `version.` +Element | Property | Description | Default +:------------------|:----------------------------|:----------------------------------|:------------------------- +`project` | `version.project` | The project name. | +`major` | `version.major` | The major version number. | `1` +`minor` | `version.major` | The minor version number. | `0` +`patch` | `version.patch` | The patch version number. | `0` +`preRelease` | `version.prerelease` | The pre-release version. | +`preReleasePrefix` | `version.prerelease.prefix` | The pre-release prefix. | `-` +`buildMeta` | `version.buildmeta` | The build metadata version. | +`buildMetaPrefix` | `version.buildmeta.prefix` | The metadata prefix. | `+` +`separator` | `version.separator` | The version separator. | `.` +`packageName` | | The package name. | _Same as annotated class_ +`className` | | The name of the generated class. | `GeneratedVersion` +`properties` | | The properties file. | +`template` | | The template file. | `version.mustache` +`type` | | Either `java` or `kt` for Kotlin. | `java` +`keysPrefix` | | The prefix for all property keys. | `version.` In order to easily incorporate with existing projects, the property keys may be assigned custom values: @@ -171,7 +180,7 @@ To install and run from [Maven](https://maven.apache.org/), configure an artifac net.thauvin.erik semver - 1.1.1 + 1.2.0 ``` @@ -183,8 +192,8 @@ To install and run from [Gradle](https://gradle.org/), add the following to the ```gradle dependencies { - annotationProcessor 'net.thauvin.erik:semver:1.1.1' - compileOnly 'net.thauvin.erik:semver:1.1.1' + annotationProcessor 'net.thauvin.erik:semver:1.2.0' + compileOnly 'net.thauvin.erik:semver:1.2.0' } ``` @@ -208,8 +217,8 @@ To install and run from [Kobalt](https://beust.com/kobalt/), add the following t ```gradle dependencies { - apt("net.thauvin.erik:semver:1.1.1") - compileOnly("net.thauvin.erik:semver:1.1.1") + apt("net.thauvin.erik:semver:1.2.0") + compileOnly("net.thauvin.erik:semver:1.2.0") } ``` diff --git a/docs/README.html b/docs/README.html index c4debaf..f4ecc35 100644 --- a/docs/README.html +++ b/docs/README.html @@ -162,10 +162,25 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni alpha +PRERELASE_PREFIX +The pre-release prefix +- + + BUILDMETA The build metadata, if any. 001 + +BUILDMETA_PREFIX +The metadata prefix. ++ + + +SEPARATOR +The version separator. +. +

And the following methods/functions:

@@ -253,14 +268,29 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni {{preRelease}} -The pre/release version. +The pre-release version. String +{{preReleasePrefix}} +The pre-release prefix. +String + + {{buildMeta}} The build metadata version. String + +{{buildMetaPrefix}} +The metadata prefix. +String + + +{{separator}} +The version separator. +String +

Please also look at this example using java.time

@@ -307,42 +337,60 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni +preReleasePrefix +version.prerelease.prefix +The pre-release prefix. +- + + buildMeta version.buildmeta The build metadata version. + +buildMetaPrefix +version.buildmeta.prefix +The metadata prefix. ++ + +separator +version.separator +The version separator. +. + + packageName The package name. Same as annotated class - + className The name of the generated class. GeneratedVersion - + properties The properties file. - + template The template file. version.mustache - + type Either java or kt for Kotlin. java - + keysPrefix The prefix for all property keys. @@ -381,14 +429,14 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
<dependency>
     <groupId>net.thauvin.erik</groupId>
     <artifactId>semver</artifactId>
-    <version>1.1.1</version>
+    <version>1.2.0</version>
 </dependency>

Gradle

Class Generation

To install and run from Gradle, add the following to the build.gradle file:

dependencies {
-    annotationProcessor 'net.thauvin.erik:semver:1.1.1'
-    compileOnly 'net.thauvin.erik:semver:1.1.1'
+    annotationProcessor 'net.thauvin.erik:semver:1.2.0'
+    compileOnly 'net.thauvin.erik:semver:1.2.0'
 }
 

The GeneratedVersion class will be automatically created in the build/generated directory upon compiling.

@@ -401,8 +449,8 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

Kobalt

To install and run from Kobalt, add the following to the Build.kt file:

dependencies {
-    apt("net.thauvin.erik:semver:1.1.1")
-    compileOnly("net.thauvin.erik:semver:1.1.1")
+    apt("net.thauvin.erik:semver:1.2.0")
+    compileOnly("net.thauvin.erik:semver:1.2.0")
 }
 

Please look at the Build.kt file in the Java example module directory for a sample.

diff --git a/examples/java/build.gradle b/examples/java/build.gradle index 4b2766d..958977e 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'application' defaultTasks 'run' -def semverProcessor = 'net.thauvin.erik:semver:1.1.1' +def semverProcessor = 'net.thauvin.erik:semver:1.2.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/examples/java/src/generated/java/com/example/GeneratedVersion.java b/examples/java/src/generated/java/com/example/GeneratedVersion.java index 4803fd9..ef39f05 100644 --- a/examples/java/src/generated/java/com/example/GeneratedVersion.java +++ b/examples/java/src/generated/java/com/example/GeneratedVersion.java @@ -12,23 +12,23 @@ import java.util.Date; * @author Semantic Version Annotation Processor */ public final class GeneratedVersion { - public final static String PRERELEASE_PREFIX = "-"; - public final static String BUILDMETA_PREFIX = "+"; - public final static String PROJECT = "Example"; - public final static Date BUILDDATE = new Date(1554009013319L); + public final static Date BUILDDATE = new Date(1554108013631L); public final static int MAJOR = 2; - public final static int MINOR = 17; + public final static int MINOR = 0; public final static int PATCH = 52; public final static String PRERELEASE = "beta"; + public final static String PRERELEASE_PREFIX = "-"; public final static String BUILDMETA = "007"; + public final static String BUILDMETA_PREFIX = "+"; + public final static String SEPARATOR = ""; /** * The full version string. *

* Formatted as: *

- * MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA] + * [MAJOR][SEPARATOR][MINOR][SEPARATOR][PATCH][[PRERELEASE_PREFIX][PRERELEASE]][[BUILDMETA_PREFIX][BUILDMETA]] *
*

* For example: @@ -39,10 +39,8 @@ public final class GeneratedVersion { *

  • 1.0.0-alpha+001
  • * */ - 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 GeneratedVersion { * @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 GeneratedVersion { * @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; } } -} \ No newline at end of file +} diff --git a/examples/java/version.properties b/examples/java/version.properties index 0821cbd..d329bec 100644 --- a/examples/java/version.properties +++ b/examples/java/version.properties @@ -2,7 +2,7 @@ #Sat Mar 30 15:48:08 PDT 2019 version.buildmeta=007 version.major=2 -version.minor=17 +version.minor=0 version.patch=52 version.prerelease=beta version.project=Example diff --git a/examples/kotlin/.idea/modules/examples-kotlin_main.iml b/examples/kotlin/.idea/modules/examples-kotlin_main.iml index b2be99a..21ca34c 100644 --- a/examples/kotlin/.idea/modules/examples-kotlin_main.iml +++ b/examples/kotlin/.idea/modules/examples-kotlin_main.iml @@ -6,7 +6,7 @@