[jboss-cvs] JBossAS SVN: r72915 - in projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2: src/main/java/org/apache/maven/plugin and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 1 05:27:39 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-05-01 05:27:39 -0400 (Thu, 01 May 2008)
New Revision: 72915

Added:
   projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.classpath
   projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.project
Modified:
   projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/
   projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/pom.xml
   projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
Log:
Add testExcludeFile, testIncludeFile


Property changes on: projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2
___________________________________________________________________
Name: svn:ignore
   + .settings
target


Added: projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.classpath
===================================================================
--- projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.classpath	                        (rev 0)
+++ projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.classpath	2008-05-01 09:27:39 UTC (rev 72915)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java">
+		<attributes>
+			<attribute name="maven.type" value="test"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>

Added: projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.project
===================================================================
--- projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.project	                        (rev 0)
+++ projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/.project	2008-05-01 09:27:39 UTC (rev 72915)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>maven-compiler-plugin</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Modified: projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/pom.xml
===================================================================
--- projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/pom.xml	2008-05-01 08:54:27 UTC (rev 72914)
+++ projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/pom.xml	2008-05-01 09:27:39 UTC (rev 72915)
@@ -8,7 +8,7 @@
   <artifactId>maven-compiler-plugin</artifactId>
   <packaging>maven-plugin</packaging>
   <name>Maven Compiler Plugin</name>
-  <version>2.0.2</version>
+  <version>2.0.2.SP1</version>
   <inceptionYear>2001</inceptionYear>
   <prerequisites>
     <maven>2.0</maven>

Modified: projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
===================================================================
--- projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java	2008-05-01 08:54:27 UTC (rev 72914)
+++ projects/maven/plugins/maven-compiler-plugin/branches/maven-compiler-plugin-2.0.2/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java	2008-05-01 09:27:39 UTC (rev 72915)
@@ -23,7 +23,10 @@
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -33,6 +36,7 @@
  * Compiles application test sources
  *
  * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:thomas.diesler at jboss.org">Thomas Diesler</a>
  * @version $Id$
  * @goal testCompile
  * @phase test-compile
@@ -90,6 +94,20 @@
      */
     private Set testExcludes = new HashSet();
 
+    /**
+     * A file of exclusion filters for the compiler.
+     *
+     * @parameter
+     */
+    private File testExcludeFile;
+
+    /**
+     * A file of inclusion filters for the compiler.
+     *
+     * @parameter
+     */
+    private File testIncludeFile;
+
     public void execute()
         throws MojoExecutionException, CompilationFailureException
     {
@@ -122,17 +140,19 @@
     {
         SourceInclusionScanner scanner = null;
 
-        if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
+        Set effectiveIncludes = getEffectiveIncludes();
+        Set effectiveExcludes = getEffectiveExcludes();
+        if ( effectiveIncludes.isEmpty() && effectiveExcludes.isEmpty() )
         {
             scanner = new StaleSourceScanner( staleMillis );
         }
         else
         {
-            if ( testIncludes.isEmpty() )
+            if ( effectiveIncludes.isEmpty() )
             {
-                testIncludes.add( "**/*.java" );
+               effectiveIncludes.add( "**/*.java" );
             }
-            scanner = new StaleSourceScanner( staleMillis, testIncludes, testExcludes );
+            scanner = new StaleSourceScanner( staleMillis, effectiveIncludes, effectiveExcludes );
         }
 
         return scanner;
@@ -142,21 +162,84 @@
     {
         SourceInclusionScanner scanner = null;
 
-        if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
+        Set effectiveIncludes = getEffectiveIncludes();
+        Set effectiveExcludes = getEffectiveExcludes();
+        if ( effectiveIncludes.isEmpty() && effectiveExcludes.isEmpty() )
         {
-            testIncludes = Collections.singleton( "**/*." + inputFileEnding );
-            scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.EMPTY_SET );
+           effectiveIncludes = Collections.singleton( "**/*." + inputFileEnding );
+            scanner = new SimpleSourceInclusionScanner( effectiveIncludes, Collections.EMPTY_SET );
         }
         else
         {
-            if ( testIncludes.isEmpty() )
+            if ( effectiveIncludes.isEmpty() )
             {
-                testIncludes.add( "**/*." + inputFileEnding );
+               effectiveIncludes.add( "**/*." + inputFileEnding );
             }
-            scanner = new SimpleSourceInclusionScanner( testIncludes, testExcludes );
+            scanner = new SimpleSourceInclusionScanner( effectiveIncludes, effectiveExcludes );
         }
 
         return scanner;
     }
 
+    protected Set getEffectiveIncludes() 
+    {
+      Set effectiveIncludes = new HashSet(testIncludes);
+      if (testIncludeFile != null)
+      {
+         if (testIncludeFile.exists() == false)
+            throw new IllegalArgumentException("Cannot find: " + testIncludeFile);
+
+         try
+         {
+            BufferedReader br = new BufferedReader(new FileReader(testIncludeFile));
+            String line = br.readLine();
+            while (line != null)
+            {
+               if (line.length() > 0 && !line.startsWith("#"))
+               {
+                  getLog().debug("Add include: " + line);
+                  effectiveIncludes.add(line);
+               }
+               line = br.readLine();
+            }
+            br.close();
+         }
+         catch (IOException ex)
+         {
+            throw new IllegalArgumentException("Cannot process: " + testIncludeFile, ex);
+         }
+      }
+      return effectiveIncludes;
+    }
+
+    protected Set getEffectiveExcludes() 
+    {
+       Set effectiveExcludes = new HashSet(testExcludes);
+       if (testExcludeFile != null)
+       {
+          if (testExcludeFile.exists() == false)
+             throw new IllegalArgumentException("Cannot find: " + testExcludeFile);
+
+          try
+          {
+             BufferedReader br = new BufferedReader(new FileReader(testExcludeFile));
+             String line = br.readLine();
+             while (line != null)
+             {
+                if (line.length() > 0 && !line.startsWith("#"))
+                {
+                   getLog().debug("Add exclude: " + line);
+                   effectiveExcludes.add(line);
+                }
+                line = br.readLine();
+             }
+             br.close();
+          }
+          catch (IOException ex)
+          {
+             throw new IllegalArgumentException("Cannot process: " + testExcludeFile, ex);
+          }
+       }
+       return effectiveExcludes;
+    }
 }




More information about the jboss-cvs-commits mailing list