diff --git a/src/it/mrm/repository/parent-transitive-deps-1.pom b/src/it/mrm/repository/parent-transitive-deps-1.pom new file mode 100644 index 00000000..0da3ee52 --- /dev/null +++ b/src/it/mrm/repository/parent-transitive-deps-1.pom @@ -0,0 +1,15 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + parent-transitive-dep + 1 + pom + + + + org.codehaus.mojo.flatten.its + core + 3.2.1 + + + diff --git a/src/it/projects/complete-multimodule-parent-pom-direct-dependencies/pom.xml b/src/it/projects/complete-multimodule-parent-pom-direct-dependencies/pom.xml index fbe03efd..8bc80557 100644 --- a/src/it/projects/complete-multimodule-parent-pom-direct-dependencies/pom.xml +++ b/src/it/projects/complete-multimodule-parent-pom-direct-dependencies/pom.xml @@ -14,6 +14,9 @@ org.codehaus.mojo flatten-maven-plugin + + direct + diff --git a/src/it/projects/inherit-parent-dependency/pom.xml b/src/it/projects/inherit-parent-dependency/pom.xml index 0396c371..e2a6dac9 100644 --- a/src/it/projects/inherit-parent-dependency/pom.xml +++ b/src/it/projects/inherit-parent-dependency/pom.xml @@ -4,21 +4,9 @@ org.codehaus.mojo.flatten.its - parent-deps + parent-transitive-dep 1 resolve-properties 0.0.1-SNAPSHOT - - verify - - - org.codehaus.mojo - flatten-maven-plugin - - all - - - - diff --git a/src/it/projects/parent-with-version-range/pom.xml b/src/it/projects/parent-with-version-range/pom.xml index 5125ba3d..4dd35939 100644 --- a/src/it/projects/parent-with-version-range/pom.xml +++ b/src/it/projects/parent-with-version-range/pom.xml @@ -1,25 +1,13 @@ - 4.0.0 + 4.0.0 - - org.codehaus.mojo.flatten.its - parent-deps - [0,2] - + + org.codehaus.mojo.flatten.its + parent-deps + [0,2] + parent-with-version-range 0.0.1-SNAPSHOT - - verify - - - org.codehaus.mojo - flatten-maven-plugin - - all - - - - diff --git a/src/main/java/org/codehaus/mojo/flatten/DirectDependenciesInheritanceAssembler.java b/src/main/java/org/codehaus/mojo/flatten/DirectDependenciesInheritanceAssembler.java index bcc878e4..5b6f7f8d 100644 --- a/src/main/java/org/codehaus/mojo/flatten/DirectDependenciesInheritanceAssembler.java +++ b/src/main/java/org/codehaus/mojo/flatten/DirectDependenciesInheritanceAssembler.java @@ -144,7 +144,7 @@ public void merge(Model target, Model source, boolean sourceDominant, Map @Override protected void mergeModelBase_Dependencies( ModelBase target, ModelBase source, boolean sourceDominant, Map context) { - if (flattenDependencyMode == null || flattenDependencyMode == FlattenDependencyMode.direct) { + if (flattenDependencyMode == FlattenDependencyMode.direct) { return; } super.mergeModelBase_Dependencies(target, source, sourceDominant, context); diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenDependencyMode.java b/src/main/java/org/codehaus/mojo/flatten/FlattenDependencyMode.java index ef5fd2f0..46d289a2 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenDependencyMode.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenDependencyMode.java @@ -27,13 +27,18 @@ */ public enum FlattenDependencyMode { /** - * Flatten only the direct dependency versions. This is the default mode and compatible with - * Flatten Plugin prior to 1.2.0. + * Flatten only the direct dependency versions, excluding inherited dependencies from a parent module. */ direct, /** - * Flatten both direct and transitive dependencies. This will examine the full dependency tree, and pull up + * Flatten dependencies, including inherited dependencies from a parent module. + * This is the default mode and compatible with Flatten Plugin prior to 1.2.0. + */ + inherited, + + /** + * Flatten both direct, inherited and transitive dependencies. This will examine the full dependency tree, and pull up * all transitive dependencies as a direct dependency, and setting their versions appropriately. * * This is recommended if you are releasing a library that uses dependency management to manage dependency diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java index 6cf7bfc9..74ba0e4e 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java @@ -339,8 +339,16 @@ public class FlattenMojo extends AbstractFlattenMojo { * * * direct - * Flatten only the direct dependency versions. - * This is the default mode and compatible with Flatten Plugin prior to 1.2.0. + *

Flatten only the direct dependency versions, excluding inherited dependencies from a parent module.

+ *

This was the default mode with Flatten Plugin in versions 1.4.0 up to 1.6.0. + * + * + * + * inherited + *

Flatten the dependency versions, including inherited dependencies from a parent module

+ *

This is the default mode and compatible with Flatten Plugin prior to 1.2.0, this mode was called direct between versions 1.2.0 and 1.3.0.

+ * + * * * all *

Flatten both direct and transitive dependencies. This will examine the full dependency tree, and pull up @@ -1217,7 +1225,9 @@ protected void createFlattenedDependencies(Model effectiveModel, List projectDependencies = currentProject.getOriginalModel().getDependencies(); List projectDependencies = effectiveModel.getDependencies(); - if (flattenDependencyMode == null | flattenDependencyMode == FlattenDependencyMode.direct) { + if (flattenDependencyMode == null + || flattenDependencyMode == FlattenDependencyMode.direct + || flattenDependencyMode == FlattenDependencyMode.inherited) { createFlattenedDependenciesDirect(projectDependencies, flattenedDependencies); } else if (flattenDependencyMode == FlattenDependencyMode.all) { try {