Description
Preface: Finding this issue was quite a journey because I first considered it to be a Maven core bug (apache/maven#310), but the problem is actually caused by this plugin.
When building in parallel, compilation in a submodule of my current closed source project (sorry, cannot share!) fails sporadically with errors like:
17:12:46 [ERROR] <someJavaFile>:[10,37] package org.jboss.resteasy.spi does not exist
17:12:46 [ERROR] <someJavaFile>:[10,1] static import only from classes and interfaces
17:12:46 [ERROR] <someJavaFile>:[11,37] package org.jboss.resteasy.spi does not exist
17:12:46 [ERROR] <someJavaFile>:[11,1] static import only from classes and interfaces
17:12:46 [ERROR] <someJavaFile>:[12,37] package org.jboss.resteasy.spi does not exist
17:12:46 [ERROR] <someJavaFile>:[12,1] static import only from classes and interfaces
17:12:46 [ERROR] <someJavaFile>:[14,24] package javax.ws.rs.core does not exist
The "missing" packages come from transitive dependencies of resteasy-core
which in turn is a transitive dependency of quarkus-resteasy
.
It turns out that when the errors strike, there is a Warning further up in the log that is very easy to miss:
[WARNING] The POM for org.jboss.resteasy:resteasy-core:jar:4.5.3.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
I modified the logging in maven-core
(as -X
would change the timing in a way I could not reproduce the problem anymore) so that I could see what was going on:
org.apache.maven.model.building.ModelBuildingException: 17 problems were encountered while building the effective model for org.jboss.resteasy:resteasy-core:4.5.3.Final
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.resteasy:resteasy-tracing-api:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.reactivestreams:reactive-streams:jar is missing. @
[ERROR] 'dependencies.dependency.version' for jakarta.validation:jakarta.validation-api:jar is missing. @
[ERROR] 'dependencies.dependency.version' for junit:junit:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.apache.logging.log4j:log4j-api:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.apache.logging.log4j:log4j-core:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:jar is missing. @
[ERROR] 'dependencies.dependency.version' for com.sun.activation:jakarta.activation:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.el:jboss-el-api_3.0_spec:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.logging:jboss-logging:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.logging:jboss-logging-annotations:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.jboss.logging:jboss-logging-processor:jar is missing. @
[ERROR] 'dependencies.dependency.version' for org.eclipse.microprofile.config:microprofile-config-api:jar is missing. @
[ERROR] 'dependencies.dependency.version' for io.smallrye.config:smallrye-config:jar is missing. @
at org.apache.maven.model.building.DefaultModelProblemCollector.newModelBuildingException (DefaultModelProblemCollector.java:197)
at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:509)
Luckily, this reminded me of the following problem I ran into with an earlier version of this plugin: #87 (comment)
And indeed, there is a special dependency-defining profile involved in the parent of resteasy-core
: https://repo1.maven.org/maven2/org/jboss/resteasy/resteasy-jaxrs-all/4.5.3.Final/resteasy-jaxrs-all-4.5.3.Final.pom
<profile>
<id>resteasy-default</id>
<activation>
<property>
<name>!resteasy.dependencies.eap</name>
</property>
</activation>
<modules>
<!-- ... -->
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
So my theory is, that the dreaded profile handling of this plugin in the combination with the not-so-immutable and thus not-so-thread-safe Maven internals sometimes yields a state, where this profile is not activated and so the versions are missing.
Due to the complexity and volatile nature of the problem, I cannot actually pinpoint the exact location of the root cause.
At the moment I am testing a fix/workaround for this locally and so far it has been looking good!
PS: So it turns out that my fears in context of #87 were unfortunately right.