Closed OlgaMaciaszek closed 2 years ago
A similar issue is caused when the projects use ByteBuddy for code transformation as that only considers the compile classpath. I've filed an issue for that to be able to tweak that.
Just for reference, ByteBuddy just released 1.11.19, which contains an option to work against the runtime classpath.
@aclement Could you please check if that's of interest for us?
Spring AOT already considers runtime
and not compile
classpath for the generation.
What happens here is com.netflix.eureka:eureka-client
using runtime
dependency for GSON, so as expected it is taken in account.
[INFO] | +- com.netflix.eureka:eureka-client:jar:1.10.17:compile
[INFO] | | +- com.netflix.netflix-commons:netflix-eventbus:jar:0.3.0:compile
[INFO] | | | +- com.netflix.netflix-commons:netflix-infix:jar:0.3.0:runtime
[INFO] | | | | +- commons-jxpath:commons-jxpath:jar:1.3:runtime
[INFO] | | | | +- joda-time:joda-time:jar:2.3:runtime
[INFO] | | | | +- org.antlr:antlr-runtime:jar:3.4:runtime
[INFO] | | | | | +- org.antlr:stringtemplate:jar:3.2.1:runtime
[INFO] | | | | | \- antlr:antlr:jar:2.7.7:runtime
[INFO] | | | | \- com.google.code.gson:gson:jar:2.8.9:runtime
The IDE automatically attaches the generated code and is using the compile classpath, hence the errors repported:
After discussing with @snicoll, I think what we would need here is to find a way that IDEs configure the generated code with runtime classpath, or compile + runtime classpath. That may require raising issues on IDE side, so for now I move it to the backlog.
After a discussion with @bclozel, let's change the name of the directory to avoid it to be recognized by IDEA automatically with the wrong classpath, and document how to configure it properly.
Sample that reproduces the issue:
discovery-client
. After packaging the sample with maven with AOT and running it with the IDE (used IntelliJ for my tests), the IDE was complaining that the aot-generated sources contained imports from missing dependencies, i.e. Google'sGson
; adding the dep to pom and refreshing IDE mvn setup fixes the issue, but it's a usability concern.