cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1406332 - in /cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin: AbstractCodegenMoho.java wsdl2java/WSDL2JavaMojo.java wsdl2js/WSDL2JavaScriptMojo.java
Date Tue, 06 Nov 2012 21:08:16 GMT
Author: dkulp
Date: Tue Nov  6 21:08:15 2012
New Revision: 1406332

URL: http://svn.apache.org/viewvc?rev=1406332&view=rev
Log:
Record the options used for the wsdl into the .DONE file and compare them on next run to allow
changes to the pom to trigger regeneration of code.

Modified:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.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=1406332&r1=1406331&r2=1406332&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
Tue Nov  6 21:08:15 2012
@@ -434,7 +434,7 @@ public abstract class AbstractCodegenMoh
             URI wsdlURI = getWsdlURI(wsdlOption, basedir);
             File doneFile = getDoneFile(basedir, wsdlURI, getMarkerSuffix());
             try {
-                doneFile.createNewFile();
+                createMarkerFile(wsdlOption, doneFile, wsdlURI);
             } catch (Throwable e) {
                 getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
                 getLog().debug(e);
@@ -570,6 +570,9 @@ public abstract class AbstractCodegenMoh
      */
     protected abstract boolean shouldRun(GenericWsdlOption wsdlOption, File doneFile, URI
wsdlURI);
 
+    protected void createMarkerFile(GenericWsdlOption wsdlOption, File doneFile, URI wsdlURI)
throws IOException {
+        doneFile.createNewFile();
+    }
    
     private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException
{
         try {

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java?rev=1406332&r1=1406331&r2=1406332&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
Tue Nov  6 21:08:15 2012
@@ -19,7 +19,11 @@
 
 package org.apache.cxf.maven_plugin.wsdl2java;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URI;
@@ -238,8 +242,41 @@ public class WSDL2JavaMojo extends Abstr
                 }
             }
         }
+        if (!doWork) {
+            URI basedir = project.getBasedir().toURI();
+            String options = wsdlOption.generateCommandLine(null, basedir, wsdlURI, false).toString();
+            DataInputStream reader = null;
+            try {
+                reader = new DataInputStream(new FileInputStream(doneFile));
+                String s = reader.readUTF();
+                if (!options.equals(s)) {
+                    doWork = true;
+                }
+            } catch (Exception ex) {
+                //ignore
+            } finally {
+                if (reader != null) {
+                    try {
+                        reader.close();
+                    } catch (IOException e) {
+                        //ignore
+                    }
+                }
+            }
+        }
         return doWork;
     }
+    
+    protected void createMarkerFile(GenericWsdlOption wsdlOption, File doneFile, URI wsdlURI)
throws IOException {
+        doneFile.createNewFile();
+        URI basedir = project.getBasedir().toURI();
+        String options = wsdlOption.generateCommandLine(null, basedir, wsdlURI, false).toString();
+        DataOutputStream writer = new DataOutputStream(new FileOutputStream(doneFile));
+        writer.writeUTF(options);
+        writer.flush();
+        writer.close();
+    }
+    
 
     /**
      * Finds the timestamp for a given URI. Calls {@link #getBaseFileURI(URI)} prior to the
timestamp
@@ -407,7 +444,7 @@ public class WSDL2JavaMojo extends Abstr
 
 
         try {
-            doneFile.createNewFile();
+            createMarkerFile(wsdlOption, doneFile, wsdlURI);
             buildContext.refresh(doneFile);
         } catch (Throwable e) {
             getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java?rev=1406332&r1=1406331&r2=1406332&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
Tue Nov  6 21:08:15 2012
@@ -136,7 +136,7 @@ public class WSDL2JavaScriptMojo extends
         }
 
         try {
-            doneFile.createNewFile();
+            createMarkerFile(wsdlOption, doneFile, wsdlURI);
         } catch (Throwable e) {
             getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
             getLog().debug(e);



Mime
View raw message