From 35c3107b4124a94b7085e66e173dbbcf6d1e3cd8 Mon Sep 17 00:00:00 2001 From: Hitesh Date: Fri, 10 Jul 2026 14:55:46 +0530 Subject: [PATCH 1/2] Integration test for MNG-8432 using mixins --- .../MavenITmng8432MixinsPropertiesTest.java | 79 +++++++++++++++++++ .../managed-dep/pom.xml | 10 +++ .../mixin-bom/pom.xml | 24 ++++++ .../project/pom.xml | 25 ++++++ 4 files changed, 138 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-8432-mixins-properties/managed-dep/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-8432-mixins-properties/mixin-bom/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java new file mode 100644 index 000000000000..7213d1684fcb --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.it; + +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * This is a test set for MNG-8432. + *

+ * Demonstrates that the {@code } feature (Maven 4.2.0+) is the proper solution + * for inheriting both dependency management and properties from a BOM-like project, + * instead of extending BOM import semantics. + *

+ */ +public class MavenITmng8432MixinsPropertiesTest extends AbstractMavenIntegrationTestCase { + + /** + * Verify that a project using a mixin inherits both properties and + * dependency management from the mixin POM. + * + * @throws Exception in case of failure + */ + @Test + public void testMixinProvidesDependencyManagementAndProperties() throws Exception { + Path testDir = extractResources("/mng-8432-mixins-properties"); + + // 1. Install the mixin-bom which provides properties and dependencyManagement + Verifier verifier = newVerifier(testDir.resolve("mixin-bom")); + verifier.setAutoclean(false); + verifier.deleteDirectory("target"); + verifier.deleteArtifacts("org.apache.maven.its.mng8432"); + verifier.addCliArgument("install"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + // 2. Build the consuming project and dump its effective POM + Path projectDir = testDir.resolve("project"); + verifier = newVerifier(projectDir); + verifier.setAutoclean(false); + verifier.deleteDirectory("target"); + verifier.addCliArgument("help:effective-pom"); + verifier.addCliArgument("-Doutput=target/effective-pom.xml"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + // 3. Verify the effective POM contains the mixin's property + verifier.verifyFilePresent("target/effective-pom.xml"); + String effectivePom = Files.readString(projectDir.resolve("target/effective-pom.xml")); + assertTrue( + effectivePom.contains("mixin-value"), + "Property from mixin BOM should be inherited by the consuming project"); + + // 4. Verify the effective POM contains the managed dependency from the mixin + assertTrue( + effectivePom.contains("managed-dep"), + "Dependency management from mixin BOM should be inherited by the consuming project"); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/managed-dep/pom.xml b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/managed-dep/pom.xml new file mode 100644 index 000000000000..73a30f03b737 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/managed-dep/pom.xml @@ -0,0 +1,10 @@ + + + 4.0.0 + org.apache.maven.its.mng8432 + managed-dep + 1.0 + jar + + Maven Integration Test :: MNG-8432 :: Managed Dep + diff --git a/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/mixin-bom/pom.xml b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/mixin-bom/pom.xml new file mode 100644 index 000000000000..ad4ed711d6e6 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/mixin-bom/pom.xml @@ -0,0 +1,24 @@ + + + 4.2.0 + org.apache.maven.its.mng8432 + mixin-bom + 1.0 + pom + + Maven Integration Test :: MNG-8432 :: Mixin BOM + + + mixin-value + + + + + + org.apache.maven.its.mng8432 + managed-dep + 1.0 + + + + diff --git a/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml new file mode 100644 index 000000000000..61153ec33898 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml @@ -0,0 +1,25 @@ + + + 4.2.0 + org.apache.maven.its.mng8432 + project + 1.0 + jar + + Maven Integration Test :: MNG-8432 :: Project + + + + org.apache.maven.its.mng8432 + managed-dep + + + + + + org.apache.maven.its.mng8432 + mixin-bom + 1.0 + + + From bf5ac5c44041c39f7cbf565f53944edc971be5dd Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 17 Jul 2026 09:41:36 +0000 Subject: [PATCH 2/2] Use maven-it-plugin-expression instead of effective POM string matching Replace help:effective-pom + Files.readString/String.contains with the conventional maven-it-plugin-expression approach using verifier.loadProperties(), which is more robust against whitespace/formatting changes. Co-Authored-By: Claude Opus 4.6 --- .../MavenITmng8432MixinsPropertiesTest.java | 30 +++++++++---------- .../project/pom.xml | 25 ++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java index 7213d1684fcb..27eaffd440eb 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8432MixinsPropertiesTest.java @@ -18,12 +18,12 @@ */ package org.apache.maven.it; -import java.nio.file.Files; import java.nio.file.Path; +import java.util.Properties; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This is a test set for MNG-8432. @@ -54,26 +54,24 @@ public void testMixinProvidesDependencyManagementAndProperties() throws Exceptio verifier.execute(); verifier.verifyErrorFreeLog(); - // 2. Build the consuming project and dump its effective POM - Path projectDir = testDir.resolve("project"); - verifier = newVerifier(projectDir); + // 2. Build the consuming project and evaluate model expressions + verifier = newVerifier(testDir.resolve("project")); verifier.setAutoclean(false); verifier.deleteDirectory("target"); - verifier.addCliArgument("help:effective-pom"); - verifier.addCliArgument("-Doutput=target/effective-pom.xml"); + verifier.addCliArgument("validate"); verifier.execute(); verifier.verifyErrorFreeLog(); - // 3. Verify the effective POM contains the mixin's property - verifier.verifyFilePresent("target/effective-pom.xml"); - String effectivePom = Files.readString(projectDir.resolve("target/effective-pom.xml")); - assertTrue( - effectivePom.contains("mixin-value"), + // 3. Verify the model contains the mixin's property and managed dependency + verifier.verifyFilePresent("target/model.properties"); + Properties props = verifier.loadProperties("target/model.properties"); + assertEquals( + "mixin-value", + props.getProperty("project.properties.mixin.property"), "Property from mixin BOM should be inherited by the consuming project"); - - // 4. Verify the effective POM contains the managed dependency from the mixin - assertTrue( - effectivePom.contains("managed-dep"), + assertEquals( + "org.apache.maven.its.mng8432:managed-dep:jar", + props.getProperty("project.dependencyManagement.dependencies.0.managementKey"), "Dependency management from mixin BOM should be inherited by the consuming project"); } } diff --git a/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml index 61153ec33898..ae4a59c4e1eb 100644 --- a/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml +++ b/its/core-it-suite/src/test/resources/mng-8432-mixins-properties/project/pom.xml @@ -15,6 +15,31 @@ + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + + + eval + + validate + + target/model.properties + + project/properties + project/dependencyManagement + + + + + + + + org.apache.maven.its.mng8432