Author: epunzalan
Date: Fri Mar  3 00:01:42 2006
New Revision: 382712

URL: http://svn.apache.org/viewcvs?rev=382712&view=rev
Log:
Fixed a bug that creates additional <orderEntry> on an already existing 
<orderEntry> element with the same attribute

Modified:
    
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java?rev=382712&r1=382711&r2=382712&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
 Fri Mar  3 00:01:42 2006
@@ -263,7 +263,47 @@
             for ( Iterator i = testClasspathElements.iterator(); i.hasNext(); )
             {
                 Artifact a = (Artifact) i.next();
-                Xpp3Dom dep = createElement( component, "orderEntry" );
+
+                String moduleName;
+                if ( useFullNames )
+                {
+                    moduleName = a.getGroupId() + ':' + a.getArtifactId() + 
':' + a.getType() + ':' + a.getVersion();
+                }
+                else
+                {
+                    moduleName = a.getArtifactId();
+                }
+
+                Xpp3Dom dep = null;
+
+                Xpp3Dom[] orderEntries = component.getChildren( "orderEntry" );
+                for( int idx = 0; idx < orderEntries.length; idx++ )
+                {
+                    Xpp3Dom orderEntry = orderEntries[ idx ];
+
+                    if ( orderEntry.getAttribute( "type" ).equals( "module" ) )
+                    {
+                        if ( orderEntry.getAttribute( "module-name" ).equals( 
moduleName ) )
+                        {
+                            dep = orderEntry;
+                            break;
+                        }
+                    }
+                    else if ( orderEntry.getAttribute( "type" ).equals( 
"module-library" ) )
+                    {
+                        Xpp3Dom lib = orderEntry.getChild( "library" );
+                        if ( lib.getAttribute( "name" ).equals( moduleName ) )
+                        {
+                            dep = orderEntry;
+                            break;
+                        }
+                    }
+                }
+
+                if ( dep == null )
+                {
+                    dep = createElement( component, "orderEntry" );
+                }
 
                 boolean isIdeaModule = false;
                 if ( linkModules )
@@ -273,7 +313,7 @@
                     if ( isIdeaModule )
                     {
                         dep.setAttribute( "type", "module" );
-                        dep.setAttribute( "module-name", a.getArtifactId() );
+                        dep.setAttribute( "module-name", moduleName );
                     }
                 }
 
@@ -281,16 +321,6 @@
                 {
                     dep.setAttribute( "type", "module-library" );
                     dep = createElement( dep, "library" );
-                    String moduleName;
-                    if ( useFullNames )
-                    {
-                        moduleName =
-                            a.getGroupId() + ':' + a.getArtifactId() + ':' + 
a.getType() + ':' + a.getVersion();
-                    }
-                    else
-                    {
-                        moduleName = a.getArtifactId();
-                    }
                     dep.setAttribute( "name", moduleName );
 
                     Xpp3Dom el = createElement( dep, "CLASSES" );


Reply via email to