Describe the bug
The build goal of the quarkus-maven-plugin builds an incomplete application in case "Maven CI Friendly Versions" are used.
E.g.:
Parent pom.xml:
<groupId>some.project</groupId>
<artifactId>root</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<!-- This is only the default for local development, CI will override it! -->
<revision>0.1-SNAPSHOT</revision>
</properties>
Submodule pom.xml (the one with the quarkus-maven-plugin execution):
<parent>
<groupId>some.project</groupId>
<artifactId>root</artifactId>
<version>${revision}</version>
</parent>
<artifactId>dist</artifactId>
As described on "Maven CI Friendly Versions" (paragraph "Install / Deploy"), flatten-maven-plugin is configured properly.
Expected behavior
The application is built normally/fully. There should be no difference to e.g. <version>0.1-SNAPSHOT</version>.
Actual behavior
The runner jar is missing most (all?) of the application classes and the following is logged:
[INFO] --- quarkus-maven-plugin:1.3.0.CR2:build (default) @ dist ---
[WARNING] The POM for some.project:dist:jar:${revision} is missing, no dependency information available
[WARNING] The POM for some.project:dist:jar:${revision} is missing, no dependency information available
[INFO] [org.jboss.threads] JBoss Threads version 3.0.1.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building thin jar: C:\Develop\some-project\dist\target\dist-0.1-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 1106ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
To Reproduce
Steps to reproduce the behavior:
${revision}flatten-maven-pluginmvn clean install on root level)I am pretty swamped at the moment so I cannot provide a sample project right away.
But please do let me know if you need one.
_Update:_ Reproducer created, see https://github.com/quarkusio/quarkus/issues/7747#issuecomment-597336269
Configuration
none
Screenshots
none
Environment:
uname -a or ver: MINGW64_NT-10.0-18363 W4DEUMSY9003463 3.0.7-338.x86_64 2019-11-21 23:07 UTC x86_64 Msysjava -version: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)mvnw --version or gradlew --version): Apache Maven 3.6.3Additional context
I think I already found the source of the problem:
io.quarkus.bootstrap.resolver.maven.workspace.LocalProject is re-reading the pom.xml via ModelUtils / MavenXpp3Reader. This simple XML parsing does _not_ take care of the property interpolation that is required for the resolution of ${revision}.
_One_ solution might be to prefer a possibly existing .flattened-pom.xml to the regular pom.xml.
I did something similar here: https://github.com/shrinkwrap/resolver/pull/142
Since the name and location of the flattened file is configurable, Quarkus should probably provide a config option to reflect that.
๐ I like the "Maven CI Friendly Versions" - You don't have to change the version of parent pom in all your pom.xml if you create a bug release!
So, it would be great, if the quarkus-maven-plugin could support this feature.
I could live with the .flatten-pom.xml workaround
I found some time to create a reproducer, with slightly different Maven coordinates than in the original description but I think you'll manage. ๐
quarkus-7747-mvn-ci-friendlyAfter mvn clean install:
$ ll dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
-rw-r--r-- 1 Falko 197121 83891 Mrz 10 22:45 dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
$ java -jar dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
Exception in thread "main" java.lang.NoClassDefFoundError: io/quarkus/runtime/Application
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:27)
Caused by: java.lang.ClassNotFoundException: io.quarkus.runtime.Application
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 10 more
Now check out master and run mvn clean install:
$ ll dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
-rw-r--r-- 1 Falko 197121 203710 Mrz 10 22:47 dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
$ java -jar dist/target/modmono-quarkus-dist-1.0-SNAPSHOT-runner.jar
โโโโโโโ โโโ โโโ โโโโโโ โโโโโโโ โโโ โโโโโโ โโโโโโโโโโโ โโโ
โโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโโโโโ โโโโ
โโโโโโ โโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ โโโโ
โโโโโโ โโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ โโโโ
โโโโโโ โโโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโ
โโโโโโโ โโโโโโโ โโโ โโโโโโ โโโโโโ โโโ โโโโโโโ โโโโโโโโ โโโ
2020-03-10 22:47:52,289 INFO [io.quarkus] (main) modmono-quarkus-dist 1.0-SNAPSHOT (powered by Quarkus 1.3.0.CR2) started in 1.494s. Listening on: http://127.0.0.1:8080
2020-03-10 22:47:52,320 INFO [io.quarkus] (main) Profile prod activated.
2020-03-10 22:47:52,320 INFO [io.quarkus] (main) Installed features: [cdi, resteasy]
@aloubyansky & @gastaldi you seem to be the Maven experts here, WDYT?
Thanks for reporting the issue. LocalProject shouldn't be used for building the app though. It's used during the tests and dev mode.
LocalProject shouldn't be used for building the app though. It's used during the tests and dev mode.
I'll re-check that.
But does this also mean that once we get past the build problem, we might run into problems in tests and dev mode?
I can't answer that, atm. I haven't actually looked into this issue yet.
Interesting, @famod, the dev mode does not work for your project even on master branch. I've fixed the build and the tests, btw.
Wow, that was quick. Thanks! Will check the dev mode ASAP.
the dev mode does not work for your project even on master branch
Well, it seems to work for me:
OK on master:
mvn clean installmvn quarkus:dev -f dist/The same procedure _fails_ on quarkus-7747-mvn-ci-friendly with:
[...]
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.github.famod.modmono_quarkus.core.HelloBean and qualifiers [@Default]
- java member: com.github.famod.modmono_quarkus.dist.HelloResource#bean
- declared on CLASS bean [types=[com.github.famod.modmono_quarkus.dist.HelloResource, java.lang.Object], qualifiers=[@Default, @Any], target=com.github.famod.modmono_quarkus.dist.HelloResource]
- available beans:
- CLASS bean [types=[com.github.famod.modmono_quarkus.core.HelloBean, java.lang.Object], qualifiers=[@Default, @Any], target=com.github.famod.modmono_quarkus.core.HelloBean]
- CLASS bean [types=[com.github.famod.modmono_quarkus.core.HelloBean, java.lang.Object], qualifiers=[@Default, @Any], target=com.github.famod.modmono_quarkus.core.HelloBean]
at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:487)
at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:420)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:224)
... 14 more
Am I missing something?
I did not touch the Quarkus version (1.3.0.CR2).
Yes, try mvn clean compile quarkus:dev. It does not fail in your scenario because the jandex has been generated when you did install.
To fix your dev mode you should apply this change:
diff --git a/core/pom.xml b/core/pom.xml
index be7bd6c..3b60ae0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -28,6 +28,7 @@
<execution>
<?m2e ignore?>
<id>make-index</id>
+ <phase>compile</phase>
<goals>
<goal>jandex</goal>
</goals>
This will generate the jandex index in compile phase which is what quarkus:dev needs.
Ok, the addition of the phase fixes mvn clean compile quarkus:dev when called from the root.
So I suppose there is no regression.
Right. Thanks!
Fix confirmed in 1.3.0.Final. Thanks again to everyone involved!