maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From epunza...@apache.org
Subject svn commit: r381884 - /maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
Date Wed, 01 Mar 2006 03:10:12 GMT
Author: epunzalan
Date: Tue Feb 28 19:10:11 2006
New Revision: 381884

URL: http://svn.apache.org/viewcvs?rev=381884&view=rev
Log:
PR: MIDEA-21
Submitted by: Chris Conrad

Patch to remove the modules from an existing idea ipr when updating the ipr

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

Modified: maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java?rev=381884&r1=381883&r2=381884&view=diff
==============================================================================
--- maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
(original)
+++ maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
Tue Feb 28 19:10:11 2006
@@ -251,10 +251,10 @@
             Xpp3Dom component = findComponent( module, "ProjectModuleManager" );
             Xpp3Dom modules = findElement( component, "modules" );
 
+            removeOldElements( modules, "module" );
+
             if ( project.getCollectedProjects().size() > 0 )
             {
-                removeOldElements( modules, "module" );
-
                 Xpp3Dom m = createElement( modules, "module" );
                 String projectPath = new File( project.getBasedir(),
                                                project.getArtifactId() + ".iml" ).getAbsolutePath();
@@ -361,11 +361,11 @@
                 addSourceFolder( content, directory, true );
             }
 
+            List resourceDirectory = new ArrayList();
             for ( Iterator i = project.getBuild().getResources().iterator(); i.hasNext();
)
             {
                 Resource resource = (Resource) i.next();
-                String directory = resource.getDirectory();
-                addSourceFolder( content, directory, false );
+                resourceDirectory.add( resource.getDirectory() );
             }
 
             for ( Iterator i = project.getBuild().getTestResources().iterator(); i.hasNext();
)
@@ -449,6 +449,15 @@
                 }
             }
 
+            for( Iterator resourceDirs = resourceDirectory.iterator(); resourceDirs.hasNext();
)
+            {
+                String resourceDir = (String) resourceDirs.next();
+
+                getLog().info( "Adding resource directory: " + resourceDir );
+
+                addResources( component, resourceDir );
+            }
+
             FileWriter writer = new FileWriter( moduleFile );
             try
             {
@@ -467,6 +476,20 @@
         {
             throw new MojoExecutionException( "Error parsing existing IML file " + moduleFile.getAbsolutePath(),
e );
         }
+    }
+
+    private void addResources( Xpp3Dom component, String directory ) {
+        Xpp3Dom dep = createElement( component, "orderEntry" );
+        dep.setAttribute( "type", "module-library" );
+        dep = createElement( dep, "library" );
+        dep.setAttribute( "name", "resources" );
+
+        Xpp3Dom el = createElement( dep, "CLASSES" );
+        el = createElement( el, "root" );
+        el.setAttribute( "url", getModuleFileUrl( directory ) );
+
+        createElement( dep, "JAVADOC" );
+        createElement( dep, "SOURCES" );
     }
 
     /**



Mime
View raw message