diff --git a/README.md b/README.md
index 3db1cb5..cefe757 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ version.prerelease=beta
Upon running the annotation processor, a source file [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/net/thauvin/erik/semver/examples/java/GeneratedVersion.java) is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable [Mustache](https://mustache.github.io/) template.
-To use your own template, simply create a `version.mustache` file. The processor will automatically look for it.
+To use your own template, simply create a `version.mustache` file in the project's root directory. The processor will automatically look for it.
To specify your own template name, use:
@@ -171,7 +171,7 @@ To install and run from [Maven](http://maven.apache.org/), configure an artifact
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.
+This processor was inspired by Cédric Beust's version-processor and works well in conjunction with the Semantic Version Plugin for Gradle.
Upon running the annotation processor, a source file GeneratedVersion.java
is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable Mustache template.
To use your own template, simply create a version.mustache
file. The processor will automatically look for it.
Upon running the annotation processor, a source file GeneratedVersion.java
is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable Mustache template.
To use your own template, simply create a version.mustache
file in the project's root directory. The processor will automatically look for it.
To specify your own template name, use:
@Version(template = "version.mustache")
public class A {
@@ -316,70 +316,67 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
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:
@Version(
properties = "example.properties",
- majorKey = "example.major",
- minorKey = "example.minor",
- patchKey = "example.patch",
- preReleaseKey = "example.prerelease",
- buildMetaKey = "example.buildmeta",
- projectKey = "example.project"
+ keysPrefix = "example."
+ majorKey = "maj",
+ minorKey = "min",
+ patchKey = "build",
+ preReleaseKey = "rel",
+ buildMetaKey = "meta",
+ projectKey = "project"
)
public class Example {
// ...
# example.properties
example.project=Example
-example.major=1
-example.minor=0
-example.patch=0
+example.maj=1
+example.min=0
+example.build=0
+example.rel=beta
+example.meta=
# ...
+
+⚠️ keysPrefix
is a new element 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.
+
Usage with Maven, Grail, Kobalt and Kotlin
Maven
To install and run from Maven, configure an artifact as follows:
<dependency>
<groupId>net.thauvin.erik</groupId>
<artifactId>semver</artifactId>
- <version>1.0.1</version>
+ <version>1.1.0-beta</version>
</dependency>
Gradle
Class Generation
To install and run from Gradle, add the following to the build.gradle
file:
dependencies {
- compileOnly 'net.thauvin.erik:semver:1.0.1'
+ annotationProcessor 'net.thauvin.erik:semver:1.1.0-beta'
+ compileOnly 'net.thauvin.erik:semver:1.1.0-beta'
}
The GeneratedVersion
class will be automatically created in the build/generated
directory upon compiling.
Class & Source Generation
-In order to also incorporate the generated source code into the source tree
, use the EWERK Annotation Processor Plugin. Start by adding the following to the very top of the build.gradle
file:
-plugins {
- id "com.ewerk.gradle.plugins.annotation-processor" version "1.0.4"
-}
-Then add the following to the build.gradle
file:
-dependencies {
- compileOnly 'net.thauvin.erik:semver:1.0.1'
-}
-
-annotationProcessor {
- library 'net.thauvin.erik:semver:1.0.1'
- processor 'net.thauvin.erik.semver.VersionProcessor'
- // sourcesDir 'src/generated/java'
-}
-
-compileJava {
- // Disable the classpath processor
- options.compilerArgs << '-proc:none'
-}
-The plugin implements a separate compile task that only runs the annotation processor and is executed during the build phase.
-Please look at the build.gradle file in the example module directory for a sample.
+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:
+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.
Kobalt
To install and run from Kobalt, add the following to the Build.kt
file:
dependencies {
- apt("net.thauvin.erik:semver:1.0.1")
- compileOnly("net.thauvin.erik:semver:1.0.1")
+ apt("net.thauvin.erik:semver:1.1.0-beta")
+ compileOnly("net.thauvin.erik:semver:1.1.0-beta")
}
-Please look at the Build.kt file in the example module directory for a sample.
+Please look at the Build.kt file in the Kotlin example module directory for a sample.
Kotlin
The annotation processor also supports Kotlin.
To generate a Kotlin version file, simply specify the type
as follows:
@@ -389,11 +386,9 @@ compileJava {
open class Main {
// ...
The Kotlin default template implements the same static fields and functions as the Java template.
-Please look at the Example for Kotlin project for samples on using Gradle (build.gradle) and Kobalt (Build.kt).
-Incrementing the version is best left to your favorite build system.
-For a solution using Gradle, please have a look at the build.gradle file in the example module directory. To run the example with patch version auto-incrementing, issue the following command:
-gradle release run
-For a solution using Kobalt look at my Property File Editor plug-in.
+Please look at the Kotlin example project for samples on using Gradle (build.gradle.kts) and Kobalt (Build.kt).
+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.