cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r603992 - in /incubator/cxf/branches/2.0.x-fixes: ./ common/common/src/main/java/org/apache/cxf/helpers/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ systests/src/test/resources/wsdl/
Date Thu, 13 Dec 2007 19:20:53 GMT
Author: dkulp
Date: Thu Dec 13 11:20:52 2007
New Revision: 603992

URL: http://svn.apache.org/viewvc?rev=603992&view=rev
Log:
Merged revisions 602797 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r602797 | mmao | 2007-12-10 02:38:38 -0500 (Mon, 10 Dec 2007) | 5 lines
  
  CXF-1246
   CodeGen plugin support loading multiple wsdls/options/bindings from the wsdlRoot
    Only changed the systests for review
........

Added:
    incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java
      - copied unchanged from r602797, incubator/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/resources/wsdl/add_numbers-fromjava-options
      - copied unchanged from r602797, incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava-options
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
    incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=603992&r1=603991&r2=603992&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
Thu Dec 13 11:20:52 2007
@@ -20,7 +20,11 @@
 package org.apache.cxf.helpers;
 
 import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
 public final class FileUtils {
@@ -165,5 +169,104 @@
             result.deleteOnExit();
         }
         return result;
+    }
+    
+    public static String getStringFromFile(File location) {
+        InputStream is = null;
+        String result = null;
+
+        try {
+            is = new FileInputStream(location);
+            result = normalizeCRLF(is);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (Exception e) {
+                    //do nothing
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public static String normalizeCRLF(InputStream instream) {
+        BufferedReader in = new BufferedReader(new InputStreamReader(instream));
+        StringBuffer result = new StringBuffer();
+        String line = null;
+
+        try {
+            line = in.readLine();
+            while (line != null) {
+                String[] tok = line.split("\\s");
+
+                for (int x = 0; x < tok.length; x++) {
+                    String token = tok[x];
+                    result.append("  " + token);
+                }
+                line = in.readLine();
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        String rtn = result.toString();
+
+        rtn = ignoreTokens(rtn, "<!--", "-->");
+        rtn = ignoreTokens(rtn, "/*", "*/");
+        return rtn;
+    }
+    
+    private static String ignoreTokens(final String contents, 
+                                       final String startToken, final String endToken) {
+        String rtn = contents;
+        int headerIndexStart = rtn.indexOf(startToken);
+        int headerIndexEnd = rtn.indexOf(endToken);
+        if (headerIndexStart != -1 && headerIndexEnd != -1 && headerIndexStart
< headerIndexEnd) {
+            rtn = rtn.substring(0, headerIndexStart - 1)
+                + rtn.substring(headerIndexEnd + endToken.length() + 1);
+        }
+        return rtn;
+    }
+
+    public static List<File> getFiles(File dir, final String pattern) {
+        return getFiles(dir, pattern, null);
+    }
+
+    public static List<File> getFiles(File dir, final String pattern, File exclude)
{
+        File[] files =  dir.listFiles(new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    return name.matches(pattern);
+                }
+            });
+        if (files == null) {
+            return new ArrayList<File>();
+        }
+
+        List<File> fileList = new ArrayList<File>();
+        for (File file : files) {
+            if (file.equals(exclude)) {
+                continue;
+            }
+            fileList.add(file);
+        }
+        return fileList;
+    }
+
+    public static List<String> readLines(File file) throws Exception {
+        if (!file.exists()) {
+            return new ArrayList<String>();
+        }
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+        List<String> results = new ArrayList<String>();
+        String line = reader.readLine();
+        while (line != null) {
+            results.add(line);
+            line = reader.readLine();
+        }
+        return results;
     }
 }

Modified: incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java?rev=603992&r1=603991&r2=603992&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Thu Dec 13 11:20:52 2007
@@ -37,6 +37,7 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.tools.ant.ExitException;
 import org.apache.tools.ant.util.optional.NoExitSecurityManager;
+
 /**
  * @goal wsdl2java
  * @description CXF WSDL To Java Tool
@@ -73,6 +74,12 @@
     WsdlOption wsdlOptions[];
 
     /**
+     * @parameter
+     */
+    String wsdlRoot;
+
+
+    /**
      * Use the compile classpath rather than the test classpath for execution
      * useful if the test dependencies clash with those of wsdl2java
      * @parameter
@@ -89,7 +96,12 @@
 
 
         if (wsdlOptions == null) {
-            throw new MojoExecutionException("Must specify wsdlOptions");
+            List<WsdlOption> options = new WsdlOptionLoader().load(wsdlRoot);
+            wsdlOptions = options.toArray(new WsdlOption[options.size()]);
+            if (wsdlOptions == null) {
+                getLog().info("Nothing to generate");
+                return;
+            }
         }
 
         List<URL> urlList = new ArrayList<URL>();
@@ -188,8 +200,6 @@
                 }
             }
         }
-
-
 
         if (doWork) {
             doneFile.delete();

Modified: incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java?rev=603992&r1=603991&r2=603992&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
Thu Dec 13 11:20:52 2007
@@ -20,12 +20,13 @@
 package org.apache.cxf.maven_plugin;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 public class WsdlOption {
     String wsdl;
     List packagenames;
-    List extraargs;
+    List extraargs = new ArrayList();
     File dependencies[];
     File redundantDirs[];
 



Mime
View raw message