cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r667164 - in /cxf/trunk: common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Date Thu, 12 Jun 2008 17:10:46 GMT
Author: dkulp
Date: Thu Jun 12 10:10:46 2008
New Revision: 667164

URL: http://svn.apache.org/viewvc?rev=667164&view=rev
Log:
[CXF-1646] Update xsd plugin to put .DONE files in separate directory so not included in the
jar
Update both plugins to use mangled full paths to wsdl/schema for the .DONE marker. 

Modified:
    cxf/trunk/common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java

Modified: cxf/trunk/common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java?rev=667164&r1=667163&r2=667164&view=diff
==============================================================================
--- cxf/trunk/common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java (original)
+++ cxf/trunk/common/xsd/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaMojo.java Thu
Jun 12 10:10:46 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.maven_plugin;
 
 import java.io.File;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -59,11 +60,20 @@
      */
     XsdOption xsdOptions[];
     
+    /**
+     * Directory in which the "DONE" markers are saved that 
+     * @parameter expression="${cxf.markerDirectory}" 
+     *            default-value="${project.build.directory}/cxf-xsd-plugin-markers"
+     */
+    File markerDirectory;
+    
+    
     public void execute() throws MojoExecutionException {
         String outputDir = testSourceRoot == null ? sourceRoot : testSourceRoot;
         File outputDirFile = new File(outputDir);
         outputDirFile.mkdirs();
-        
+        markerDirectory.mkdirs();
+
         long timestamp = CodegenUtils.getCodegenTimestamp();
         boolean result = true;
         
@@ -74,12 +84,37 @@
         for (int x = 0; x < xsdOptions.length; x++) {
             String[] args = getArguments(xsdOptions[x], outputDir);
             
-            File file = new File(xsdOptions[x].getXsd());
-            File doneFile = new File(outputDirFile, "." + file.getName() + ".DONE");
+            String xsdLocation = xsdOptions[x].getXsd();
+            URI basedir = project.getBasedir().toURI();
+            URI xsdURI = basedir.resolve(xsdLocation);
+            
+            String doneFileName = xsdURI.toString();
+            if (doneFileName.startsWith(basedir.toString())) {
+                doneFileName = doneFileName.substring(basedir.toString().length());
+            }
+            
+            doneFileName = doneFileName.replace('?', '_')
+                .replace('&', '_').replace('/', '_').replace('\\', '_');
+            
+            // If URL to WSDL, replace ? and & since they're invalid chars for file names
+            File doneFile =
+                new File(markerDirectory, "." + doneFileName + ".DONE");
+            
+            long srctimestamp = 0;
+            if ("file".equals(xsdURI.getScheme())) {
+                srctimestamp = new File(xsdURI).lastModified();
+            } else {
+                try {
+                    srctimestamp = xsdURI.toURL().openConnection().getDate();
+                } catch (Exception e) {
+                    //ignore
+                }
+            }
+            
             boolean doWork = timestamp > doneFile.lastModified();
             if (!doneFile.exists()) {
                 doWork = true;
-            } else if (file.lastModified() > doneFile.lastModified()) {
+            } else if (srctimestamp > doneFile.lastModified()) {
                 doWork = true;
             } else {
                 File files[] = xsdOptions[x].getDependencies();

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java?rev=667164&r1=667163&r2=667164&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Thu Jun 12 10:10:46 2008
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
@@ -111,7 +112,6 @@
      */
     String excludes[];
                     
-
     private List<WsdlOption> getWsdlOptionsFromDir(final File root,
                                                    final File output)
         throws MojoExecutionException {
@@ -262,14 +262,39 @@
         File outputDirFile = wsdlOption.getOutputDir();
         outputDirFile.mkdirs();
         
-        File file = new File(wsdlOption.getWsdl());
+        
+        String wsdlLocation = wsdlOption.getWsdl();
+        URI basedir = project.getBasedir().toURI();
+        URI wsdlURI = basedir.resolve(wsdlLocation);
+        
+        String doneFileName = wsdlURI.toString();
+        if (doneFileName.startsWith(basedir.toString())) {
+            doneFileName = doneFileName.substring(basedir.toString().length());
+        }
+        
+        doneFileName = doneFileName.replace('?', '_')
+            .replace('&', '_').replace('/', '_').replace('\\', '_');
+        
         // If URL to WSDL, replace ? and & since they're invalid chars for file names
         File doneFile =
-            new File(markerDirectory, "." + file.getName().replace('?', '_').replace('&',
'_') + ".DONE");
+            new File(markerDirectory, "." + doneFileName + ".DONE");
+        
+        long timestamp = 0;
+        if ("file".equals(wsdlURI.getScheme())) {
+            timestamp = new File(wsdlURI).lastModified();
+        } else {
+            try {
+                timestamp = wsdlURI.toURL().openConnection().getDate();
+            } catch (Exception e) {
+                //ignore
+            }
+        }
+        
+        
         boolean doWork = cgtimestamp > doneFile.lastModified();
         if (!doneFile.exists()) {
             doWork = true;
-        } else if (file.lastModified() > doneFile.lastModified()) {
+        } else if (timestamp > doneFile.lastModified()) {
             doWork = true;
         } else if (isDefServiceName(wsdlOption)) {
             doWork = true;
@@ -306,7 +331,7 @@
                     list.add(it.next().toString());
                 }
             }
-            list.add(wsdlOption.getWsdl());
+            list.add(wsdlURI.toString());
 
             getLog().debug("Calling wsdl2java with args: " + list);
             try {



Mime
View raw message