mavenquarkusquarkus-extension

Quarkus extensions failure in multi-module build


We're migrating our extensions to a mono repository. Now we experience a weird behaviour with random failures locally and kind of deterministic fails on our CI.

Maven Project structure

pom.xml
- library-a-parent  
-- library-a-runtime 
-- library-a-deployment 
- library-b-parent   
-- library-b-runtime 
-- library-b-deployment 
- library-c

Library b depends on library a. Library c depends on library b.

When we build without library c, it works fine. When we change the module order in the pom it works fine.

Works:

<module>library-a-parent</module>
<module>library-b-parent</module>
<module>library-c</module>

Does not work:

<module>library-c</module>
<module>library-a-parent</module>
<module>library-b-parent</module>

As we have more libraries to migrate this "solution" with trying out the order won't work. In the exception we see, that Quarkus tries to download a pom-file which can't exist, because it hasn't been built yet. If we would add this module as a dependency, it would by a cyclic dependency.

The exception happens during the test execution

java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for ch.anon.libs:lib-config-cache::jar:999-SNAPSHOTnull
    at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:638)
    at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:722)
    at java.base/java.util.Optional.orElseGet(Optional.java:364)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for ch.anon.libs:lib-config-cache::jar:999-SNAPSHOTnull
    at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:297)
    at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:133)
    at io.quarkus.test.junit.AbstractJvmQuarkusTestExtension.createAugmentor(AbstractJvmQuarkusTestExtension.java:189)
    at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:219)
    at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:605)
    at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:655)
    ... 1 more
Caused by: io.quarkus.bootstrap.resolver.AppModelResolverException: Failed to inject extension deployment dependencies for ch.anon.libs:lib-config-cache:999-SNAPSHOT
    at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.buildAppModel(BootstrapAppModelResolver.java:340)
    at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.doResolveModel(BootstrapAppModelResolver.java:288)
    at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveManagedModel(BootstrapAppModelResolver.java:168)
    at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:283)
    ... 6 more
Caused by: io.quarkus.bootstrap.BootstrapDependencyProcessingException: Failed to collect dependencies of ch.anon.libs:lib-mandant-cache-deployment:jar:999-SNAPSHOT: either its POM could not be resolved from the available Maven repositories or the artifact does not have any dependencies while at least a dependency on the runtime artifact ch.anon.libs:lib-mandant-cache:jar:999-SNAPSHOT is expected
    at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.injectDeploymentDependencies(ApplicationDependencyTreeResolver.java:587)
    at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.resolve(ApplicationDependencyTreeResolver.java:207)
    at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.buildAppModel(BootstrapAppModelResolver.java:337)

Solution

  • Right, Maven is unaware of Quarkus extension runtime -> deployment dependency. In this case library-c should add a test scoped dependency on the pom of the deployment artifact excluding all its dependencies just to let Maven know it has to be built before running the tests, such as

            <dependency>
                <groupId>ch.anon.libs</groupId>
                <artifactId>lib-mandant-cache-deployment</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>*</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>