diff --git a/build.gradle b/build.gradle index a07ca1a..59a862e 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,6 @@ final def pkgLabels = ['java', 'kotlin', 'annotation', 'processor', 'semantic', sourceCompatibility = 1.8 targetCompatibility = 1.8 -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' repositories { mavenLocal() @@ -53,6 +52,10 @@ dependencies { testImplementation 'org.testng:testng:6.14.3' } +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + pmd { ruleSetFiles = files("config/pmd.xml") ruleSets = [] diff --git a/docs/README.html b/docs/README.html index cf79f94..1235a99 100644 --- a/docs/README.html +++ b/docs/README.html @@ -99,7 +99,6 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
The directory containing the configuration files (version.properties
, version.mustache
) must be specified using the semver.project.dir
processor argument.
The GeneratedVersion.java
class will be automatically created in the build/generated
directory upon compiling.
Please look at build.gradle in the examples/java 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 build.gradle:
compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
-
-The GeneratedVersion.java
file will now be located in src/generated
.
When using properties file (version.properties
) under Java 12+ and Gradle 5.4.1+, the directory containing the properties file must be specified using the semver.project.dir
processor argument.
For example, if the properties file is in the Gradle project directory, add the following to build.gradle:
+In order to also incorporate the generated source code into the source tree
, add the following to build.gradle:
tasks.withType(JavaCompile) {
- if (JavaVersion.current().isJava12Compatible()) {
- options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
- }
+ options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
}
+The GeneratedVersion.java
file will now be located in src/generated
.
The annotation processor also supports Kotlin.
To generate a Kotlin version file, simply specify the type
as follows:
import net.thauvin.erik.semver.Version
-
-@Version(properties = "version.properties", type="kt")
-open class Main {
-// ...
import net.thauvin.erik.semver.Version
+
+@Version(properties = "version.properties", type="kt")
+open class Main {
+// ...
The Kotlin default template implements the same static fields and functions as the Java template.
Please look at the examples/kotlin project for a build.gradle.kts sample.
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)
- implementation (semverProcessor)
-}
-
-kapt {
- arguments {
- arg("semver.project.dir", projectDir)
- }
-}
The arguments block is not required if kapt
is configured to use the Gradle Worker API in gradle.properties:
This option will likely be enabled by default in the future, but is currently not working under Java 10+ see KT-26203.
+var semverProcessor = "net.thauvin.erik:semver:1.2.0"
+
+dependencies {
+ kapt(semverProcessor)
+ implementation(semverProcessor)
+}
+
+kapt {
+ arguments {
+ arg("semver.project.dir", projectDir)
+ }
+}
The directory containing the configuration files (version.properties
, version.mustache
) must be specified using the semver.project.dir
processor argument.
To install and run from Kobalt, add the following to Build.kt:
dependencies {