Due to the RESTEasy version of @*Param which requires no value and uses the reflection parameter name, we'd ideally like the compiler to default to -parameters but we can't, so we tell users to set <maven.compiler.parameters>true</...> in their pom.xml.
This setting is ignored by the dev mojo. Similarly the longer configuration is also ignored:
<configuration>
<parameters>true</parameters>
</configuration>
I'd rather we just always add the -parameters flag to javac, but it would behave differently in dev mode than when generating jar/native, so I think we should respect the user's config. I can make a PR for this.
@FroMage I am pretty sure it already does, see: https://github.com/quarkusio/quarkus/blob/master/core/devmode/src/main/java/io/quarkus/dev/JavaCompilationProvider.java#L31
Did you see something to make you think otherwise?
Huh, well it doesn't work I just tried it and nothing could make it work except if I used <compilerArgs><args>-parameters which is the only setting it reads. Also this would make dev mode use parameters even if the pom.xml is badly configured not to, and would lead to differences between dev and jar/native.
I do see it, but in practice it doesn't work.
The idea is that you can change things in devmode configuration, but I expect not many people would be doing that.
I'll take a look and see if I can spot the problem in a quickstart or something.
@geoand the JavaCompilationProvider will only concern the modified classes AFAIK.
I know @evanchooly made some changes to the dev mojo so that it calls the compile one before. Maybe it's where the problem is?
import java.util.Set;
import java.util.concurrent.CompletionStage;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
@Path("/v2")
@RegisterRestClient
public interface CountriesService {
@GET
@Path("/name/{name}")
@Produces("application/json")
CompletionStage<Set<Country>> getByName(@PathParam String name);
}
This is enough to see this in the logs:
2019-10-17 11:25:33,723 WARN [io.qua.resteasy] (build-7) Detected RESTEasy annotation org.jboss.resteasy.annotations.jaxrs.PathParam on method parameter org.acme.CountriesService.getByName with no name. Either specify its name, or tell your compiler to enable debug info (-g) or parameter names (-parameters). This message is only logged for the first such parameter.
The idea is that you can change things in devmode configuration
Well, if dev mode adds parameters (good) but the users's pom does not (bad) then dev mode will give the user a false sense of his application working.
Well, if dev mode adds parameters (good) but the users's pom does not
(bad) then dev mode will give the user a false sense of his application
working.
FWIW, I pushed something in 0.25.0 to enable -parameters in the Maven
templates.
So it will get much more common that people have it properly enabled.
On Thu, Oct 17, 2019 at 11:32 AM Stéphane Épardaud notifications@github.com
wrote:
The idea is that you can change things in devmode configuration
Well, if dev mode adds parameters (good) but the users's pom does not
(bad) then dev mode will give the user a false sense of his application
working.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/4632?email_source=notifications&email_token=AAJYOBJMSCFWBP6IBVQ2FJLQPAWJZA5CNFSM4JBWRD42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPOT2Y#issuecomment-543091179,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAJYOBP5H5S67Z5UHYKQGKDQPAWJZANCNFSM4JBWRD4Q
.
Definitely yes. I am looking at the problem now.
Very nice, except I have <maven.compiler.parameters>true</maven.compiler.parameters> and it's not being used by dev mode :(
@FroMage I can't reproduce the problem... I tried generating a project with 0.25 and added
@GET
@Path("/nm/{nm}")
@Produces("application/json")
public CompletionStage<String> cs(@PathParam String nm) {
return CompletableFuture.completedFuture("Hello " + nm + "!");
}
and everything worked as expected.
I also verified in the debugger that the -parameters flag was being passed to the java compiler.
This is my pom.xml with the issue:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>code-with-quarkus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>0.25.0</quarkus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
<version>4.2.0.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
-->
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I run it with mvn clean quarkus:dev
@FroMage If you add
<compiler-plugin.version>3.8.1</compiler-plugin.version>
as a maven property and then also configure the compiler plugin like so:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
then everything will work as expected.
Note that this configuration is done automatically when you create a new project.
WTF. It's using the 3.1 compiler!!! https://maven.apache.org/plugins-archives/maven-compiler-plugin-3.1/compile-mojo.html says it doesn't even support -parameters option.
How do I end up with such an ancient compiler??
Ah, yes, so to be clear maven.compiler.parameters is only supported by
recent versions.
And IIRC, if you don't define the Maven Compiler Plugin version, you end up
with 3.1 instead of 3.8.1.
That's why I fixed the template and defined the version there.
On Thu, Oct 17, 2019 at 12:05 PM Georgios Andrianakis <
[email protected]> wrote:
@FroMage https://github.com/FroMage If you add
3.8.1 as a maven property and then also configure the plugin like so:
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${compiler-plugin.version}</version> </plugin>then everything will work as expected.
Note that this configuration is done automatically when you create a new
project.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/4632?email_source=notifications&email_token=AAJYOBPT3M3RWRFODVXRQ23QPA2INA5CNFSM4JBWRD42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPRW2I#issuecomment-543103849,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAJYOBN2MJQZCQBAV7KDDQDQPA2INANCNFSM4JBWRD4Q
.
@FroMage should we close this then?
Yeah, sorry about this, but thanks for figuring it out. I can't believe this. -parameters is Java 8, so 2014. My Maven is 3.6 from end of 2018. Why would it default to such an ancient compiler?!?!
That's a very good question :)
The funny think is that Maven 3.6 called without a POM will resolve the compiler plugin to 3.8.1.
But if you have a POM (or at least a Quarkus one), you end up with 3.1 for whatever reasons. Maven plugin resolution is pretty obscure.
The nice thing is that it should be fixed for all the new projects created with 0.25.0+.
BTW, @geoand do you know if Gradle automatically enables it?
@gsmet It does not, but we in out gradle templates we enable it with
compileJava {
options.compilerArgs << '-parameters'
}
OK cool \o/.
I am using Gradle with Kotlin (and was trying to follow the rest client guide), and I was able to resolve the warning by using passing the -java-parameters Kotlin compiler option:
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-java-parameters")
}
Also, make sure you are using org.jboss.resteasy.annotations.jaxrs.PathParam and not javax.ws.rs.PathParam.
For the record - Jandex is able to obtain the param names info from the debug info as well (-g) and since maven.compiler.debug is true by default, I think it's safe (at least for maven projects) to expect this info to be present if only accessed at build time via Jandex API. That's not the case for JAX-RS but other extensions can benefit from this info. Of course, a meaningful error message/warning should be used as a fallback.