From 6468b08bda895f93d98763147569858c254b1238 Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Mon, 10 Nov 2008 07:23:45 +0000 Subject: [PATCH] Fix for IT 3821. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@712621 13f79535-47bb-0310-9956-ffa450edef68 --- .../builder/IdModelContainerFactory.java | 2 +- ...luginReportSetIdModelContainerFactory.java | 84 +++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 maven-project/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java diff --git a/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java b/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java index b04821270b..25a9b45fab 100644 --- a/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java +++ b/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java @@ -36,7 +36,7 @@ public class IdModelContainerFactory private static final Collection 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 getUris() { diff --git a/maven-project/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java b/maven-project/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java new file mode 100644 index 0000000000..3b1e71f453 --- /dev/null +++ b/maven-project/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java @@ -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 uris = Collections.unmodifiableList(Arrays.asList( + ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri)); + + public Collection getUris() { + return uris; + } + + public ModelContainer create(List 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 properties; + + private PluginReportSetIdModelContainer( List properties ) + { + this.properties = new ArrayList( 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 modelProperties ) + { + return new PluginReportSetIdModelContainer( modelProperties ); + } + + public List getProperties() + { + return properties; + } + + public String toString() + { + return "ID = " + id; + } + } +}