Fix for IT 3821.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@712621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2008-11-10 07:23:45 +00:00
parent 9929e8101d
commit 6468b08bda
2 changed files with 85 additions and 1 deletions

View File

@ -36,7 +36,7 @@ public class IdModelContainerFactory
private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
ProjectUri.PluginRepositories.PluginRepository.xUri, ProjectUri.Repositories.Repository.xUri,
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri, ProjectUri.Profiles.Profile.xUri) );
ProjectUri.Profiles.Profile.xUri) );
public Collection<String> getUris()
{

View File

@ -0,0 +1,84 @@
package org.apache.maven.project.builder;
import org.apache.maven.shared.model.ModelContainer;
import org.apache.maven.shared.model.ModelProperty;
import org.apache.maven.shared.model.ModelContainerAction;
import org.apache.maven.shared.model.ModelContainerFactory;
import java.util.*;
public class PluginReportSetIdModelContainerFactory implements ModelContainerFactory {
private static final Collection<String> uris = Collections.unmodifiableList(Arrays.asList(
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri));
public Collection<String> getUris() {
return uris;
}
public ModelContainer create(List<ModelProperty> modelProperties) {
if ( modelProperties == null || modelProperties.size() == 0 )
{
throw new IllegalArgumentException( "modelProperties: null or empty" );
}
return new PluginReportSetIdModelContainer( modelProperties );
}
private static class PluginReportSetIdModelContainer
implements ModelContainer
{
private String id;
private List<ModelProperty> properties;
private PluginReportSetIdModelContainer( List<ModelProperty> properties )
{
this.properties = new ArrayList<ModelProperty>( properties );
this.properties = Collections.unmodifiableList( this.properties );
for ( ModelProperty mp : properties )
{
if ( mp.getUri().endsWith( "/id" ) )
{
this.id = mp.getResolvedValue();
}
}
}
public ModelContainerAction containerAction( ModelContainer modelContainer )
{
if ( modelContainer == null )
{
throw new IllegalArgumentException( "modelContainer: null" );
}
if ( !( modelContainer instanceof PluginReportSetIdModelContainer ) )
{
throw new IllegalArgumentException( "modelContainer: wrong type" );
}
PluginReportSetIdModelContainer c = (PluginReportSetIdModelContainer) modelContainer;
if ( c.id == null || id == null )
{
return ModelContainerAction.NOP;
}
return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP;
}
public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
{
return new PluginReportSetIdModelContainer( modelProperties );
}
public List<ModelProperty> getProperties()
{
return properties;
}
public String toString()
{
return "ID = " + id;
}
}
}