Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 25389 invoked from network); 31 May 2006 22:16:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 May 2006 22:16:27 -0000 Received: (qmail 87601 invoked by uid 500); 31 May 2006 22:16:20 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 87546 invoked by uid 500); 31 May 2006 22:16:20 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 87393 invoked by uid 99); 31 May 2006 22:16:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 May 2006 15:16:17 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 May 2006 15:16:15 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id A50CC1A983A; Wed, 31 May 2006 15:15:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r410686 - /maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java Date: Wed, 31 May 2006 22:15:55 -0000 To: commits@maven.apache.org From: carlos@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060531221555.A50CC1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: carlos Date: Wed May 31 15:15:54 2006 New Revision: 410686 URL: http://svn.apache.org/viewvc?rev=410686&view=rev Log: [MNG-2327] Don't add plugins twice Modified: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java Modified: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java?rev=410686&r1=410685&r2=410686&view=diff ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java (original) +++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/AbstractPluginConfigurationConverter.java Wed May 31 15:15:54 2006 @@ -17,6 +17,7 @@ */ import java.io.StringReader; +import java.util.Iterator; import java.util.Properties; import org.apache.maven.model.Model; @@ -27,6 +28,7 @@ /** * @author Fabrizio Giustina + * @author Dennis Lundberg * @version $Id$ */ public abstract class AbstractPluginConfigurationConverter @@ -40,13 +42,10 @@ } public void convertConfiguration( Model v4Model, org.apache.maven.model.v3_0_0.Model v3Model, - Properties projectProperties ) + Properties projectProperties ) throws MojoExecutionException { - - Plugin plugin = new Plugin(); - plugin.setGroupId( getGroupId() ); - plugin.setArtifactId( getArtifactId() ); + boolean addPlugin = false; Xpp3Dom configuration = newXpp3Dom( "" ); @@ -54,10 +53,44 @@ if ( configuration.getChildCount() > 0 ) { + Plugin plugin = findPlugin( v4Model, getGroupId(), getArtifactId() ); + if ( plugin == null ) + { + addPlugin = true; + plugin = new Plugin(); + plugin.setGroupId( getGroupId() ); + plugin.setArtifactId( getArtifactId() ); + } + plugin.setConfiguration( configuration ); - v4Model.getBuild().addPlugin( plugin ); + + if ( addPlugin ) + { + v4Model.getBuild().addPlugin( plugin ); + } } + } + /** + * Try to find a plugin in a model. + * + * @param model Look for the plugin in this model + * @param groupId The groupId for the plugin to look for + * @param artifactId The artifactId for the plugin to look for + * @return The requested plugin if it exists, otherwise null + */ + private Plugin findPlugin( Model model, String groupId, String artifactId ) + { + Iterator iterator = model.getBuild().getPlugins().iterator(); + while ( iterator.hasNext() ) + { + Plugin plugin = (Plugin) iterator.next(); + if ( plugin.getGroupId().equals( groupId ) && plugin.getArtifactId().equals( artifactId ) ) + { + return plugin; + } + } + return null; } protected abstract void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model,