diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0085TransitiveSystemScopeTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0085TransitiveSystemScopeTest.java index 6f7d0825b..33da96873 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0085TransitiveSystemScopeTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0085TransitiveSystemScopeTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.Collection; +import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.shared.verifier.Verifier; import org.apache.maven.shared.verifier.util.ResourceExtractor; import org.junit.jupiter.api.Test; @@ -35,6 +36,10 @@ public MavenIT0085TransitiveSystemScopeTest() { * when they are resolved transitively via another (non-system) * dependency. Inherited scope should not apply in the case of * system-scoped dependencies, no matter where they are. + *
+ * Since 3.10.0-rc-2, repository-resolved models restrict property + * interpolation by default, so the opt-out flag is required for the + * legacy behavior and the default behavior causes a build failure. * * @throws Exception in case of failure */ @@ -51,6 +56,44 @@ public void testit0085() throws Exception { verifier.addCliArgument("--settings"); verifier.addCliArgument("settings.xml"); verifier.addCliArgument("validate"); + + String mavenVersion = getMavenVersion() != null ? getMavenVersion().toString() : ""; + if (mavenVersion.equals("3.10.0-rc-1") || matchesVersionRange("(,3.10.0)")) { + // Before restricted interpolation: full interpolation works without opt-out + verifier.execute(); + verifier.verifyErrorFreeLog(); + } else { + // With restricted interpolation: build fails without opt-out + try { + verifier.execute(); + verifier.verifyErrorFreeLog(); + fail("Build should not succeed without -Dmaven.model.dependencyInterpolation.full=true"); + } catch (VerificationException e) { + verifier.verifyTextInLog("must specify an absolute path but is ${test.home}/system.jar"); + } + } + } + + /** + * Verify that system-scoped dependencies work correctly when the opt-out + * property {@code -Dmaven.model.dependencyInterpolation.full=true} is set. + * + * @throws Exception in case of failure + */ + @Test + public void testit0085WithFullInterpolation() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0085"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.setAutoclean(false); + verifier.deleteDirectory("target"); + verifier.deleteArtifacts("org.apache.maven.its.it0085"); + verifier.getSystemProperties().setProperty("test.home", testDir.getAbsolutePath()); + verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8"); + verifier.addCliArgument("--settings"); + verifier.addCliArgument("settings.xml"); + verifier.addCliArgument("validate"); + verifier.addCliArgument("-Dmaven.model.dependencyInterpolation.full=true"); verifier.execute(); verifier.verifyErrorFreeLog(); diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3586SystemScopePluginDependencyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3586SystemScopePluginDependencyTest.java index f20a99c0b..463f876f5 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3586SystemScopePluginDependencyTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3586SystemScopePluginDependencyTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.Properties; +import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.shared.verifier.Verifier; import org.apache.maven.shared.verifier.util.ResourceExtractor; import org.junit.jupiter.api.Test; @@ -40,6 +41,10 @@ public MavenITmng3586SystemScopePluginDependencyTest() { /** * Test that plugin dependencies with scope system are part of the plugin class realm. This test checks * dependencies that are declared in the plugin POM. + *
+ * Since 3.10.0-rc-2, repository-resolved models restrict property + * interpolation by default, so the opt-out flag is required for the + * legacy behavior and the default behavior causes a build failure. * * @throws Exception in case of failure */ @@ -56,6 +61,48 @@ public void testitFromPlugin() throws Exception { verifier.addCliArgument("--settings"); verifier.addCliArgument("settings.xml"); verifier.addCliArgument("validate"); + + String mavenVersion = getMavenVersion() != null ? getMavenVersion().toString() : ""; + if (mavenVersion.equals("3.10.0-rc-1") || matchesVersionRange("(,3.10.0)")) { + // Before restricted interpolation: full interpolation works without opt-out + verifier.execute(); + verifier.verifyErrorFreeLog(); + + Properties props = verifier.loadProperties("target/it.properties"); + assertEquals("PASSED", props.getProperty("test")); + } else { + // With restricted interpolation: build fails without opt-out + try { + verifier.execute(); + verifier.verifyErrorFreeLog(); + fail("Build should not succeed without -Dmaven.model.dependencyInterpolation.full=true"); + } catch (VerificationException e) { + verifier.verifyTextInLog("must specify an absolute path but is ${test.home}/tools.jar"); + } + } + } + + /** + * Test that plugin dependencies with scope system are part of the plugin class realm when the + * opt-out property {@code -Dmaven.model.dependencyInterpolation.full=true} is set. + * This test checks dependencies that are declared in the plugin POM. + * + * @throws Exception in case of failure + */ + @Test + public void testitFromPluginWithFullInterpolation() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3586/test-1"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.setAutoclean(false); + verifier.deleteDirectory("target"); + verifier.deleteArtifacts("org.apache.maven.its.mng3586"); + verifier.getSystemProperties().setProperty("test.home", testDir.getAbsolutePath()); + verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8"); + verifier.addCliArgument("--settings"); + verifier.addCliArgument("settings.xml"); + verifier.addCliArgument("validate"); + verifier.addCliArgument("-Dmaven.model.dependencyInterpolation.full=true"); verifier.execute(); verifier.verifyErrorFreeLog(); diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4379TransitiveSystemPathInterpolatedWithEnvVarTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4379TransitiveSystemPathInterpolatedWithEnvVarTest.java index 733eeb80b..2fc3ccc92 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4379TransitiveSystemPathInterpolatedWithEnvVarTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4379TransitiveSystemPathInterpolatedWithEnvVarTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.List; +import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.shared.verifier.Verifier; import org.apache.maven.shared.verifier.util.ResourceExtractor; import org.junit.jupiter.api.Test; @@ -39,6 +40,10 @@ public MavenITmng4379TransitiveSystemPathInterpolatedWithEnvVarTest() { /** * Test that the path of a system-scope dependency gets interpolated using environment variables during * transitive dependency resolution. + *
+ * Since 3.10.0-rc-2, repository-resolved models restrict property
+ * interpolation by default, so the opt-out flag is required for the
+ * legacy behavior and the default behavior causes a build failure.
*
* @throws Exception in case of failure
*/
@@ -55,6 +60,47 @@ public void testit() throws Exception {
verifier.addCliArgument("-s");
verifier.addCliArgument("settings.xml");
verifier.addCliArguments("validate");
+
+ String mavenVersion = getMavenVersion() != null ? getMavenVersion().toString() : "";
+ if (mavenVersion.equals("3.10.0-rc-1") || matchesVersionRange("(,3.10.0)")) {
+ // Before restricted interpolation: env var interpolation works without opt-out
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ List
+ * Since 3.10.0-rc-2, repository-resolved models restrict property
+ * interpolation by default, so the opt-out flag is required for the
+ * legacy behavior and the default behavior causes a build failure.
*
* @throws Exception in case of failure
*/
@@ -55,6 +60,52 @@ public void testit() throws Exception {
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
+
+ String mavenVersion = getMavenVersion() != null ? getMavenVersion().toString() : "";
+ if (mavenVersion.equals("3.10.0-rc-1") || matchesVersionRange("(,3.10.0)")) {
+ // Before restricted interpolation: full interpolation works without opt-out
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ Properties props = verifier.loadProperties("target/pom.properties");
+ assertEquals("1", props.getProperty("project.dependencyManagement.dependencies"));
+ assertEquals("dep-a", props.getProperty("project.dependencyManagement.dependencies.0.artifactId"));
+ assertEquals(
+ new File(testDir, "pom.xml").getAbsoluteFile(),
+ new File(props.getProperty("project.dependencyManagement.dependencies.0.systemPath")));
+ } else {
+ // With restricted interpolation: build fails without opt-out
+ try {
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+ fail("Build should not succeed without -Dmaven.model.dependencyInterpolation.full=true");
+ } catch (VerificationException e) {
+ verifier.verifyTextInLog("must specify an absolute path but is ${test.dir}/${test.file}");
+ }
+ }
+ }
+
+ /**
+ * Verify that imported POMs are processed using the same system/user properties as the importing POM
+ * when the opt-out property {@code -Dmaven.model.dependencyInterpolation.full=true} is set.
+ *
+ * @throws Exception in case of failure
+ */
+ @Test
+ public void testitWithFullInterpolation() throws Exception {
+ File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4590");
+
+ Verifier verifier = newVerifier(testDir.getAbsolutePath());
+ verifier.setAutoclean(false);
+ verifier.deleteDirectory("target");
+ verifier.deleteArtifacts("org.apache.maven.its.mng4590");
+ verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
+ verifier.setEnvironmentVariable("MAVEN_OPTS", "-Dtest.file=pom.xml");
+ verifier.addCliArgument("-Dtest.dir=" + testDir.getAbsolutePath());
+ verifier.addCliArgument("--settings");
+ verifier.addCliArgument("settings.xml");
+ verifier.addCliArgument("validate");
+ verifier.addCliArgument("-Dmaven.model.dependencyInterpolation.full=true");
verifier.execute();
verifier.verifyErrorFreeLog();