You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2006/09/20 09:15:36 UTC

svn commit: r448104 - in /myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin: AbstractAPTMojo.java AptMojo.java TestAptMojo.java

Author: bommel
Date: Wed Sep 20 00:15:35 2006
New Revision: 448104

URL: http://svn.apache.org/viewvc?view=rev&rev=448104
Log:
[TOBAGO-131] Maven Apt Plugin should support additional sourceRoot directories
revert [TOBAGO-130]

Modified:
    myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AbstractAPTMojo.java
    myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AptMojo.java
    myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/TestAptMojo.java

Modified: myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AbstractAPTMojo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AbstractAPTMojo.java?view=diff&rev=448104&r1=448103&r2=448104
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AbstractAPTMojo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AbstractAPTMojo.java Wed Sep 20 00:15:35 2006
@@ -31,7 +31,6 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 
@@ -84,15 +83,6 @@
     protected String resourceTargetPath;
 
     /**
-      * The plugin dependencies.
-      *
-      * @parameter expression="${plugin.artifacts}"
-      * @required
-      * @readonly
-      */
-     private List artifacts;
-
-    /**
      * Whether to include debugging information in the compiled class files. The
      * default value is true.
      * 
@@ -196,6 +186,8 @@
 
     protected abstract List getCompileSourceRoots();
 
+    protected abstract List getAptSourceRoots();
+
     protected abstract File getOutputDirectory();
 
     protected abstract String getGenerated();
@@ -242,6 +234,10 @@
             }
             Class c = this.getClass().forName( APT_ENTRY_POINT ); // getAptCompilerClass();
             Object compiler = c.newInstance();
+            if( getLog().isDebugEnabled() )
+            {
+                getLog().debug( "Invoking apt with cmd " + cmd );
+            }
             try {
               Method compile = c.getMethod( APT_METHOD_NAME, new Class[] {
                     PrintWriter.class, (new String[] {}).getClass() } );
@@ -367,40 +363,60 @@
         boolean has = false;
         // sources ....
         Iterator it = getCompileSourceRoots().iterator();
+        if( getLog().isDebugEnabled() ) {
+            getLog().debug("Checking sourcepath");
+        }
         while( it.hasNext() )
         {
             File srcFile = new File( (String) it.next() );
-            if( srcFile.isDirectory() )
+            has = addIncludedSources(srcFile, cmd, has);
+        }
+        List aptSourcesRoots = getAptSourceRoots();
+        if( aptSourcesRoots != null) {
+            it = aptSourcesRoots.iterator();
+            while( it.hasNext() )
             {
-                Collection sources = null;
-                try
-                {
-                    sources = //
+                File srcFile = new File( (String) it.next() );
+                has = addIncludedSources(srcFile, cmd, has);
+            }
+        }
+        return has;
+    }
+
+    private boolean addIncludedSources(File srcFile, List cmd, boolean has) throws MojoExecutionException {
+        if( getLog().isDebugEnabled() ) {
+            getLog().debug("Checking sourcepath in " + srcFile);
+        }
+        if( srcFile.isDirectory() )
+        {
+            Collection sources = null;
+            try
+            {
+                sources = //
                     getSourceInclusionScanner().getIncludedSources( srcFile,
-                            getOutputDirectory() );
-                } catch ( Exception ex )
-                {
-                    throw new MojoExecutionException(
-                            "Can't agregate sources.", ex );
-                }
-                if( getLog().isDebugEnabled() )
-                {
-                    getLog().debug(
-                            "sources from: " + srcFile.getAbsolutePath() );
-                    String s = "";
-                    for( Iterator jt = sources.iterator(); jt.hasNext(); )
-                    {
-                        s += jt.next() + "\n";
-                    }
-                    getLog().debug( s );
-                }
-                Iterator jt = sources.iterator();
-                while( jt.hasNext() )
+                        getOutputDirectory() );
+            } catch ( Exception ex )
+            {
+                throw new MojoExecutionException(
+                    "Can't agregate sources.", ex );
+            }
+            if( getLog().isDebugEnabled() )
+            {
+                getLog().debug(
+                        "sources from: " + srcFile.getAbsolutePath() );
+                String s = "";
+                for( Iterator jt = sources.iterator(); jt.hasNext(); )
                 {
-                    File src = (File) jt.next();
-                    cmd.add( src.getAbsolutePath() );
-                    has = true;
+                     s += jt.next() + "\n";
                 }
+                getLog().debug( s );
+            }
+            Iterator jt = sources.iterator();
+            while( jt.hasNext() )
+            {
+                File src = (File) jt.next();
+                cmd.add( src.getAbsolutePath() );
+                has = true;
             }
         }
         return has;
@@ -415,24 +431,6 @@
             {
                 buffer.append( PATH_SEPARATOR );
             }
-        }
-        for( Iterator it = artifacts.iterator(); it.hasNext(); )
-        {
-
-             Artifact a = (Artifact) it.next();
-             File file = a.getFile();
-             if ( file == null )
-             {
-                 throw new DependencyResolutionRequiredException( a );
-             }
-
-
-             if ( buffer.length() > 0 )
-             {
-                 buffer.append( PATH_SEPARATOR );
-             }
-             buffer.append( file.getPath() );
-
         }
         cmdAdd( cmd, "-classpath", buffer.toString() );
     }

Modified: myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AptMojo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AptMojo.java?view=diff&rev=448104&r1=448103&r2=448104
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AptMojo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/AptMojo.java Wed Sep 20 00:15:35 2006
@@ -53,10 +53,18 @@
      * 
      * @parameter expression="${project.compileSourceRoots}"
      * @required
+     * @readonly
      */
     private List compileSourceRoots;
 
     /**
+     * The extra source directories containing the sources to be processed.
+     *
+     * @parameter
+     */
+    private List aptSourceRoots;
+
+    /**
      * Project classpath.
      * 
      * @parameter expression="${project.compileClasspathElements}"
@@ -92,6 +100,11 @@
     protected File getOutputDirectory()
     {
         return outputDirectory;
+    }
+
+    protected List getAptSourceRoots()
+    {
+        return aptSourceRoots;
     }
 
     public void execute() throws MojoExecutionException

Modified: myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/TestAptMojo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/TestAptMojo.java?view=diff&rev=448104&r1=448103&r2=448104
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/TestAptMojo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/maven-apt-plugin/src/main/java/org/apache/myfaces/maven/plugin/TestAptMojo.java Wed Sep 20 00:15:35 2006
@@ -60,10 +60,18 @@
      * 
      * @parameter expression="${project.testCompileSourceRoots}"
      * @required
+     * @readonly
      */
     private List compileSourceRoots;
 
     /**
+     * The extra source directories containing the test-source to be processed.
+     *
+     * @parameter
+     */
+    private List aptSourceRoots;
+
+    /**
      * Project test classpath.
      * 
      * @parameter expression="${project.testClasspathElements}"
@@ -134,6 +142,11 @@
     protected File getOutputDirectory()
     {
         return outputDirectory;
+    }
+
+    protected List getAptSourceRoots()
+    {
+        return aptSourceRoots;
     }
 
     protected SourceInclusionScanner getSourceInclusionScanner()