[Git][java-team/maven-debian-helper][master] 3 commits: Fixed the resolution of the dependencies declared with the test scope in a...
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Mon Nov 16 15:23:41 GMT 2026
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-debian-helper
Commits:
aa37f8c7 by Emmanuel Bourg at 2026-11-16T15:34:51+01:00
Fixed the resolution of the dependencies declared with the test scope in a module and the runtime scope in another one
- - - - -
4c69bbd2 by Emmanuel Bourg at 2026-11-16T15:47:03+01:00
Fixed mh_resolve_dependencies deleting the existing .poms file when run outside of a build
- - - - -
d376a21b by Emmanuel Bourg at 2026-11-16T16:15:48+01:00
Upload to unstable
- - - - -
11 changed files:
- bin/mh_resolve_dependencies
- debian/changelog
- maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
- maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
- maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
- + maven-packager-utils/src/test/resources/testscope-runtime-first.poms
- + maven-packager-utils/src/test/resources/testscope-tests-first.poms
- + maven-packager-utils/src/test/resources/testscope.substvars
- + maven-packager-utils/src/test/resources/testscope/pom.xml
- + maven-packager-utils/src/test/resources/testscope/runtime/pom.xml
- + maven-packager-utils/src/test/resources/testscope/tests/pom.xml
Changes:
=====================================
bin/mh_resolve_dependencies
=====================================
@@ -71,7 +71,7 @@ if [ ! -e .debianVersion -a ! -e debian/stamp-poms-patched ]; then
mh_lspoms $PACKAGE
fi
mh_patchpoms -p$PACKAGE --keep-pom-version
- if [ $CREATED_POMS ]; then
+ if [ "$CREATED_POMS" = true ]; then
rm debian/${PACKAGE}.poms
fi
fi
=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+maven-debian-helper (2.8.5) unstable; urgency=medium
+
+ * Fixed the resolution of the dependencies declared with the test scope in
+ a module and the runtime scope in another one
+ * Fixed mh_resolve_dependencies deleting the existing .poms file when run
+ outside of a build
+
+ -- Emmanuel Bourg <ebourg at apache.org> Mon, 16 Nov 2026 16:15:40 +0100
+
maven-debian-helper (2.8.4) unstable; urgency=medium
* Fixed the build failure with maven-plugin-tools 3.16
=====================================
maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
=====================================
@@ -621,6 +621,15 @@ public class DependenciesSolver {
return null;
}
+ // Ignore the test dependencies for the test scope only, another module may require the same artifact at runtime
+ if (ignoreDependencyQuestion.askIgnoreTestDependency(dependency, sourcePomLoc, runTests)) {
+ pomTransformer.getRulesFiles().get(IGNORE).add(new DependencyRule(dependency.getGroupId(), dependency.getArtifactId(), "*", "*", "*", "test"));
+ if (verbose) {
+ System.out.println("[ignored]");
+ }
+ return null;
+ }
+
POMInfo pom = getRepository().searchMatchingPOM(dependency);
try {
if (pom == null && dependency.getVersion() == null) {
=====================================
maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
=====================================
@@ -204,9 +204,6 @@ public class IgnoreDependencyQuestions {
return true;
if (!runTests) {
- if ("test".equals(dependency.getScope())
- && askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test dependency?"))
- return true;
if (containsPlugin(TEST_PLUGINS, dependency)
&& askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test plugin?"))
return true;
@@ -220,6 +217,11 @@ public class IgnoreDependencyQuestions {
return false;
}
+ public boolean askIgnoreTestDependency(Dependency dependency, String sourcePomLoc, boolean runTests) {
+ return !runTests && "test".equals(dependency.getScope())
+ && askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test dependency?");
+ }
+
public boolean askIgnoreDocOrReportPlugin(String sourcePomLoc, Dependency dependency) {
return containsPlugin(DOC_PLUGINS, dependency)
&& askIgnoreDependency(sourcePomLoc, dependency,
=====================================
maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
=====================================
@@ -320,6 +320,47 @@ public class DependenciesSolverTest extends TestCase {
assertFileEquals("versions.substvars", "versions.substvars");
}
+ /**
+ * Test of a dependency declared with the test scope in a module and required
+ * at runtime by another module processed after it.
+ */
+ public void testSolveTestScopeDependencyBeforeRuntimeDependency() throws Exception {
+ solveTestScopeDependencies("testscope-tests-first.poms");
+ }
+
+ /**
+ * Test of a dependency required at runtime by a module and declared with
+ * the test scope in another module processed after it.
+ */
+ public void testSolveRuntimeDependencyBeforeTestScopeDependency() throws Exception {
+ solveTestScopeDependencies("testscope-runtime-first.poms");
+ }
+
+ private void solveTestScopeDependencies(String poms) throws Exception {
+ useFile("testscope/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver(testDir, new PackageScanner(true), false);
+ solver.mavenRepo = getFileInClasspath("repository/root.dir").getParentFile();
+ solver.exploreProjects = false;
+ solver.packageName = "testscope";
+ File listOfPoms = getFileInClasspath(poms);
+ solver.setBaseDir(getFileInClasspath("testscope/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.issues.isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.saveSubstvars();
+
+ // log4j is required at runtime by one module, whatever the order of the modules
+ assertFileEquals("testscope.substvars", "testscope.substvars");
+
+ // the test dependency is ignored for the test scope only
+ assertTrue(solver.pomTransformer.getRulesFiles().get(IGNORE).getRules().contains(new DependencyRule("log4j log4j * * * test")));
+ assertFalse(solver.pomTransformer.getRulesFiles().get(IGNORE).getRules().contains(new DependencyRule("log4j log4j * *")));
+ }
+
public void testSolveBuildhelperPluginDependencies() throws Exception {
useFile("buildhelper-maven-plugin/pom.xml", pomFile);
DependenciesSolver solver = new DependenciesSolver(testDir, new PackageScanner(true), false);
=====================================
maven-packager-utils/src/test/resources/testscope-runtime-first.poms
=====================================
@@ -0,0 +1,3 @@
+pom.xml --no-parent
+runtime/pom.xml
+tests/pom.xml
=====================================
maven-packager-utils/src/test/resources/testscope-tests-first.poms
=====================================
@@ -0,0 +1,3 @@
+pom.xml --no-parent
+tests/pom.xml
+runtime/pom.xml
=====================================
maven-packager-utils/src/test/resources/testscope.substvars
=====================================
@@ -0,0 +1,7 @@
+#List of dependencies for testscope, generated for use by debian/control
+maven.CompileDepends=
+maven.Depends=liblog4j1.2-java (>= 1.2.16)
+maven.DocDepends=
+maven.DocOptionalDepends=
+maven.OptionalDepends=
+maven.TestDepends=
=====================================
maven-packager-utils/src/test/resources/testscope/pom.xml
=====================================
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.example</groupId>
+ <artifactId>testscope</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>tests</module>
+ <module>runtime</module>
+ </modules>
+</project>
=====================================
maven-packager-utils/src/test/resources/testscope/runtime/pom.xml
=====================================
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.example</groupId>
+ <artifactId>testscope</artifactId>
+ <version>1.0</version>
+ </parent>
+ <artifactId>testscope-runtime</artifactId>
+ <dependencies>
+ <!-- required at runtime by this module -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+ </dependencies>
+</project>
=====================================
maven-packager-utils/src/test/resources/testscope/tests/pom.xml
=====================================
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.example</groupId>
+ <artifactId>testscope</artifactId>
+ <version>1.0</version>
+ </parent>
+ <artifactId>testscope-tests</artifactId>
+ <dependencies>
+ <!-- only used by the tests of this module -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/-/compare/6617d5f93dcd3f78ef04617eed8d0fbe92eca177...d376a21b42c882c53545cc18cf015770dd9641f6
--
View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/-/compare/6617d5f93dcd3f78ef04617eed8d0fbe92eca177...d376a21b42c882c53545cc18cf015770dd9641f6
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261116/2f80a036/attachment.htm>
More information about the pkg-java-commits
mailing list