diff --git a/README.md b/README.md
index 56fbb72..ea64eab 100644
--- a/README.md
+++ b/README.md
@@ -191,11 +191,17 @@ To install and run from [Maven](https://maven.apache.org/), configure an artifac
```
+Please look at [pom.xml](https://github.com/ethauvin/semver/blob/master/examples/java/pom.xml) in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) directory for a sample:
+
+```bash
+mvn compile exec:java
+```
+
### Gradle
#### Class Generation
-To install and run from [Gradle](https://gradle.org/), add the following to the `build.gradle` file:
+To install and run from [Gradle](https://gradle.org/), add the following to `build.gradle`:
```gradle
dependencies {
@@ -208,7 +214,7 @@ The `GeneratedVersion` class will be automatically created in the `build/generat
#### Class & Source Generation
-In order to also incorporate the generated source code into the `source tree`, add the following to the very top of the `build.gradle` file:
+In order to also incorporate the generated source code into the `source tree`, add the following to the very top of `build.gradle`:
```gradle
compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
@@ -216,7 +222,7 @@ compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${proje
The `GeneratedVersion.java` file will now be located in `src/generated`.
-Please look at the [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle) file in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) module directory for a sample.
+Please look at [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle) in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) directory for a sample.
### Kotlin
@@ -235,7 +241,7 @@ The [Kotlin default template](https://github.com/ethauvin/semver/blob/master/src
#### Kotlin & Gradle
-To install and run from [Gradle](https://gradle.org/), add the following to the `build.gradle.kts` file:
+To install and run from [Gradle](https://gradle.org/), add the following to `build.gradle.kts`:
```kotlin
var semverProcessor = "net.thauvin.erik:semver:1.2.0"
@@ -245,19 +251,19 @@ dependencies {
compileOnly(semverProcessor)
}
```
-As of [Kotlin 1.2.30](https://blog.jetbrains.com/kotlin/2019/04/kotlin-1-3-30-released/#more-6991), when using `kapt` you must include the following to the `gradle.properties` file:
+As of [Kotlin 1.2.30](https://blog.jetbrains.com/kotlin/2019/04/kotlin-1-3-30-released/#more-6991), when using `kapt` you must include the following in `gradle.properties`:
```ini
kapt.use.worker.api=true
```
-This option will likely be enabled by default in the future.
+This option will likely be enabled by default in the future, but is currently not working under Java 10/11 see [KT-26203](https://youtrack.jetbrains.net/issue/KT-26203).
Please look at the [Kotlin example](https://github.com/ethauvin/semver/tree/master/examples/kotlin) project for a [build.gradle.kts](https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts) sample.
### Kobalt
-To install and run from [Kobalt](https://beust.com/kobalt/), add the following to the `Build.kt` file:
+To install and run from [Kobalt](https://beust.com/kobalt/), add the following to `Build.kt`:
```gradle
dependencies {
@@ -266,7 +272,7 @@ dependencies {
}
```
-Please look at the [Build.kt](https://github.com/ethauvin/semver/blob/master/examples/java/kobalt/src/Build.kt) file in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) module directory for a sample.
+Please look at [Build.kt](https://github.com/ethauvin/semver/blob/master/examples/java/kobalt/src/Build.kt) in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) directory for a sample.
## Auto-Increment
diff --git a/docs/README.html b/docs/README.html
index 3215637..0fa5011 100644
--- a/docs/README.html
+++ b/docs/README.html
@@ -85,6 +85,31 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
An annotation processor that automatically generates a GeneratedVersion
class based on a Mustache template and containing the semantic version (major, minor, patch, etc.) that is read from a Properties
file or defined in the annotation.
This processor was inspired by Cédric Beust's version-processor and works well in conjunction with the Semantic Version Plugin for Gradle.
+The default template implements the following static fields:
+The default template implements the following static variables:
And the following methods/functions:
-Method | -Description | -Example | -
---|---|---|
preReleaseWithPrefix() |
-Returns the pre-release with a prefix, - by default. |
--alpha |
-
buildMetaWithPrefix() |
-Returns the build metadata with a prefix, + by default. |
-+001 |
-
A very simple custom template might look something like:
/* version.mustache */
@@ -215,12 +218,8 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
public final class {{className}} {
public final static String PROJECT = "{{project}}";
public final static Date DATE = 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 BUILDMETA = "{{buildMeta}}";
-}
The mustache variables automatically filled in by the processor are:
The version separator. | String |
+|
{{semver}} or {{version}} |
+The full semantic version. | +String |
+
Please also look at this example using java.time
⚠️ keysPrefix
is a new element staring in 1.1.0
and may break older versions when using custom property keys.
⚡ A quick fix is to include keysPrefix=""
in the annotation to remove the default version.
prefix.
To install and run from Maven, configure an artifact as follows:
<dependency>
@@ -431,9 +435,11 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
<artifactId>semver</artifactId>
<version>1.2.0</version>
</dependency>
Please look at pom.xml in the Java example directory for a sample:
+To install and run from Gradle, add the following to the build.gradle
file:
To install and run from Gradle, add the following to build.gradle
:
dependencies {
annotationProcessor 'net.thauvin.erik:semver:1.2.0'
compileOnly 'net.thauvin.erik:semver:1.2.0'
@@ -441,19 +447,11 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
The GeneratedVersion
class will be automatically created in the build/generated
directory upon compiling.
In order to also incorporate the generated source code into the source tree
, add the following to the very top of the build.gradle
file:
In order to also incorporate the generated source code into the source tree
, add the following to the very top of build.gradle
:
compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
The GeneratedVersion.java
file will now be located in src/generated
.
Please look at the build.gradle file in the Java example module directory for a sample.
-To install and run from Kobalt, add the following to the Build.kt
file:
dependencies {
- 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.
+Please look at build.gradle in the Java example directory for a sample.
The annotation processor also supports Kotlin.
To generate a Kotlin version file, simply specify the type
as follows:
The Kotlin default template implements the same static fields and functions as the Java template.
-Please look at the Kotlin example project for samples on using Gradle (build.gradle.kts) and Kobalt (Build.kt).
+To install and run from Gradle, add the following to build.gradle.kts
:
var semverProcessor = "net.thauvin.erik:semver:1.2.0"
+
+dependencies {
+ kapt(semverProcessor)
+ compileOnly(semverProcessor)
+}
As of Kotlin 1.2.30, when using kapt
you must include the following in gradle.properties
:
This option will likely be enabled by default in the future, but is currently not working under Java 10/11 see KT-26203.
+Please look at the Kotlin example project for a build.gradle.kts sample.
+To install and run from Kobalt, add the following to Build.kt
:
dependencies {
+ apt("net.thauvin.erik:semver:1.2.0")
+ compileOnly("net.thauvin.erik:semver:1.2.0")
+}
+
+Please look at Build.kt in the Java example directory for a sample.
Incrementing the version is best left to your favorite build system. For a solution using Gradle, please have a look at the Semver Version Plugin for Gradle.
There are also full examples in both Java and Kotlin showing how to use both the plugin and annotation processor concurrently.