Author: dkulp
Date: Thu Nov  1 14:52:09 2012
New Revision: 1404619

URL: http://svn.apache.org/viewvc?rev=1404619&view=rev
Log:
[CXF-4581] UPdates to work better with m2eclipse incremental builds
Patch from Josh Beitelspacher applied.

Modified:
    
cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

Modified: 
cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1404619&r1=1404618&r2=1404619&view=diff
==============================================================================
--- 
cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
 (original)
+++ 
cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
 Thu Nov  1 14:52:09 2012
@@ -220,6 +220,20 @@ public abstract class AbstractCodegenMoh
     }
 
     public void execute() throws MojoExecutionException {
+        // add the generated source into compile source
+        // do this step first to ensure the source folder will be added to the 
Eclipse classpath
+        if (project != null && getGeneratedSourceRoot() != null) {
+            
project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
+        }
+        if (project != null && getGeneratedTestRoot() != null) {
+            
project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
+        }
+
+        // if this is an m2e configuration build then return immediately 
without doing any work
+        if (project != null && buildContext.isIncremental() && 
!buildContext.hasDelta(project.getBasedir())) {
+            return;
+        }
+
         File classesDir = new File(classesDirectory);
         /*
          * This shouldn't be needed, but it's harmless.
@@ -272,13 +286,11 @@ public abstract class AbstractCodegenMoh
             classLoaderSwitcher.restoreClassLoader();
         }
 
-        // add the generated source into compile source
+        // refresh the generated sources
         if (project != null && getGeneratedSourceRoot() != null && 
getGeneratedSourceRoot().exists()) {
-            
project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
             buildContext.refresh(getGeneratedSourceRoot().getAbsoluteFile());
         }
         if (project != null && getGeneratedTestRoot() != null && 
getGeneratedTestRoot().exists()) {
-            
project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
             buildContext.refresh(getGeneratedTestRoot().getAbsoluteFile());
         }
         System.gc();


Reply via email to