Author: fgiust
Date: Wed Oct 25 00:42:10 2006
New Revision: 467577

URL: http://svn.apache.org/viewvc?view=rev&rev=467577
Log:
MECLIPSE-48 handle includes and excludes in source dirs

Added:
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.classpath
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.project
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
   (with props)
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/src/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/src/main/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/src/main/java/
Modified:
    maven/plugins/trunk/maven-eclipse-plugin/pom.xml
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-03/expected/.classpath

Modified: maven/plugins/trunk/maven-eclipse-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/pom.xml?view=diff&rev=467577&r1=467576&r2=467577
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/pom.xml Wed Oct 25 00:42:10 2006
@@ -34,6 +34,7 @@
           <excludes>
             <exclude>**/Abstract*TestCase.java</exclude>
             <exclude>**/EclipsePluginMasterProjectTest.java</exclude>
+            <exclude>**/InstallPluginsMojoTest.java</exclude>
           </excludes>
         </configuration>
       </plugin>

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?view=diff&rev=467577&r1=467576&r2=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
 Wed Oct 25 00:42:10 2006
@@ -789,37 +789,16 @@
 
             if ( resource.getIncludes().size() != 0 )
             {
-                // @todo includePattern = ?
-                getLog().warn( Messages.getString( 
"EclipsePlugin.includenotsupported" ) ); //$NON-NLS-1$
+                includePattern = StringUtils.join( 
resource.getIncludes().iterator(), "|" );
             }
 
             if ( resource.getExcludes().size() != 0 )
             {
-                // @todo excludePattern = ?
-                getLog().warn( Messages.getString( 
"EclipsePlugin.excludenotsupported" ) ); //$NON-NLS-1$
+                excludePattern = StringUtils.join( 
resource.getExcludes().iterator(), "|" );
             }
 
-            // Example of setting include/exclude patterns for future 
reference.
-            //
             // TODO: figure out how to merge if the same dir is specified twice
-            // with different in/exclude patterns. We can't write them now,
-            // since only the the first one would be included.
-            //
-            // if ( resource.getIncludes().size() != 0 )
-            // {
-            // writer.addAttribute(
-            // "including", StringUtils.join( 
resource.getIncludes().iterator(),
-            // "|" )
-            // );
-            // }
-            //
-            // if ( resource.getExcludes().size() != 0 )
-            // {
-            // writer.addAttribute(
-            // "excluding", StringUtils.join( 
resource.getExcludes().iterator(),
-            // "|" )
-            // );
-            // }
+            // with different in/exclude patterns.
 
             File resourceDirectory = new File( resource.getDirectory() );
 

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java?view=diff&rev=467577&r1=467576&r2=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
 Wed Oct 25 00:42:10 2006
@@ -94,6 +94,11 @@
     private static final String ATTR_CON = "con"; //$NON-NLS-1$     
 
     /**
+     * Attribute name for source file includes in a path.
+     */
+    private static final String ATTR_INCLUDING = "including";
+
+    /**
      * Attribute name for source file excludes in a path.
      */
     private static final String ATTR_EXCLUDING = "excluding";
@@ -155,9 +160,23 @@
                 writer.addAttribute( ATTR_OUTPUT, dir.getOutput() );
             }
 
+            if ( StringUtils.isNotEmpty( dir.getInclude() ) )
+            {
+                writer.addAttribute( ATTR_INCLUDING, dir.getInclude() );
+            }
+
+            String excludes = dir.getExclude();
+
             if ( dir.isResource() )
             {
-                writer.addAttribute( ATTR_EXCLUDING, "**/*.java" );
+                // automatically exclude java files: eclipse doesn't have the 
concept of resource directory so it will
+                // try to compile any java file found in maven resource dirs
+                excludes = StringUtils.isEmpty( excludes ) ? "**/*.java" : 
excludes + "|**/*.java";
+            }
+
+            if ( StringUtils.isNotEmpty( excludes ) )
+            {
+                writer.addAttribute( ATTR_EXCLUDING, excludes );
             }
 
             writer.endElement();

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java?view=diff&rev=467577&r1=467576&r2=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
 Wed Oct 25 00:42:10 2006
@@ -233,4 +233,14 @@
         testProject( "project-24" );
     }
 
+    /**
+     * Test source exclude/include.
+     * @throws Exception any exception thrown during test
+     */
+    public void testProject25()
+        throws Exception
+    {
+        testProject( "project-25" );
+    }
+
 }

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-03/expected/.classpath
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-03/expected/.classpath?view=diff&rev=467577&r1=467576&r2=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-03/expected/.classpath
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-03/expected/.classpath
 Wed Oct 25 00:42:10 2006
@@ -1,6 +1,6 @@
 <classpath>
   <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources" 
output="target/classes/main-resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/resources" 
output="target/classes/main-resources" including="**/*.xml" 
excluding="**/*.properties|**/*.java"/>
   <classpathentry kind="src" path="src/test/resources" 
output="target/test-output-dir" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

Added: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.classpath
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.classpath?view=auto&rev=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.classpath
 (added)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.classpath
 Wed Oct 25 00:42:10 2006
@@ -0,0 +1,6 @@
+<classpath>
+  <classpathentry kind="src" path="." including="plugin.*|*.bmp|icons/*.*" 
excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.project
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.project?view=auto&rev=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.project
 (added)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/expected/.project
 Wed Oct 25 00:42:10 2006
@@ -0,0 +1,14 @@
+<projectDescription>
+  <name>maven-eclipse-plugin-test-project-25</name>
+  <comment/>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+      <arguments/>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml?view=auto&rev=467577
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
 Wed Oct 25 00:42:10 2006
@@ -0,0 +1,32 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>eclipse</groupId>
+  <artifactId>maven-eclipse-plugin-test-project-25</artifactId>
+  <version>25</version>
+  <name>maven-eclipse-plugin-test-project-25</name>
+  <build>
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+        <excludes>
+          <exclude>*.txt</exclude>
+        </excludes>
+      </resource>
+      <resource>
+        <directory>${basedir}</directory>
+        <includes>
+          <include>plugin.*</include>
+          <include>*.bmp</include>
+          <include>icons/*.*</include>
+        </includes>
+      </resource>
+      <resource>
+        <directory>/src/main/java</directory>
+        <includes>
+          <include>*.xml</include>
+        </includes>
+      </resource>
+    </resources>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-25/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to