Removed Java 12 syntax.

This commit is contained in:
Erik C. Thauvin 2019-07-28 21:37:40 -07:00
parent 14a72542ff
commit 1580bfca98
3 changed files with 10 additions and 20 deletions

View file

@ -17,7 +17,6 @@ This processor was inspired by Cédric Beust's [version-processor](https://githu
- [Gradle](#gradle)
- [Class Generation](#class-generation)
- [Class & Source Generation](#class--source-generation)
- [Java 12](#java-12)
- [Kotlin](#kotlin)
- [Kotlin & Gradle](#kotlin--gradle)
- [Kobalt](#kobalt)
@ -206,8 +205,14 @@ dependencies {
annotationProcessor 'net.thauvin.erik:semver:1.2.0'
implementation 'net.thauvin.erik:semver:1.2.0'
}
tasks.withType(JavaCompile) {
options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
```
The directory containing the configuration files (`version.properties`, `version.mustache`) must be specified using the `semver.project.dir` processor argument.
The [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java) class will be automatically created in the `build/generated` directory upon compiling.
Please look at [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle) in the [examples/java](https://github.com/ethauvin/semver/tree/master/examples/java) directory for a sample.
@ -224,20 +229,6 @@ tasks.withType(JavaCompile) {
The [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java) file will now be located in `src/generated`.
### Java 12
Under Java 12+ (Gradle 5.4.1+), the directory containing the configuration files (`version.properties`, `version.mustache`) must be specified using the `semver.project.dir` processor argument.
For example, if the configuration files are in the Gradle project directory, add the following to [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle):
```gradle
tasks.withType(JavaCompile) {
if (JavaVersion.current().isJava12Compatible()) {
options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
}
```
## Kotlin
The annotation processor also supports [Kotlin](https://kotlinlang.org/).

View file

@ -28,10 +28,8 @@ dependencies {
tasks.withType(JavaCompile) {
options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
if (JavaVersion.current().isJava12Compatible()) {
options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
}
task runExample(type: JavaExec) {
group = 'application'

View file

@ -14,7 +14,7 @@ final def semverProcessor = 'net.thauvin.erik:semver:1.2.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
compileJava.
mainClassName = 'com.example.Example'
@ -29,5 +29,6 @@ dependencies {
}
tasks.withType(JavaCompile) {
options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
options.compilerArgs += [ "-Asemver.project.dir=${projectDir}/example" ]
}