o Fixed inheritance of <developers>, <contributors>, <licenses> and <mailingLists>

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@783556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-10 22:30:55 +00:00
parent 424b7ef1b0
commit db5d449c33
10 changed files with 400 additions and 0 deletions

View File

@ -1520,6 +1520,39 @@ public class PomConstructionTest
assertSame( null, pom.getValue( "prerequisites" ) ); 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 ) private void assertPathSuffixEquals( String expected, Object actual )
{ {
String a = actual.toString(); String a = actual.toString();

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<!--
While <contributors> are inherited, they are not aggregated, only the child elements are used.
-->
<parent>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
</parent>
<groupId>org.apache.maven.its.mng3843.child</groupId>
<artifactId>child-2</artifactId>
<version>0.2</version>
<packaging>jar</packaging>
<contributors>
<contributor>
<name>child-contributor</name>
</contributor>
</contributors>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<contributors>
<contributor>
<name>parent-contributor</name>
</contributor>
</contributors>
</project>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<!--
While <developers> are inherited, they are not aggregated, only the child elements are used.
-->
<parent>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
</parent>
<groupId>org.apache.maven.its.mng3843.child</groupId>
<artifactId>child-2</artifactId>
<version>0.2</version>
<packaging>jar</packaging>
<developers>
<developer>
<name>child-developer</name>
</developer>
</developers>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<developers>
<developer>
<name>parent-developer</name>
</developer>
</developers>
</project>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<!--
While <licenses> are inherited, they are not aggregated, only the child licenses are used.
-->
<parent>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
</parent>
<groupId>org.apache.maven.its.mng3843.child</groupId>
<artifactId>child-2</artifactId>
<version>0.2</version>
<packaging>jar</packaging>
<licenses>
<license>
<name>child-license</name>
<url>http://child.url/license</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<licenses>
<license>
<name>parent-license</name>
<url>http://parent.url/license</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<!--
While <mailingLists> are inherited, they are not aggregated, only the child elements are used.
-->
<parent>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
</parent>
<groupId>org.apache.maven.its.mng3843.child</groupId>
<artifactId>child-2</artifactId>
<version>0.2</version>
<packaging>jar</packaging>
<mailingLists>
<mailingList>
<name>child-mailing-list</name>
</mailingList>
</mailingLists>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3843</groupId>
<artifactId>parent-1</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<mailingLists>
<mailingList>
<name>parent-mailing-list</name>
</mailingList>
</mailingLists>
</project>

View File

@ -31,11 +31,15 @@ import java.util.StringTokenizer;
import org.apache.maven.model.BuildBase; import org.apache.maven.model.BuildBase;
import org.apache.maven.model.CiManagement; import org.apache.maven.model.CiManagement;
import org.apache.maven.model.Contributor;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Developer;
import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Extension; import org.apache.maven.model.Extension;
import org.apache.maven.model.IssueManagement; 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.Model;
import org.apache.maven.model.ModelBase; import org.apache.maven.model.ModelBase;
import org.apache.maven.model.Organization; import org.apache.maven.model.Organization;
@ -172,6 +176,45 @@ public class MavenModelMerger
// neither inherited nor injected // neither inherited nor injected
} }
@Override
protected void mergeModel_Licenses( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
{
if ( target.getLicenses().isEmpty() )
{
target.setLicenses( new ArrayList<License>( source.getLicenses() ) );
}
}
@Override
protected void mergeModel_Developers( Model target, Model source, boolean sourceDominant,
Map<Object, Object> context )
{
if ( target.getDevelopers().isEmpty() )
{
target.setDevelopers( new ArrayList<Developer>( source.getDevelopers() ) );
}
}
@Override
protected void mergeModel_Contributors( Model target, Model source, boolean sourceDominant,
Map<Object, Object> context )
{
if ( target.getContributors().isEmpty() )
{
target.setContributors( new ArrayList<Contributor>( source.getContributors() ) );
}
}
@Override
protected void mergeModel_MailingLists( Model target, Model source, boolean sourceDominant,
Map<Object, Object> context )
{
if ( target.getMailingLists().isEmpty() )
{
target.setMailingLists( new ArrayList<MailingList>( source.getMailingLists() ) );
}
}
@Override @Override
protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant, protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant,
Map<Object, Object> context ) Map<Object, Object> context )