diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 0e3828ae1c..6e0dc6bcb5 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1520,6 +1520,39 @@ public class PomConstructionTest assertSame( null, pom.getValue( "prerequisites" ) ); } + public void testLicensesAreInheritedButNotAggregated() + throws Exception + { + PomTestWrapper pom = buildPom( "licenses-inheritance/child-2" ); + assertEquals( 1, ( (List) pom.getValue( "licenses" ) ).size() ); + assertEquals( "child-license", pom.getValue( "licenses[1]/name" ) ); + assertEquals( "http://child.url/license", pom.getValue( "licenses[1]/url" ) ); + } + + public void testDevelopersAreInheritedButNotAggregated() + throws Exception + { + PomTestWrapper pom = buildPom( "developers-inheritance/child-2" ); + assertEquals( 1, ( (List) pom.getValue( "developers" ) ).size() ); + assertEquals( "child-developer", pom.getValue( "developers[1]/name" ) ); + } + + public void testContributorsAreInheritedButNotAggregated() + throws Exception + { + PomTestWrapper pom = buildPom( "contributors-inheritance/child-2" ); + assertEquals( 1, ( (List) pom.getValue( "contributors" ) ).size() ); + assertEquals( "child-contributor", pom.getValue( "contributors[1]/name" ) ); + } + + public void testMailingListsAreInheritedButNotAggregated() + throws Exception + { + PomTestWrapper pom = buildPom( "mailing-lists-inheritance/child-2" ); + assertEquals( 1, ( (List) pom.getValue( "mailingLists" ) ).size() ); + assertEquals( "child-mailing-list", pom.getValue( "mailingLists[1]/name" ) ); + } + private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); diff --git a/maven-core/src/test/resources-project-builder/contributors-inheritance/child-2/pom.xml b/maven-core/src/test/resources-project-builder/contributors-inheritance/child-2/pom.xml new file mode 100644 index 0000000000..745289fdd5 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/contributors-inheritance/child-2/pom.xml @@ -0,0 +1,45 @@ + + + + + + 4.0.0 + + + + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + + + org.apache.maven.its.mng3843.child + child-2 + 0.2 + jar + + + + child-contributor + + + diff --git a/maven-core/src/test/resources-project-builder/contributors-inheritance/pom.xml b/maven-core/src/test/resources-project-builder/contributors-inheritance/pom.xml new file mode 100644 index 0000000000..1f65eb5fd0 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/contributors-inheritance/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + pom + + + + parent-contributor + + + diff --git a/maven-core/src/test/resources-project-builder/developers-inheritance/child-2/pom.xml b/maven-core/src/test/resources-project-builder/developers-inheritance/child-2/pom.xml new file mode 100644 index 0000000000..dad2375b73 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/developers-inheritance/child-2/pom.xml @@ -0,0 +1,45 @@ + + + + + + 4.0.0 + + + + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + + + org.apache.maven.its.mng3843.child + child-2 + 0.2 + jar + + + + child-developer + + + diff --git a/maven-core/src/test/resources-project-builder/developers-inheritance/pom.xml b/maven-core/src/test/resources-project-builder/developers-inheritance/pom.xml new file mode 100644 index 0000000000..6e7c44d113 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/developers-inheritance/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + pom + + + + parent-developer + + + diff --git a/maven-core/src/test/resources-project-builder/licenses-inheritance/child-2/pom.xml b/maven-core/src/test/resources-project-builder/licenses-inheritance/child-2/pom.xml new file mode 100644 index 0000000000..9fd30bf519 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/licenses-inheritance/child-2/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + + + + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + + + org.apache.maven.its.mng3843.child + child-2 + 0.2 + jar + + + + child-license + http://child.url/license + repo + + + diff --git a/maven-core/src/test/resources-project-builder/licenses-inheritance/pom.xml b/maven-core/src/test/resources-project-builder/licenses-inheritance/pom.xml new file mode 100644 index 0000000000..641bb37f0e --- /dev/null +++ b/maven-core/src/test/resources-project-builder/licenses-inheritance/pom.xml @@ -0,0 +1,37 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + pom + + + + parent-license + http://parent.url/license + repo + + + diff --git a/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/child-2/pom.xml b/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/child-2/pom.xml new file mode 100644 index 0000000000..95ce7fe6dc --- /dev/null +++ b/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/child-2/pom.xml @@ -0,0 +1,45 @@ + + + + + + 4.0.0 + + + + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + + + org.apache.maven.its.mng3843.child + child-2 + 0.2 + jar + + + + child-mailing-list + + + diff --git a/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/pom.xml b/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/pom.xml new file mode 100644 index 0000000000..c9b05dfd96 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3843 + parent-1 + 0.1 + pom + + + + parent-mailing-list + + + diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java index 42adcf5231..a51bd6a787 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -31,11 +31,15 @@ import java.util.StringTokenizer; import org.apache.maven.model.BuildBase; import org.apache.maven.model.CiManagement; +import org.apache.maven.model.Contributor; import org.apache.maven.model.Dependency; import org.apache.maven.model.DeploymentRepository; +import org.apache.maven.model.Developer; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Extension; import org.apache.maven.model.IssueManagement; +import org.apache.maven.model.License; +import org.apache.maven.model.MailingList; import org.apache.maven.model.Model; import org.apache.maven.model.ModelBase; import org.apache.maven.model.Organization; @@ -172,6 +176,45 @@ public class MavenModelMerger // neither inherited nor injected } + @Override + protected void mergeModel_Licenses( Model target, Model source, boolean sourceDominant, Map context ) + { + if ( target.getLicenses().isEmpty() ) + { + target.setLicenses( new ArrayList( source.getLicenses() ) ); + } + } + + @Override + protected void mergeModel_Developers( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getDevelopers().isEmpty() ) + { + target.setDevelopers( new ArrayList( source.getDevelopers() ) ); + } + } + + @Override + protected void mergeModel_Contributors( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getContributors().isEmpty() ) + { + target.setContributors( new ArrayList( source.getContributors() ) ); + } + } + + @Override + protected void mergeModel_MailingLists( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getMailingLists().isEmpty() ) + { + target.setMailingLists( new ArrayList( source.getMailingLists() ) ); + } + } + @Override protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant, Map context )