diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 94975b3a27..460fb6c4b8 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -90,6 +90,7 @@ public class IntegrationTestSuite
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+ suite.addTestSuite( MavenITmng4040ProfileInjectedModulesTest.class );
suite.addTestSuite( MavenITmng4036ParentResolutionFromSettingsRepoTest.class );
suite.addTestSuite( MavenITmng4034ManagedProfileDependencyTest.class );
suite.addTestSuite( MavenITmng4026ReactorDependenciesOrderTest.class );
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4040ProfileInjectedModulesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4040ProfileInjectedModulesTest.java
new file mode 100644
index 0000000000..6261276e5f
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4040ProfileInjectedModulesTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.it;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+
+/**
+ * This is a test set for MNG-4040.
+ *
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4040ProfileInjectedModulesTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng4040ProfileInjectedModulesTest()
+ {
+ super( ALL_MAVEN_VERSIONS );
+ }
+
+ /**
+ * Verify that modules inside profiles are not accidentally inherited by the children.
+ */
+ public void testit()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4040" );
+
+ Verifier verifier = new Verifier( new File( testDir, "sub" ).getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+ }
+
+}
diff --git a/its/core-it-suite/src/test/resources/mng-4040/pom.xml b/its/core-it-suite/src/test/resources/mng-4040/pom.xml
new file mode 100644
index 0000000000..6bff784a9d
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4040/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng4040
+ parent
+ 1.0-SNAPSHOT
+ pom
+
+ Maven Integration Test :: MNG-4040
+
+ Verify that modules inside profiles are not accidentally inherited by the children.
+
+
+
+
+ maven-core-it
+
+ true
+
+
+ sub
+
+
+
+
diff --git a/its/core-it-suite/src/test/resources/mng-4040/sub/pom.xml b/its/core-it-suite/src/test/resources/mng-4040/sub/pom.xml
new file mode 100644
index 0000000000..7c4c670af6
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4040/sub/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.its.mng4040
+ parent
+ 1.0-SNAPSHOT
+
+
+ org.apache.maven.its.mng4040
+ child
+ 1.0-SNAPSHOT
+
+ Maven Integration Test :: MNG-4040
+
+ Verify that modules inside profiles are not accidentally inherited by the children.
+
+