diff --git a/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/parent/pom.xml b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/parent/pom.xml
new file mode 100644
index 000000000000..700c84c947d1
--- /dev/null
+++ b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/parent/pom.xml
@@ -0,0 +1,19 @@
+
+ 4.0.0
+ org.codehaus.mojo.flatten.its
+ profile-with-dependencies-inherit-parent-dependencyManagement_parent
+ 0.0.1-SNAPSHOT
+ pom
+
+
+
+
+
+ org.codehaus.mojo.flatten.its
+ dep
+ 1.1
+
+
+
+
+
diff --git a/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/pom.xml b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/pom.xml
new file mode 100644
index 000000000000..349dfd65edfb
--- /dev/null
+++ b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/pom.xml
@@ -0,0 +1,41 @@
+
+ 4.0.0
+ org.codehaus.mojo.flatten.its
+ profile-with-dependencies-inherit-parent-dependencyManagement
+ 0.0.1-SNAPSHOT
+
+
+ org.codehaus.mojo.flatten.its
+ profile-with-dependencies-inherit-parent-dependencyManagement_parent
+ 0.0.1-SNAPSHOT
+ parent
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+
+ true
+
+
+
+
+
+
+
+ myprofile
+
+ true
+
+
+
+ org.codehaus.mojo.flatten.its
+ dep
+
+
+
+
+
+
diff --git a/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/verify.groovy b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/verify.groovy
new file mode 100644
index 000000000000..5fd62dca9071
--- /dev/null
+++ b/src/it/projects/profile-with-dependencies-inherit-parent-dependencyManagement/verify.groovy
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+File originalPom = new File( basedir, 'pom.xml' )
+assert originalPom.exists()
+
+def originalProject = new XmlSlurper().parse( originalPom )
+assert 0 == originalProject.dependencies.size()
+assert 'myprofile' == originalProject.profiles.profile.id.text()
+assert 1 == originalProject.profiles.profile.dependencies.size()
+
+File flattendPom = new File( basedir, '.flattened-pom.xml' )
+assert flattendPom.exists()
+
+def flattendProject = new XmlSlurper().parse( flattendPom )
+assert 1 == flattendProject.dependencies.size()
+assert 'dep' == flattendProject.dependencies.dependency.artifactId.text()
+assert '1.1' == flattendProject.dependencies.dependency.version.text()
+assert 0 == flattendProject.profiles.profile.size()
diff --git a/src/main/java/org/codehaus/mojo/flatten/Dependencies.java b/src/main/java/org/codehaus/mojo/flatten/Dependencies.java
index 0d89c1874691..2377816a2a79 100644
--- a/src/main/java/org/codehaus/mojo/flatten/Dependencies.java
+++ b/src/main/java/org/codehaus/mojo/flatten/Dependencies.java
@@ -100,6 +100,17 @@ public boolean contains( Dependency dependency )
return this.key2DependencyMap.containsKey( getKey( dependency ) );
}
+ /**
+ *
+ * @param dependency the {@link Dependency} to resolve.
+ * @return a full declared {@link Dependency}
+ */
+ public Dependency resolve( Dependency dependency )
+ {
+ return this.key2DependencyMap.get( getKey( dependency ) );
+ }
+
+
/**
* @return a {@link List} with the {@link Dependency} objects contained in these {@link Dependencies}.
*/
diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
index b9cd7227b7e8..f98a92404018 100644
--- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
+++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
@@ -991,7 +991,7 @@ protected List createFlattenedDependencies( Model effectiveModel )
// Non build-time driven profiles will remain in the flattened POM with their dependencies
// and
// allow dynamic dependencies due to OS or JDK.
- flattenedDependencies.add( profileDependency );
+ flattenedDependencies.add( modelDependencies.resolve(profileDependency) );
}
}
}