mirror of https://github.com/apache/maven.git
o Added contributor/developer processors
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@756980 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
609077e2b4
commit
e7eeaba62a
|
@ -0,0 +1,70 @@
|
||||||
|
package org.apache.maven.project.processor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.maven.model.Contributor;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
|
||||||
|
public class ContributorsProcessor
|
||||||
|
extends BaseProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||||
|
{
|
||||||
|
super.process( parent, child, target, isChildMostSpecialized );
|
||||||
|
|
||||||
|
Model p = (Model) parent;
|
||||||
|
Model c = (Model) child;
|
||||||
|
Model t = (Model) target;
|
||||||
|
|
||||||
|
if ( !c.getContributors().isEmpty() )
|
||||||
|
{
|
||||||
|
copyContributors( c.getContributors(), t );
|
||||||
|
}
|
||||||
|
else if ( p != null && !p.getContributors().isEmpty() )
|
||||||
|
{
|
||||||
|
copyContributors( p.getContributors(), t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyContributors( List<Contributor> contributors, Model target )
|
||||||
|
{
|
||||||
|
for ( Contributor contributor : contributors )
|
||||||
|
{
|
||||||
|
Contributor copy = new Contributor();
|
||||||
|
copy.setName( contributor.getName() );
|
||||||
|
copy.setEmail( contributor.getEmail() );
|
||||||
|
copy.setUrl( contributor.getUrl() );
|
||||||
|
copy.setOrganization( contributor.getOrganization() );
|
||||||
|
copy.setOrganizationUrl( contributor.getOrganizationUrl() );
|
||||||
|
copy.setTimezone( contributor.getTimezone() );
|
||||||
|
copy.setRoles( new ArrayList<String>( contributor.getRoles() ) );
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.putAll( contributor.getProperties() );
|
||||||
|
copy.setProperties( props );
|
||||||
|
target.addContributor( copy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package org.apache.maven.project.processor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.maven.model.Developer;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
|
||||||
|
public class DevelopersProcessor
|
||||||
|
extends BaseProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||||
|
{
|
||||||
|
super.process( parent, child, target, isChildMostSpecialized );
|
||||||
|
|
||||||
|
Model p = (Model) parent;
|
||||||
|
Model c = (Model) child;
|
||||||
|
Model t = (Model) target;
|
||||||
|
|
||||||
|
if ( !c.getDevelopers().isEmpty() )
|
||||||
|
{
|
||||||
|
copyDevelopers( c.getDevelopers(), t );
|
||||||
|
}
|
||||||
|
else if ( p != null && !p.getDevelopers().isEmpty() )
|
||||||
|
{
|
||||||
|
copyDevelopers( p.getDevelopers(), t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyDevelopers( List<Developer> developers, Model target )
|
||||||
|
{
|
||||||
|
for ( Developer developer : developers )
|
||||||
|
{
|
||||||
|
Developer copy = new Developer();
|
||||||
|
copy.setId( developer.getId() );
|
||||||
|
copy.setName( developer.getName() );
|
||||||
|
copy.setEmail( developer.getEmail() );
|
||||||
|
copy.setUrl( developer.getUrl() );
|
||||||
|
copy.setOrganization( developer.getOrganization() );
|
||||||
|
copy.setOrganizationUrl( developer.getOrganizationUrl() );
|
||||||
|
copy.setTimezone( developer.getTimezone() );
|
||||||
|
copy.setRoles( new ArrayList<String>( developer.getRoles() ) );
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.putAll( developer.getProperties() );
|
||||||
|
copy.setProperties( props );
|
||||||
|
target.addDeveloper( copy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -176,7 +176,8 @@ public class ProcessorContext
|
||||||
new MailingListProcessor(), new IssueManagementProcessor(),
|
new MailingListProcessor(), new IssueManagementProcessor(),
|
||||||
new CiManagementProcessor(), new ReportingProcessor(),
|
new CiManagementProcessor(), new ReportingProcessor(),
|
||||||
new RepositoriesProcessor(), new DistributionManagementProcessor(),
|
new RepositoriesProcessor(), new DistributionManagementProcessor(),
|
||||||
new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor() );
|
new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor(),
|
||||||
|
new ContributorsProcessor(), new DevelopersProcessor() );
|
||||||
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors, true );
|
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors, true );
|
||||||
|
|
||||||
PomClassicDomainModel model = convertToDomainModel( target, false );
|
PomClassicDomainModel model = convertToDomainModel( target, false );
|
||||||
|
|
|
@ -983,11 +983,28 @@ public class PomConstructionTest
|
||||||
assertEquals( "repo", pom.getValue( "licenses[1]/distribution" ) );
|
assertEquals( "repo", pom.getValue( "licenses[1]/distribution" ) );
|
||||||
assertEquals( "free", pom.getValue( "licenses[1]/comments" ) );
|
assertEquals( "free", pom.getValue( "licenses[1]/comments" ) );
|
||||||
|
|
||||||
/* FIXME
|
|
||||||
assertEquals( 1, ( (List<?>) pom.getValue( "developers" ) ).size() );
|
assertEquals( 1, ( (List<?>) pom.getValue( "developers" ) ).size() );
|
||||||
|
assertEquals( "dev", pom.getValue( "developers[1]/id" ) );
|
||||||
|
assertEquals( "project-developer", pom.getValue( "developers[1]/name" ) );
|
||||||
|
assertEquals( "developer@", pom.getValue( "developers[1]/email" ) );
|
||||||
|
assertEquals( "http://developer", pom.getValue( "developers[1]/url" ) );
|
||||||
|
assertEquals( "developer", pom.getValue( "developers[1]/organization" ) );
|
||||||
|
assertEquals( "http://devel.org", pom.getValue( "developers[1]/organizationUrl" ) );
|
||||||
|
assertEquals( "-1", pom.getValue( "developers[1]/timezone" ) );
|
||||||
|
assertEquals( "yes", pom.getValue( "developers[1]/properties/developer" ) );
|
||||||
|
assertEquals( 1, ( (List<?>) pom.getValue( "developers[1]/roles" ) ).size() );
|
||||||
|
assertEquals( "devel", pom.getValue( "developers[1]/roles[1]" ) );
|
||||||
|
|
||||||
assertEquals( 1, ( (List<?>) pom.getValue( "contributors" ) ).size() );
|
assertEquals( 1, ( (List<?>) pom.getValue( "contributors" ) ).size() );
|
||||||
//*/
|
assertEquals( "project-contributor", pom.getValue( "contributors[1]/name" ) );
|
||||||
|
assertEquals( "contributor@", pom.getValue( "contributors[1]/email" ) );
|
||||||
|
assertEquals( "http://contributor", pom.getValue( "contributors[1]/url" ) );
|
||||||
|
assertEquals( "contributor", pom.getValue( "contributors[1]/organization" ) );
|
||||||
|
assertEquals( "http://contrib.org", pom.getValue( "contributors[1]/organizationUrl" ) );
|
||||||
|
assertEquals( "+1", pom.getValue( "contributors[1]/timezone" ) );
|
||||||
|
assertEquals( "yes", pom.getValue( "contributors[1]/properties/contributor" ) );
|
||||||
|
assertEquals( 1, ( (List<?>) pom.getValue( "contributors[1]/roles" ) ).size() );
|
||||||
|
assertEquals( "contrib", pom.getValue( "contributors[1]/roles[1]" ) );
|
||||||
|
|
||||||
assertEquals( 1, ( (List<?>) pom.getValue( "mailingLists" ) ).size() );
|
assertEquals( 1, ( (List<?>) pom.getValue( "mailingLists" ) ).size() );
|
||||||
assertEquals( "project-mailing-list", pom.getValue( "mailingLists[1]/name" ) );
|
assertEquals( "project-mailing-list", pom.getValue( "mailingLists[1]/name" ) );
|
||||||
|
|
Loading…
Reference in New Issue