Quarkus 扩展在多模块构建中失败

问题描述 投票:0回答:1

我们正在将扩展迁移到 Mono 存储库。现在,我们遇到了一种奇怪的行为,局部随机失败,而我们的 CI 则出现确定性失败。

Maven 项目结构

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

库 b 依赖于库 a。 库 c 依赖于库 b。

当我们在没有库 c 的情况下构建时,它工作得很好。当我们更改 pom 中的模块顺序时,它可以正常工作。

作品:

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

不起作用:

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

由于我们有更多的库来迁移这个“解决方案”,尝试顺序将不起作用。 在我们看到的异常中,Quarkus 尝试下载一个不存在的 pom 文件,因为它尚未构建。如果我们将此模块添加为依赖项,它将是循环依赖项。

测试执行过程中发生异常

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)
maven quarkus quarkus-extension
1个回答
0
投票

是的,Maven 不知道 Quarkus 扩展运行时 -> 部署依赖项。在这种情况下,library-c 应该在部署工件的 pom 上添加一个测试范围的依赖项,排除其所有依赖项,只是为了让 Maven 知道它必须在运行测试之前构建,例如

        <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>
© www.soinside.com 2019 - 2024. All rights reserved.