diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 01195f9..be2df0e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,6 +17,6 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
- java-version: 13
+ java-version: 14
- name: Build with Gradle
run: ./gradlew build
diff --git a/.gitignore b/.gitignore
index c8427e1..fd0c699 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,9 +3,13 @@
.gradle
build/
+target/
.idea/
out/
+*.iml
+*.ipr
+*.iws
.project
diff --git a/README.md b/README.md
index 8b39e95..99ab2c5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Jabel - use Javac 12+ syntax when targeting Java 8
+# Jabel - use modern Java 9-14 syntax when targeting Java 8
> Because life is too short to wait for your users to upgrade their Java!
@@ -13,7 +13,7 @@ But, since most of features after Java 8 did not require a change in the bytecod
## How Jabel works
-Although Jabel is an annotation processor, it does not run any processing,
+Although Jabel is a javac compiler plugin, it does not run any processing,
but instruments the java compiler classes and makes it treat some new Java 9+ languages features
as they were supported in Java 8.
@@ -32,7 +32,7 @@ require the same target as the JVM because they get released altogether.
As was previously described, Jabel makes the compiler think that certain features were developed
for Java 8, and removes the checks that otherwise will report them as invalid for the target.
-It is important to understand that it will use the same code as for Java 12 and won't change
+It is important to understand that it will use the same desugaring code as for Java 9+ but won't change
the result's classfile version, because the compilation phase will be done with Java 8 target.
## How to use
@@ -66,7 +66,7 @@ Jabel has to be added as an annotation processor to your maven-compiler-plugin:
org.apache.maven.pluginsmaven-compiler-plugin
- 13
+ 14--enable-preview
@@ -77,29 +77,33 @@ Jabel has to be added as an annotation processor to your maven-compiler-plugin:
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
-
- 8
-
-
- com.github.bsideup.jabel
- jabel-javac-plugin
- 0.2.0
-
-
-
- com.github.bsideup.jabel.JabelJavacProcessor
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+
+ 8
+ 14
+ 14
+
+ -Xplugin:jabel
+
+
+
+
+
+
+
+
+ com.github.bsideup.jabel
+ jabel-javac-plugin
+ 0.3.0
+ provided
+
+
```
Compile your project and verify that Jabel is installed and successfully reports:
@@ -129,19 +133,26 @@ repositories {
Then, add Jabel as any other annotation processor:
```groovy
dependencies {
- annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:0.2.0'
+ annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:0.3.0'
}
```
Now, even if you set source/target/release to 8, the compiler will let you use some new language features.
The full list of features will be printed during the compilation.
```groovy
-sourceCompatibility = 12 // for the IDE support
+sourceCompatibility = 14 // for the IDE support
-compileJava {
+tasks.withType(JavaCompile).all {
options.compilerArgs = [
- "--release", "8" // Avoid using Java 12 APIs
+ "--release", "8", // Avoid using Java 9+ APIs
+ '--enable-preview',
]
+
+ doFirst {
+ options.compilerArgs = options.compilerArgs.findAll {
+ it != '--enable-preview'
+ }
+ }
}
```
diff --git a/example/build.gradle b/example/build.gradle
index 852b738..b42698e 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -2,19 +2,20 @@ plugins {
id "java"
}
-sourceCompatibility = 13
+sourceCompatibility = 14
targetCompatibility = 8
-compileJava {
+tasks.withType(JavaCompile).all {
options.compilerArgs = [
"--release", "8",
+ '--enable-preview',
]
-}
-compileTestJava {
- options.compilerArgs = [
- "--release", "8",
- ]
+ doFirst {
+ options.compilerArgs = options.compilerArgs.findAll {
+ it != '--enable-preview'
+ }
+ }
}
test {
diff --git a/example/src/main/java/com/example/JabelExample.java b/example/src/main/java/com/example/JabelExample.java
index 1b7862a..3c648a0 100644
--- a/example/src/main/java/com/example/JabelExample.java
+++ b/example/src/main/java/com/example/JabelExample.java
@@ -15,7 +15,10 @@ public String run(String[] args) {
// https://openjdk.java.net/jeps/325
var result = switch (args.length) {
case 1 -> {
- yield "one";
+ yield """
+ one...
+ yet pretty long!
+ """;
}
case 2, 3 -> "two or three";
default -> new JabelExample().new Inner().innerPublic();
@@ -33,8 +36,14 @@ private String outerPrivate(List... args) {
@Override
public String call() {
// Var in lambda parameter
- Function function = (var prefix) -> {
- return prefix + Integer.toString(0);
+ Function