Skip to content

Maven: test dependencies sometimes missing when executing with "-T1C" #8755

Description

@theit

Precondition

  • I checked the issues list for existing open or closed reports of the same problem.

Describe the bug
We have a large multi-module project; several modules in the build have dependencies to others in the reactor. The dependency check plugin is contained in an extra profile called dependency-check so that reports can be enabled on demand and don't slow down a regular build. The goal used in the profile is aggregate (see below).

When executing a normal build via mvn -Pdependency-check clean verify, everything works well. When executing with an additional -T1C, the build fails when Maven compiles test code in a module used by others:

[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/FilterTest.java:[10,29] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/FilterTest.java:[12,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/FilterTest.java:[12,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/FilterTest.java:[13,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/FilterTest.java:[13,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[3,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[3,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[4,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[4,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[5,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[5,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[6,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[6,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[7,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[7,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/ReaderTest.java:[15,29] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[7,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[7,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[8,36] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[8,1] Statischer Import nur aus Klassen und Schnittstellen
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[18,29] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[28,21] Package net.jqwik.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[29,21] Package net.jqwik.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[30,21] Package net.jqwik.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[31,21] Package net.jqwik.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[32,21] Package net.jqwik.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[33,33] Package net.jqwik.api.constraints ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[34,31] Package net.jqwik.api.lifecycle ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[35,29] Package org.junit.jupiter.api ist nicht vorhanden
[ERROR] .../app/app-commons/src/test/java/com/example/commons/test/config/moduleProperties/PropsTest.java:[288,9] Symbol nicht gefunden

Test dependencies suddenly aren't available, and I honestly don't know why.

When being used in combination with the maven-turbo-builder extension, the build fails later in another downstream module that consumes the above one (that now compiles!), but also when compiling test code. The messages are more or less similar, i.e. packages from test dependencies are missing such as org.junit.jupiter.api, org.mockito, org.eclipse.jetty.* etc.

Everything compiles fine when I either use the check goal instead of aggregate or when I omit -T1C when using aggregate.

Version of dependency-check used
The problem occurs using version 13.0.0 of the Maven plugin

Log file
Error messages see above.

To Reproduce
The code is internal so I unfortunately cannot create a reproducer. I've added the below profile to another multi-module project that then shows the same behavior in some downstream module when compiling test code.

Expected behavior
Reports are generated without build failures when Maven compiles test classes.

Additional context
Excerpt from the pom.xml:

<profiles>
	<profile>
		<id>dependency-check</id>
		<build>
			<plugins>
				<plugin>
					<groupId>org.owasp</groupId>
					<artifactId>dependency-check-maven</artifactId>
					<configuration>
						<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
						<nodeAuditAnalyzerEnabled>false</nodeAuditAnalyzerEnabled>
						<nodeAnalyzerEnabled>false</nodeAnalyzerEnabled>
						<nvdApiKey>${env.NVD_API_KEY}</nvdApiKey>
						<ossIndexServerId>ossindex</ossIndexServerId>
					</configuration>
					<executions>
						<execution>
							<goals>
								<goal>aggregate</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>


<build>
	<pluginManagement>
		<plugins>
			<plugin>
				<groupId>org.owasp</groupId>
				<artifactId>dependency-check-maven</artifactId>
				<version>13.0.0</version>
			</plugin>
		</plugins>
	</pluginManagement>
</build>


<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.junit</groupId>
			<artifactId>junit-bom</artifactId>
			<version>6.1.3</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-bom</artifactId>
			<version>5.23.0</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
		<dependency>
			<groupId>org.xmlunit</groupId>
			<artifactId>xmlunit-core</artifactId>
			<version>2.13.0</version>
		</dependency>
		<dependency>
			<groupId>org.xmlunit</groupId>
			<artifactId>xmlunit-assertj</artifactId>
			<version>2.13.0</version>
		</dependency>
		<dependency>
			<groupId>net.jqwik</groupId>
			<artifactId>jqwik</artifactId>
			<version>1.10.1</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-bom</artifactId>
			<version>12.1.12</version>
			<scope>import</scope>
			<type>pom</type>
		</dependency>
	</dependencies>
</dependencyManagement>

Tested with

  • Maven 3.9.16, 3.10.0-rc1 and 4.0.0-rc6.
  • Eclipse Temurin 25.0.4 and 26.0.1
  • Windows 11 24H2

Fun fact:
I added the above profile to another multi-module project. Executions with Maven 3.x failed; 4.0.0-rc6 seems to work, even Maven mvnd 1.0.6 works (although the very first invocation failed, but no one after killing the daemon via mvnd --stop)...
It seems to me that there's some race condition hidden somewhere but I can't figure out where (and why).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions