Quarkus master / dev mode / --enable-preview - compilation fails after .java file edit
https://github.com/quarkusio/quarkus/pull/8279 should make dev mode ready to work with --enable-preview flag, but I'm struggling with it. Tried on Java 14 and Java 15ea and Quarkus master 079cf3925c
I can run dev mode, simple rest endpoint provides the content, it blows up when the simple jaxrs resource is edited, compilation fails, java.lang.RuntimeException: Compilation failed[error: --enable-preview must be used with either -source or --release] is returned by the endpoint.
Reproducer:
git clone https://github.com/rsvoboda/quarkus-jdk15.git
cd quarkus-jdk15
sdk use java 15.ea.21-open
mvn quarkus:dev
curl http://localhost:8080/hello ## hello
edit ./src/main/java/io/quarkus/qe/jdk/Jdk15Resource.java
curl http://localhost:8080/hello ## java.lang.RuntimeException: Compilation failed[error: --enable-preview must be used with either -source or --release]
@rsvoboda what does pom.xml looks like? Is it the pom.xml generated by our tooling?
https://github.com/rsvoboda/quarkus-jdk15/blob/master/pom.xml
see reproducer steps in description ;)
I _think_ we don't handle maven.compiler.release at all.
It's generated by Quarkus maven tooling ++ adjustments for maven.compiler.release and --enable-preview
I think I tried release tag too, with the same result.
Could you give source and target a try as well? I am pretty sure those are handled properly
I can confirm the same behavior for <release> tag.
Tried <source> and <target> tags too with the same failure.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<source>15</source>
<target>15</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
OK, thanks for checking.
I'll take a look at this and get it fixed before 1.5.CR1 goes out.
Hello @rsvoboda, A temporary workaround (actually this is more than a workaround and in fact a better way) is to set the following properties in your pom.xml (which is what I did in your reproducer project) to get it working:
diff --git a/pom.xml b/pom.xml
index cecfb4f..6fbe8f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,8 @@
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
-
+ <maven.compiler.source>15</maven.compiler.source>
+ <maven.compiler.target>15</maven.compiler.target>
I see that in your attempts to get this working you set the <source> and <target> to the Maven compiler plugin configuration (and not the Quarkus Maven plugin), hoping that it will work similar to what you did with the <compilerArgs> for the --enable-preview option. Looking at the code, the DevMojo can be enhanced to support this. So I went ahead and created a PR https://github.com/quarkusio/quarkus/pull/9245 to add this ability so that if any <source> and <target> are configured for the Maven compiler plugin, then they will get used (as a last resort) by the DevMojo. With that change in the PR, I was able to update your reproducer to just use:
diff --git a/pom.xml b/pom.xml
index cecfb4f..25a5cee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,8 @@
<version>${compiler-plugin.version}</version>
<configuration>
<compilerArgs>--enable-preview</compilerArgs>
+ <source>15</source>
+ <target>15</target>
</configuration>
</plugin>
and have it working.