cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1213540 - in /cxf/trunk/maven-plugins/codegen-plugin: ./ src/main/java/org/apache/cxf/maven_plugin/ src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ src/main/java/org/apache/cxf/maven_plugin/wsdl2js/
Date Tue, 13 Dec 2011 02:05:35 GMT
Author: bimargulies
Date: Tue Dec 13 02:05:34 2011
New Revision: 1213540

URL: http://svn.apache.org/viewvc?rev=1213540&view=rev
Log:
CXF-3972: continued rearranging to allow both mojos to exist, with similiar option structures.

Added:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ForkOnceWSDL2Java.java
      - copied, changed from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java   (contents, props changed)
      - copied, changed from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java   (contents, props changed)
      - copied, changed from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java   (contents, props changed)
      - copied, changed from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java   (contents, props changed)
      - copied, changed from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java   (with props)
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java   (with props)
Removed:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java
Modified:
    cxf/trunk/maven-plugins/codegen-plugin/pom.xml
    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/WsdlArtifact.java

Modified: cxf/trunk/maven-plugins/codegen-plugin/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/pom.xml?rev=1213540&r1=1213539&r2=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/pom.xml (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/pom.xml Tue Dec 13 02:05:34 2011
@@ -102,6 +102,14 @@
             <artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-frontend-javascript</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-core</artifactId>

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=1213540&r1=1213539&r2=1213540&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 Dec 13 02:05:34 2011
@@ -35,6 +35,7 @@ import java.util.Set;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.cxf.Bus;
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.maven.ProjectDependenciesResolver;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -61,12 +62,7 @@ public abstract class AbstractCodegenMoh
      * @required
      */
     protected String classesDirectory;
-    /**
-     * Default options to be used when a wsdl has not had it's options explicitly specified.
-     * 
-     * @parameter
-     */
-    protected Option defaultOptions = new Option();
+   
     /**
      * By default all maven dependencies of type "wsdl" are added to the effective wsdlOptions. Setting this
      * parameter to true disables this functionality
@@ -75,9 +71,9 @@ public abstract class AbstractCodegenMoh
      */
     protected boolean disableDependencyScan;
     /**
-     * Disables the scanning of the wsdlRoot/testWsdlRoot directories configured above.
+     * Disables the scanning of the wsdlRoot/testWsdlRoot directories.
      * By default, we scan for *.wsdl (see include/exclude params as well) in the wsdlRoot
-     * directories and run wsdl2java on all the wsdl's we find.    This disables that scan
+     * directories and run the tool on all the wsdls we find. This disables that scan
      * and requires an explicit wsdlOption to be set for each wsdl that needs to be processed.
      * @parameter expression="${cxf.disableDirectoryScan}" default-value="false"
      */
@@ -129,19 +125,16 @@ public abstract class AbstractCodegenMoh
      * 
      * @parameter
      */
-    String excludes[];
+    protected String excludes[];
     /**
      * @parameter expression="${cxf.testWsdlRoot}" default-value="${basedir}/src/test/resources/wsdl"
      */
-    File testWsdlRoot;
-    /**
-     * @parameter
-     */
-    WsdlOption wsdlOptions[];
+    protected File testWsdlRoot;
+   
     /**
      * @parameter expression="${cxf.wsdlRoot}" default-value="${basedir}/src/main/resources/wsdl"
      */
-    File wsdlRoot;
+    protected File wsdlRoot;
     /**
      * Sets the JVM arguments (i.e. <code>-Xms128m -Xmx128m</code>) if fork is set to <code>true</code>.
      * 
@@ -197,12 +190,12 @@ public abstract class AbstractCodegenMoh
                 "*.wsdl"
             };
         }
-        defaultOptions.addDefaultBindingFileIfExists(project.getBasedir());
+       
         markerDirectory.mkdirs();
 
         configureProxyServerSettings();
 
-        List<WsdlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
+        List<GenericWsdlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
 
         if (effectiveWsdlOptions.size() == 0) {
             getLog().info("Nothing to generate");
@@ -219,7 +212,7 @@ public abstract class AbstractCodegenMoh
             if ("once".equals(fork) || "true".equals(fork)) {
                 forkOnce(cp, effectiveWsdlOptions);
             } else {
-                for (WsdlOption o : effectiveWsdlOptions) {
+                for (GenericWsdlOption o : effectiveWsdlOptions) {
                     bus = generate(o, bus, cp);
     
                     File dirs[] = o.getDeleteDirs();
@@ -249,7 +242,8 @@ public abstract class AbstractCodegenMoh
         System.gc();
     }
 
-    protected abstract Bus generate(WsdlOption o, Bus bus, Set<URI> cp) throws MojoExecutionException;
+    protected abstract Bus generate(GenericWsdlOption o, 
+                                    Bus bus, Set<URI> cp) throws MojoExecutionException;
 
     protected void addPluginArtifact(Set<URI> artifactsPath) {
         // for Maven 2.x, the actual artifact isn't in the list.... need to try and find it
@@ -298,40 +292,8 @@ public abstract class AbstractCodegenMoh
         }
     }
     
-    /**
-     * @return effective WsdlOptions
-     * @throws MojoExecutionException
-     */
-    protected List<WsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
-        throws MojoExecutionException {
-        List<WsdlOption> effectiveWsdlOptions = new ArrayList<WsdlOption>();
-        List<WsdlOption> temp;
-        if (wsdlRoot != null && wsdlRoot.exists() && !disableDirectoryScan) {
-            temp = WsdlOptionLoader.loadWsdlOptionsFromFiles(wsdlRoot, includes, excludes, defaultOptions,
-                                                             getGeneratedSourceRoot());
-            effectiveWsdlOptions.addAll(temp);
-        }
-        if (testWsdlRoot != null && testWsdlRoot.exists() && !disableDirectoryScan) {
-            temp = WsdlOptionLoader.loadWsdlOptionsFromFiles(testWsdlRoot, includes, excludes,
-                                                             defaultOptions, getGeneratedTestRoot());
-            effectiveWsdlOptions.addAll(temp);
-        }
-        if (!disableDependencyScan) {
-            temp = WsdlOptionLoader.loadWsdlOptionsFromDependencies(project, 
-                                                                    defaultOptions, 
-                                                                    getGeneratedSourceRoot());
-            effectiveWsdlOptions.addAll(temp);
-        }
-        mergeOptions(effectiveWsdlOptions);
-        downloadRemoteWsdls(effectiveWsdlOptions);
-        // String buildDir = project.getBuild().getDirectory();
-        // File tempBindingDir = new File(buildDir, TEMPBINDINGS_DIR);
-        // for (WsdlOption o : effectiveWsdlOptions) {
-        // BindingFileHelper.setWsdlLocationInBindingsIfNotSet(project.getBasedir(), tempBindingDir, o,
-        // getLog());
-        // }
-        return effectiveWsdlOptions;
-    }
+    protected abstract List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions() 
+        throws MojoExecutionException;
 
     /**
      * Recursively delete the given directory
@@ -354,16 +316,16 @@ public abstract class AbstractCodegenMoh
         return true;
     }
     
-    protected void forkOnce(Set<URI> classPath, List<WsdlOption> effectiveWsdlOptions)
+    protected void forkOnce(Set<URI> classPath, List<GenericWsdlOption> effectiveWsdlOptions)
         throws MojoExecutionException {
-        List<WsdlOption> toDo = new LinkedList<WsdlOption>();
+        List<GenericWsdlOption> toDo = new LinkedList<GenericWsdlOption>();
         List<List<String>> wargs = new LinkedList<List<String>>();
-        for (WsdlOption wsdlOption : effectiveWsdlOptions) {
+        for (GenericWsdlOption wsdlOption : effectiveWsdlOptions) {
             File outputDirFile = wsdlOption.getOutputDir();
             outputDirFile.mkdirs();
             URI basedir = project.getBasedir().toURI();
-            URI wsdlURI = wsdlOption.getWsdlURI(basedir);
-            File doneFile = getDoneFile(basedir, wsdlURI);
+            URI wsdlURI = getWsdlURI(wsdlOption, basedir);
+            File doneFile = getDoneFile(basedir, wsdlURI, "java");
 
             if (!shouldRun(wsdlOption, doneFile, wsdlURI)) {
                 continue;
@@ -392,9 +354,9 @@ public abstract class AbstractCodegenMoh
         artifactsPath.addAll(classPath);
 
         String args[] = createForkOnceArgs(wargs);
-        runForked(artifactsPath, ForkOnceWSDL2Java.class, args);
+        runForked(artifactsPath, getForkClass().getName(), args);
 
-        for (WsdlOption wsdlOption : toDo) {
+        for (GenericWsdlOption wsdlOption : toDo) {
             File dirs[] = wsdlOption.getDeleteDirs();
             if (dirs != null) {
                 for (int idx = 0; idx < dirs.length; ++idx) {
@@ -402,8 +364,8 @@ public abstract class AbstractCodegenMoh
                 }
             }
             URI basedir = project.getBasedir().toURI();
-            URI wsdlURI = wsdlOption.getWsdlURI(basedir);
-            File doneFile = getDoneFile(basedir, wsdlURI);
+            URI wsdlURI = getWsdlURI(wsdlOption, basedir);
+            File doneFile = getDoneFile(basedir, wsdlURI, "java");
             try {
                 doneFile.createNewFile();
             } catch (Throwable e) {
@@ -413,7 +375,9 @@ public abstract class AbstractCodegenMoh
         }
     }
     
-    protected File getDoneFile(URI basedir, URI wsdlURI) {
+    protected abstract Class<?> getForkClass();
+    
+    protected File getDoneFile(URI basedir, URI wsdlURI, String mojo) {
         String doneFileName = wsdlURI.toString();
 
         // Strip the basedir from the doneFileName
@@ -426,14 +390,16 @@ public abstract class AbstractCodegenMoh
         doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/', '_').replace('\\', '_')
             .replace(':', '_');
 
-        return new File(markerDirectory, "." + doneFileName + ".DONE");
+        return new File(markerDirectory, "." + doneFileName + "." + mojo + ".DONE");
     }
 
     protected abstract File getGeneratedSourceRoot();
 
     protected abstract File getGeneratedTestRoot();
 
-    protected void runForked(Set<URI> classPath, Class cls, String[] args) throws MojoExecutionException {
+    protected void runForked(Set<URI> classPath, 
+                             String mainClassName, 
+                             String[] args) throws MojoExecutionException {
         getLog().info("Running wsdl2java in fork mode...");
         getLog().debug("Running wsdl2java in fork mode with args " + Arrays.asList(args));
 
@@ -469,7 +435,7 @@ public abstract class AbstractCodegenMoh
 
             attr = new Attribute();
             attr.setName("Main-Class");
-            attr.setValue(cls.getName());
+            attr.setValue(mainClassName);
             manifest.getMainSection().addConfiguredAttribute(attr);
 
             jar.addConfiguredManifest(manifest);
@@ -526,7 +492,7 @@ public abstract class AbstractCodegenMoh
         }
 
     }
-
+    
     /**
      * Determine if code should be generated from the given wsdl
      * 
@@ -535,37 +501,9 @@ public abstract class AbstractCodegenMoh
      * @param wsdlURI
      * @return
      */
-    protected boolean shouldRun(WsdlOption wsdlOption, File doneFile, URI wsdlURI) {
-        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 = false;
-        if (!doneFile.exists()) {
-            doWork = true;
-        } else if (timestamp > doneFile.lastModified()) {
-            doWork = true;
-        } else if (wsdlOption.isDefServiceName()) {
-            doWork = true;
-        } else {
-            File files[] = wsdlOption.getDependencies();
-            if (files != null) {
-                for (int z = 0; z < files.length; ++z) {
-                    if (files[z].lastModified() > doneFile.lastModified()) {
-                        doWork = true;
-                    }
-                }
-            }
-        }
-        return doWork;
-    }
+    protected abstract boolean shouldRun(GenericWsdlOption wsdlOption, File doneFile, URI wsdlURI);
 
+   
     private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException {
         try {
             File f = FileUtils.createTempFile("cxf-w2j", "args");
@@ -585,11 +523,50 @@ public abstract class AbstractCodegenMoh
             throw new MojoExecutionException("Could not create argument file", ex);
         }
     }
+    
+    /**
+     * Try to find a file matching the wsdl path (either absolutely, relatively to the current dir or to
+     * the project base dir)
+     * 
+     * @return wsdl file
+     */
+    public File getWsdlFile(GenericWsdlOption option, File baseDir) {
+        if (option.getUri() == null) {
+            return null;
+        }
+        File file = null;
+        try {
+            URI uri = new URI(option.getUri());
+            if (uri.isAbsolute()) {
+                file = new File(uri);
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+        if (file == null || !file.exists()) {
+            file = new File(option.getUri());
+        }
+        if (!file.exists()) {
+            file = new File(baseDir, option.getUri());
+        }
+        return file;
+    }
+    
+    public URI getWsdlURI(GenericWsdlOption option, URI baseURI) throws MojoExecutionException {
+        String wsdlLocation = option.getUri();
+        if (wsdlLocation == null) {
+            throw new MojoExecutionException("No wsdl available for base URI " + baseURI);
+        }
+        File wsdlFile = new File(wsdlLocation);
+        return wsdlFile.exists() ? wsdlFile.toURI() 
+            : baseURI.resolve(URIParserUtil.escapeChars(wsdlLocation));
+    }
 
-    private void downloadRemoteWsdls(List<WsdlOption> effectiveWsdlOptions) throws MojoExecutionException {
+    protected void downloadRemoteWsdls(List<GenericWsdlOption> effectiveWsdlOptions) 
+        throws MojoExecutionException {
 
-        for (WsdlOption wsdlOption : effectiveWsdlOptions) {
-            WsdlArtifact wsdlA = wsdlOption.getWsdlArtifact();
+        for (GenericWsdlOption wsdlOption : effectiveWsdlOptions) {
+            WsdlArtifact wsdlA = wsdlOption.getArtifact();
             if (wsdlA == null) {
                 return;
             }
@@ -606,7 +583,7 @@ public abstract class AbstractCodegenMoh
                 }
                 String path = supposedFile.getAbsolutePath();
                 getLog().info("Resolved WSDL artifact to file " + path);
-                wsdlOption.setWsdl(path);
+                wsdlOption.setUri(path);
             }
         }
     }
@@ -625,43 +602,7 @@ public abstract class AbstractCodegenMoh
 
         return javaExe;
     }
-
-    /**
-     * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and deleting
-     * the second from the options list
-     * 
-     * @param options
-     */
-    private void mergeOptions(List<WsdlOption> effectiveWsdlOptions) {
-        if (wsdlOptions == null) {
-            return;
-        }
-        File outputDirFile = getGeneratedTestRoot() == null 
-                ? getGeneratedSourceRoot() : getGeneratedTestRoot();
-        for (WsdlOption o : wsdlOptions) {
-            if (defaultOptions != null) {
-                o.merge(defaultOptions);
-            }
-            if (o.getOutputDir() == null) {
-                o.setOutputDir(outputDirFile);
-            }
-
-            File file = o.getWsdlFile(project.getBasedir());
-            if (file != null && file.exists()) {
-                file = file.getAbsoluteFile();
-                for (WsdlOption o2 : effectiveWsdlOptions) {
-                    File file2 = o2.getWsdlFile(project.getBasedir());
-                    if (file2 != null && file2.exists() && file2.getAbsoluteFile().equals(file)) {
-                        o.getExtraargs().addAll(0, o2.getExtraargs());
-                        effectiveWsdlOptions.remove(o2);
-                        break;
-                    }
-                }
-            }
-            effectiveWsdlOptions.add(o);
-        }
-    }
-
+    
     private Artifact resolveRemoteWsdlArtifact(Artifact artifact) throws MojoExecutionException {
 
         Collection<String> scopes = new ArrayList<String>();

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin;
+
+import java.io.File;
+import java.net.URI;
+import java.util.List;
+
+/**
+ * The abstract mojo processes in terms of a list of these items.
+ */
+public interface GenericWsdlOption {
+    WsdlArtifact getArtifact();
+    void setArtifact(WsdlArtifact artifact);
+    /**
+     * Return a string pointing to the WSDL. Might be a plain path, might be a full URI.
+     * @return
+     */
+    String getUri();
+    void setUri(String uri);
+    File getOutputDir();
+    void setOutputDir(File outputDir);
+    File[] getDeleteDirs();
+    List<String> generateCommandLine(File outputDirFile, URI basedir, URI wsdlURI, boolean debug);
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/GenericWsdlOption.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java?rev=1213540&r1=1213539&r2=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java Tue Dec 13 02:05:34 2011
@@ -26,6 +26,7 @@ public class WsdlArtifact {
     private String groupId;
     private String artifactId;
     private String version;
+    private String classifier;
     private String type;
     
     public WsdlArtifact() {
@@ -57,9 +58,98 @@ public class WsdlArtifact {
         this.type = type;
     }
     
+    /**
+     * Not quite the same as equals: null in version 
+     * matches anything.
+     * @param artifact
+     * @return
+     */
     public boolean doesMatch(WsdlArtifact artifact) {
-        return type.equals(artifact.getType()) && groupId.equals(artifact.getGroupId())
+        if (!type.equals(artifact.getType())) {
+            return false;
+        }
+        if (!groupId.equals(artifact.getGroupId())) {
+            return false;
+        }
+        return ((classifier == null && artifact.classifier == null)
+                  || classifier != null && classifier.equals(artifact.classifier))
               && artifactId.equals(artifact.getArtifactId()) 
               && (version == null || version.equals(artifact.getVersion()));
     }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+    public void setClassifier(String classifier) {
+        this.classifier = classifier;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode());
+        result = prime * result + ((classifier == null) ? 0 : classifier.hashCode());
+        result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        result = prime * result + ((version == null) ? 0 : version.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        WsdlArtifact other = (WsdlArtifact)obj;
+        if (artifactId == null) {
+            if (other.artifactId != null) {
+                return false;
+            }
+        } else if (!artifactId.equals(other.artifactId)) {
+            return false;
+        }
+        if (classifier == null) {
+            if (other.classifier != null) {
+                return false;
+            }
+        } else if (!classifier.equals(other.classifier)) {
+            return false;
+        }
+        if (groupId == null) {
+            if (other.groupId != null) {
+                return false;
+            }
+        } else if (!groupId.equals(other.groupId)) {
+            return false;
+        }
+        if (type == null) {
+            if (other.type != null) {
+                return false;
+            }
+        } else if (!type.equals(other.type)) {
+            return false;
+        }
+        if (version == null) {
+            if (other.version != null) {
+                return false;
+            }
+        } else if (!version.equals(other.version)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "WsdlArtifact [groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version
+               + ", classifier=" + classifier + ", type=" + type + "]";
+    }
 }

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.maven_plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+
+public final class WsdlUtilities {
+
+    public static final String WSDL_TYPE = "wsdl";
+
+    private WsdlUtilities() {
+    }
+    
+    public static boolean fillWsdlOptionFromArtifact(GenericWsdlOption option, 
+                                                        Artifact artifact, 
+                                                        File outputDir) {
+        if (!WSDL_TYPE.equals(artifact.getType())) {
+            return false;
+        }
+        WsdlArtifact wsdlArtifact = new WsdlArtifact();
+        wsdlArtifact.setArtifactId(artifact.getArtifactId());
+        wsdlArtifact.setGroupId(artifact.getGroupId());
+        wsdlArtifact.setType(artifact.getType());
+        wsdlArtifact.setVersion(artifact.getVersion());
+        option.setArtifact(wsdlArtifact);
+        option.setOutputDir(outputDir);
+        return true;
+    }
+
+    public static String joinWithComma(String[] arr) {
+        if (arr == null) {
+            return "";
+        }
+        StringBuilder str = new StringBuilder();
+
+        if (arr != null) {
+            for (String s : arr) {
+                if (str.length() > 0) {
+                    str.append(',');
+                }
+                str.append(s);
+            }
+        }
+        return str.toString();
+    }
+
+    public static List<File> getWsdlFiles(File dir, String includes[], String excludes[])
+        throws MojoExecutionException {
+
+        List<String> exList = new ArrayList<String>();
+        if (excludes != null) {
+            exList.addAll(Arrays.asList(excludes));
+        }
+        exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
+
+        String inc = joinWithComma(includes);
+        String ex = joinWithComma(exList.toArray(new String[exList.size()]));
+
+        try {
+            List newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
+            return CastUtils.cast(newfiles);
+        } catch (IOException exc) {
+            throw new MojoExecutionException(exc.getMessage(), exc);
+        }
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ForkOnceWSDL2Java.java (from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ForkOnceWSDL2Java.java?p2=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ForkOnceWSDL2Java.java&p1=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java&r1=1213457&r2=1213540&rev=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ForkOnceWSDL2Java.java Tue Dec 13 02:05:34 2011
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.maven_plugin;
+package org.apache.cxf.maven_plugin.wsdl2java;
 
 import java.io.BufferedReader;
 import java.io.File;

Copied: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java (from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java?p2=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java&p1=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java&r1=1213457&r2=1213540&rev=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java Tue Dec 13 02:05:34 2011
@@ -17,11 +17,13 @@
  * under the License.
  */
 
-package org.apache.cxf.maven_plugin;
+package org.apache.cxf.maven_plugin.wsdl2java;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 
 public class Option {
@@ -30,7 +32,7 @@ public class Option {
 
     /**
      * As maven will set null for an empty parameter we need
-     * this horrid inital value to tell if it has been 
+     * this horrid initial value to tell if it has been 
      * configured or not yet.
      */
     private static final String DEFAULT_WSDL_LOCATION = "DEFAULTWSDLLOCATION - WORKAROUND";
@@ -82,7 +84,7 @@ public class Option {
     Boolean defaultNamespacePackageMapping;
 
     /**
-     * A set of dependent files used to detect the generator must process WSDL, even 
+     * A set of dependent files used to detect that the generator must process WSDL, even 
      * if generator marker files are up to date.
      */
     File dependencies[];
@@ -95,7 +97,7 @@ public class Option {
     /**
      * Specifies JAXWS or JAXB binding files. Use spaces to separate multiple entries.
      */
-    String bindingFiles[] = new String[0];
+    Set<String> bindingFiles = new HashSet<String>();
 
     /**
      * Specifies the value of the @WebServiceClient annotation's wsdlLocation property. 
@@ -261,17 +263,14 @@ public class Option {
         outputDir = f;
     }
     
-    public void setBindingFiles(String files[]) {
+    public void setBindingFiles(Set<String> files) {
         bindingFiles = files;
     }
-    public String[] getBindingFiles() {
+    public Set<String> getBindingFiles() {
         return bindingFiles;
     }
     public void addBindingFile(File file) {
-        String tmp[] = new String[bindingFiles.length + 1];
-        System.arraycopy(bindingFiles, 0, tmp, 0, bindingFiles.length);
-        bindingFiles = tmp;
-        bindingFiles[bindingFiles.length - 1] = file.getAbsolutePath();
+        bindingFiles.add(file.getAbsolutePath());
     }
     
     public void addDefaultBindingFileIfExists(File baseDir) {
@@ -493,7 +492,7 @@ public class Option {
         outputDir = setIfNull(outputDir, defaultOptions.outputDir);
         extraargs.addAll(defaultOptions.extraargs);
         xjcargs.addAll(defaultOptions.xjcargs);
-        bindingFiles = mergeList(bindingFiles, defaultOptions.bindingFiles, String.class);
+        bindingFiles.addAll(defaultOptions.getBindingFiles());
         dependencies = mergeList(dependencies, defaultOptions.dependencies, File.class);
         redundantDirs = mergeList(redundantDirs, defaultOptions.redundantDirs, File.class);
         packagenames.addAll(defaultOptions.packagenames);

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,288 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wsdl2java;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.maven_plugin.AbstractCodegenMoho;
+import org.apache.cxf.maven_plugin.GenericWsdlOption;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.wsdlto.WSDLToJava;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @goal wsdl2java
+ * @phase generate-sources
+ * @description CXF WSDL To Java Tool
+ * @requiresDependencyResolution test
+ * @threadSafe
+ */
+public class WSDL2JavaMojo extends AbstractCodegenMoho {
+
+    /**
+     * @parameter expression="${cxf.testSourceRoot}"
+     */
+    File testSourceRoot;
+
+    /**
+     * Path where the generated sources should be placed
+     * 
+     * @parameter expression="${cxf.sourceRoot}"
+     *            default-value="${project.build.directory}/generated-sources/cxf"
+     * @required
+     */
+    File sourceRoot;
+    
+    /**
+     * @parameter
+     */
+    WsdlOption wsdlOptions[];
+    
+    /**
+     * Default options to be used when a wsdl has not had it's options explicitly specified.
+     * 
+     * @parameter
+     */
+    Option defaultOptions = new Option();
+    
+    /**
+     * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and deleting
+     * the second from the options list
+     * 
+     * @param options
+     */
+    protected void mergeOptions(List<GenericWsdlOption> effectiveWsdlOptions) {
+
+        File outputDirFile = getGeneratedTestRoot() == null 
+                ? getGeneratedSourceRoot() : getGeneratedTestRoot();
+                
+        List<GenericWsdlOption> newList = new ArrayList<GenericWsdlOption>();
+
+        for (GenericWsdlOption go : effectiveWsdlOptions) {
+            WsdlOption o = (WsdlOption) go;
+            if (defaultOptions != null) {
+                o.merge(defaultOptions);
+            }
+            /*
+             * If not output dir at all, go for tests, and failing that, source.
+             */
+            if (o.getOutputDir() == null) {
+                o.setOutputDir(outputDirFile);
+            }
+
+            File file = o.getWsdlFile(project.getBasedir());
+            if (file != null && file.exists()) {
+                file = file.getAbsoluteFile();
+                boolean duplicate = false;
+                for (GenericWsdlOption o2w : newList) {
+                    WsdlOption o2 = (WsdlOption) o2w;
+                    File file2 = o2.getWsdlFile(project.getBasedir());
+                    if (file2 != null && file2.exists() && file2.getAbsoluteFile().equals(file)) {
+                        o2.getExtraargs().addAll(0, o.getExtraargs());
+                        duplicate = true;
+                        break;
+                    }
+                }
+                if (!duplicate) {
+                    newList.add(o);
+                }
+            }
+        }
+        effectiveWsdlOptions.clear();
+        effectiveWsdlOptions.addAll(newList);
+    }
+    
+    /**
+     * Determine if code should be generated from the given wsdl
+     * 
+     * @param wsdlOption
+     * @param doneFile
+     * @param wsdlURI
+     * @return
+     */
+    protected boolean shouldRun(GenericWsdlOption genericWsdlOption, 
+                                File doneFile, URI wsdlURI) {
+        WsdlOption wsdlOption = (WsdlOption) genericWsdlOption;
+        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 = false;
+        if (!doneFile.exists()) {
+            doWork = true;
+        } else if (timestamp > doneFile.lastModified()) {
+            doWork = true;
+        } else if (wsdlOption.isDefServiceName()) {
+            doWork = true;
+        } else {
+            File files[] = wsdlOption.getDependencies();
+            if (files != null) {
+                for (int z = 0; z < files.length; ++z) {
+                    if (files[z].lastModified() > doneFile.lastModified()) {
+                        doWork = true;
+                    }
+                }
+            }
+        }
+        return doWork;
+    }
+
+
+
+    @Override
+    protected Bus generate(GenericWsdlOption genericWsdlOption, 
+                              Bus bus,
+                              Set<URI> classPath) throws MojoExecutionException {
+        WsdlOption wsdlOption = (WsdlOption) genericWsdlOption;
+        File outputDirFile = wsdlOption.getOutputDir();
+        outputDirFile.mkdirs();
+        URI basedir = project.getBasedir().toURI();
+        URI wsdlURI = wsdlOption.getWsdlURI(basedir);
+        File doneFile = getDoneFile(basedir, wsdlURI, "java");
+
+        if (!shouldRun(wsdlOption, doneFile, wsdlURI)) {
+            return bus;
+        }
+        doneFile.delete();
+
+        List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir, wsdlURI, getLog()
+                                                           .isDebugEnabled());
+        String[] args = (String[])list.toArray(new String[list.size()]);
+        getLog().debug("Calling wsdl2java with args: " + Arrays.toString(args));
+        
+        if (!"false".equals(fork)) {
+            Set<URI> artifactsPath = new LinkedHashSet<URI>();
+            for (Artifact a : pluginArtifacts) {
+                File file = a.getFile();
+                if (file == null) {
+                    throw new MojoExecutionException("Unable to find " + file + " for artifact "
+                                                     + a.getGroupId() + ":" + a.getArtifactId()
+                                                     + ":" + a.getVersion());
+                }
+                artifactsPath.add(file.toURI());
+            }
+            addPluginArtifact(artifactsPath);
+            artifactsPath.addAll(classPath);
+            
+            runForked(artifactsPath, WSDLToJava.class.getName(), args);
+
+        } else {
+            if (bus == null) {
+                bus = BusFactory.newInstance().createBus();
+                BusFactory.setThreadDefaultBus(bus);
+            }
+            try {
+                new WSDLToJava(args).run(new ToolContext());
+            } catch (Throwable e) {
+                getLog().debug(e);
+                throw new MojoExecutionException(e.getMessage(), e);
+            }  
+        }
+        
+
+        try {
+            doneFile.createNewFile();
+        } catch (Throwable e) {
+            getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+            getLog().debug(e);
+            throw new MojoExecutionException("Failed to create marker file " + doneFile.getAbsolutePath());
+        }
+        if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists()) {
+            project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
+        }
+        if (project != null && getGeneratedTestRoot() != null && getGeneratedTestRoot().exists()) {
+            project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
+        }
+        return bus;
+    }
+    
+    /**
+     * @return effective WsdlOptions
+     * @throws MojoExecutionException
+     */
+    protected List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
+        throws MojoExecutionException {
+        List<GenericWsdlOption> effectiveWsdlOptions = new ArrayList<GenericWsdlOption>();
+        
+        if (wsdlOptions != null) {
+            for (WsdlOption wo : wsdlOptions) {
+                effectiveWsdlOptions.add(wo);
+            }
+        }
+        
+        List<GenericWsdlOption> temp;
+        if (wsdlRoot != null && wsdlRoot.exists() && !disableDirectoryScan) {
+            temp = WsdlOptionLoader.loadWsdlOptionsFromFiles(wsdlRoot, includes, excludes, defaultOptions,
+                                                             getGeneratedSourceRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        if (testWsdlRoot != null && testWsdlRoot.exists() && !disableDirectoryScan) {
+            temp = WsdlOptionLoader.loadWsdlOptionsFromFiles(testWsdlRoot, includes, excludes,
+                                                             defaultOptions, getGeneratedTestRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        if (!disableDependencyScan) {
+            temp = WsdlOptionLoader.loadWsdlOptionsFromDependencies(project, 
+                                                                    defaultOptions, 
+                                                                    getGeneratedSourceRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        downloadRemoteWsdls(effectiveWsdlOptions);
+        mergeOptions(effectiveWsdlOptions);
+        return effectiveWsdlOptions;
+    }
+
+    @Override
+    protected File getGeneratedSourceRoot() {
+        return sourceRoot;
+    }
+
+    @Override
+    protected File getGeneratedTestRoot() {
+        return testSourceRoot;
+    }
+
+    @Override
+    protected Class<?> getForkClass() {
+        return ForkOnceWSDL2Java.class;
+    }
+
+    @Override
+    public void execute() throws MojoExecutionException {
+        defaultOptions.addDefaultBindingFileIfExists(project.getBasedir());
+        super.execute();
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wsdl2java;
+
+/**
+ * THis exists to move this into the same package as the mojo.
+ */
+public class WsdlArtifact extends org.apache.cxf.maven_plugin.WsdlArtifact {
+
+    public WsdlArtifact() {
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java (from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java?p2=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java&p1=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java&r1=1213457&r2=1213540&rev=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java Tue Dec 13 02:05:34 2011
@@ -17,18 +17,19 @@
  * under the License.
  */
 
-package org.apache.cxf.maven_plugin;
+package org.apache.cxf.maven_plugin.wsdl2java;
 
 import java.io.File;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.cxf.maven_plugin.WsdlArtifact;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.maven.plugin.MojoExecutionException;
 
-public class WsdlOption extends Option {
+public class WsdlOption extends Option implements org.apache.cxf.maven_plugin.GenericWsdlOption {
 
     /**
      * The WSDL file to process.
@@ -51,6 +52,10 @@ public class WsdlOption extends Option {
     public WsdlArtifact getWsdlArtifact() {
         return wsdlArtifact;
     }
+    
+    public void setArtifact(WsdlArtifact artifact) {
+        wsdlArtifact = artifact;
+    }
 
     public void setWsdlArtifact(WsdlArtifact wsdlArtifact) {
         this.wsdlArtifact = wsdlArtifact;
@@ -110,6 +115,8 @@ public class WsdlOption extends Option {
     public int hashCode() {
         if (wsdl != null) {
             return wsdl.hashCode();
+        } else if (wsdlArtifact != null) {
+            return wsdlArtifact.hashCode();
         }
         return -1;
     }
@@ -130,6 +137,9 @@ public class WsdlOption extends Option {
         builder.append("Extraargs: ").append(extraargs).append('\n');
         builder.append("XJCargs: ").append(xjcargs).append('\n');
         builder.append("Packagenames: ").append(packagenames).append('\n');
+        if (wsdlArtifact != null) {
+            builder.append("Artifact: ").append(wsdlArtifact.toString()).append('\n');
+        }
         builder.append('\n');
         return builder.toString();
     }
@@ -235,4 +245,15 @@ public class WsdlOption extends Option {
         destList.add(b.toString());
     }
 
+    public WsdlArtifact getArtifact() {
+        return wsdlArtifact;
+    }
+
+    public String getUri() {
+        return wsdl;
+    }
+
+    public void setUri(String uri) {
+        wsdl = uri;
+    }
 }

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java (from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java?p2=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java&p1=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java&r1=1213457&r2=1213540&rev=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOptionLoader.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java Tue Dec 13 02:05:34 2011
@@ -17,34 +17,36 @@
  * under the License.
  */
 
-package org.apache.cxf.maven_plugin;
+package org.apache.cxf.maven_plugin.wsdl2java;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.maven_plugin.GenericWsdlOption;
+import org.apache.cxf.maven_plugin.WsdlUtilities;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 
 public final class WsdlOptionLoader {
-    private static final String WSDL_TYPE = "wsdl";
     private static final String WSDL_OPTIONS = "-options$";
     private static final String WSDL_BINDINGS = "-binding-?\\d*.xml$";
     
     private WsdlOptionLoader() {
     }
     
-    @SuppressWarnings("unchecked")
-    public static List<WsdlOption> loadWsdlOptionsFromDependencies(MavenProject project, 
-                                                                   Option defaultOptions, File outputDir) {
-        List<WsdlOption> options = new ArrayList<WsdlOption>();
-        Set<Artifact> dependencies = project.getDependencyArtifacts();
+    public static List<GenericWsdlOption> 
+    loadWsdlOptionsFromDependencies(MavenProject project, 
+                                    Option defaultOptions, 
+                                    File outputDir) {
+        List<GenericWsdlOption> options = new ArrayList<GenericWsdlOption>();
+        Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
         for (Artifact artifact : dependencies) {
             WsdlOption option = generateWsdlOptionFromArtifact(artifact, outputDir);
             if (option != null) {
@@ -58,18 +60,12 @@ public final class WsdlOptionLoader {
     }
 
     private static WsdlOption generateWsdlOptionFromArtifact(Artifact artifact, File outputDir) {
-        if (!WSDL_TYPE.equals(artifact.getType())) {
+        WsdlOption option = new WsdlOption();
+        if (WsdlUtilities.fillWsdlOptionFromArtifact(option, artifact, outputDir)) {
+            return option;
+        } else {
             return null;
         }
-        WsdlOption option = new WsdlOption();
-        WsdlArtifact wsdlArtifact = new WsdlArtifact();
-        wsdlArtifact.setArtifactId(artifact.getArtifactId());
-        wsdlArtifact.setGroupId(artifact.getGroupId());
-        wsdlArtifact.setType(artifact.getType());
-        wsdlArtifact.setVersion(artifact.getVersion());
-        option.setWsdlArtifact(wsdlArtifact);
-        option.setOutputDir(outputDir);
-        return option;
     }
 
     /**
@@ -84,21 +80,23 @@ public final class WsdlOptionLoader {
      * @return list of one WsdlOption object for each wsdl found
      * @throws MojoExecutionException
      */
-    public static List<WsdlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, String includes[],
-                                                            String excludes[], Option defaultOptions,
-                                                            File defaultOutputDir)
+    public static List<GenericWsdlOption> 
+    loadWsdlOptionsFromFiles(File wsdlBasedir, String includes[],
+                                 String excludes[], Option defaultOptions,
+                                 File defaultOutputDir)
         throws MojoExecutionException {
 
         if (wsdlBasedir == null) {
-            return new ArrayList<WsdlOption>();
+            return Collections.emptyList();
         }
 
         if (!wsdlBasedir.exists()) {
             throw new MojoExecutionException(wsdlBasedir + " does not exist");
         }
 
-        List<File> wsdlFiles = getWsdlFiles(wsdlBasedir, includes, excludes);
-        List<WsdlOption> wsdlOptions = new ArrayList<WsdlOption>();
+        List<File> wsdlFiles = WsdlUtilities.getWsdlFiles(wsdlBasedir, includes, excludes);
+        List<GenericWsdlOption> wsdlOptions 
+            = new ArrayList<GenericWsdlOption>();
         for (File wsdl : wsdlFiles) {
             WsdlOption wsdlOption = generateWsdlOptionFromFile(wsdl, defaultOptions, defaultOutputDir);
             if (wsdlOption != null) {
@@ -108,43 +106,6 @@ public final class WsdlOptionLoader {
         return wsdlOptions;
     }
 
-    private static String joinWithComma(String[] arr) {
-        if (arr == null) {
-            return "";
-        }
-        StringBuilder str = new StringBuilder();
-
-        if (arr != null) {
-            for (String s : arr) {
-                if (str.length() > 0) {
-                    str.append(',');
-                }
-                str.append(s);
-            }
-        }
-        return str.toString();
-    }
-
-    private static List<File> getWsdlFiles(File dir, String includes[], String excludes[])
-        throws MojoExecutionException {
-
-        List<String> exList = new ArrayList<String>();
-        if (excludes != null) {
-            exList.addAll(Arrays.asList(excludes));
-        }
-        exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
-
-        String inc = joinWithComma(includes);
-        String ex = joinWithComma(exList.toArray(new String[exList.size()]));
-
-        try {
-            List newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
-            return CastUtils.cast(newfiles);
-        } catch (IOException exc) {
-            throw new MojoExecutionException(exc.getMessage(), exc);
-        }
-    }
-
     private static String[] readOptionsFromFile(File dir, String wsdlName) throws MojoExecutionException {
         String[] noOptions = new String[] {};
         List<File> files = FileUtils.getFiles(dir, wsdlName + WSDL_OPTIONS);
@@ -167,7 +128,8 @@ public final class WsdlOptionLoader {
         }
     }
 
-    protected static WsdlOption generateWsdlOptionFromFile(final File wsdl, final Option defaultOptions,
+    protected static WsdlOption generateWsdlOptionFromFile(final File wsdl, 
+                                                           final Option defaultOptions,
                                                            File defaultOutputDir)
         throws MojoExecutionException {
 

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java (from r1213457, cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java?p2=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java&p1=cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java&r1=1213457&r2=1213540&rev=1213540&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ForkOnceWSDL2Java.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java Tue Dec 13 02:05:34 2011
@@ -17,20 +17,20 @@
  * under the License.
  */
 
-package org.apache.cxf.maven_plugin;
+package org.apache.cxf.maven_plugin.wsdl2js;
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 
 import org.apache.cxf.tools.common.ToolContext;
-import org.apache.cxf.tools.wsdlto.WSDLToJava;
+import org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript;
 
 /**
  * 
  */
-public final class ForkOnceWSDL2Java {
-    private ForkOnceWSDL2Java() {
+public final class ForkOnceWSDL2Javascript {
+    private ForkOnceWSDL2Javascript() {
         //utility
     }
     public static void main(String args[]) throws Exception {
@@ -47,7 +47,7 @@ public final class ForkOnceWSDL2Java {
                 wargs[x] = reader.readLine();
             }
             
-            new WSDLToJava(wargs).run(new ToolContext());
+            new WSDLToJavaScript(wargs).run(new ToolContext());
             
             line = reader.readLine();
         }

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ForkOnceWSDL2Javascript.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.maven_plugin.wsdl2js;
+
+import java.io.File;
+
+public class Option {
+
+    /**
+     * Since an arbitrary URI can't be an XML element name,
+     * these pairs are used to specify a mapping from URI
+     * to prefix.
+     */
+    public static class UriPrefixPair {
+        /**
+         * The namespace URI.
+         */
+        String uri;
+        /**
+         * The identifier prefix.
+         */
+        String prefix;
+        /**
+         * @return the uri
+         */
+        public String getUri() {
+            return uri;
+        }
+        /**
+         * Set the URI.
+         * @param uri the uri.
+         */
+        public void setUri(String uri) {
+            this.uri = uri;
+        }
+        /**
+         * @return the prefix.
+         */
+        public String getPrefix() {
+            return prefix;
+        }
+        /**
+         * Set the prefix.
+         * @param prefix the prefix.
+         */
+        public void setPrefix(String prefix) {
+            this.prefix = prefix;
+        }
+    
+    }
+
+    /**
+     * mappings from namespace URIs to javascript identifier prefixes.
+     */
+    UriPrefixPair[] packagePrefixes;
+    /**
+     * OASIS catalog file for use when reading the WSDL. 
+     */
+    File catalog;
+    /**
+     * Destination directory for the output.
+     */
+    File output;
+    /**
+     * Whether to validate the WSDL. 
+     */
+    Boolean validate;
+    /**
+     * The wsdl version.
+     */
+    String wsdlVersion;
+    /**
+     * A set of dependent files used to detect that the generator must process WSDL, even 
+     * if generator marker files are up to date.
+     */
+    File dependencies[];
+
+    public Option() {
+    }
+    
+    public void merge(Option other) {
+        if (catalog == null) {
+            catalog = other.getCatalog();
+        }
+        if (output == null) {
+            output = other.getOutput();
+        }
+        if (validate == null) {
+            validate = other.isValidate();
+        }
+        if (wsdlVersion == null) {
+            wsdlVersion = other.getWsdlVersion();
+        }
+    }
+
+    /**
+     * @return mappings from namespace URI to javascript name prefix.
+     */
+    public UriPrefixPair[] getPackagePrefixes() {
+        return packagePrefixes;
+    }
+
+    /**
+     * Set the mappings from namespace URI to Javascript name prefixes.
+     * @param packagePrefixes
+     */
+    public void setPackagePrefixes(UriPrefixPair[] packagePrefixes) {
+        this.packagePrefixes = packagePrefixes;
+    }
+
+    /**
+     * @return catalog used to resolve XML URIs in the wsdl.
+     */
+    public File getCatalog() {
+        return catalog;
+    }
+
+    /**
+     * Set catalog used to resolve XML URIs in the wsdl.
+     * @param catalog catalog.
+     */
+    public void setCatalog(File catalog) {
+        this.catalog = catalog;
+    }
+
+    /**
+     * @return output directory. Default is set 
+     * at the plugin level.
+     */
+    public File getOutput() {
+        return output;
+    }
+
+    /**
+     * Set the output directory.
+     * @param output output directory.
+     */
+    public void setOutput(File output) {
+        this.output = output;
+    }
+
+    /**
+     * @return Validating the WSDL?
+     */
+    public boolean isValidate() {
+        return validate;
+    }
+
+    /**
+     * Control WSDL validation.
+     * @param validate true to validate.
+     */
+    public void setValidate(boolean validate) {
+        this.validate = validate;
+    }
+
+    public File getOutputDir() {
+        return output;
+    }
+
+    public void setOutputDir(File outputDir) {
+        output = outputDir;
+    }
+
+    public String getWsdlVersion() {
+        return wsdlVersion;
+    }
+
+    public void setWsdlVersion(String wsdlVersion) {
+        this.wsdlVersion = wsdlVersion;
+    }
+
+    public File[] getDependencies() {
+        return dependencies;
+    }
+
+    public void setDependencies(File[] dependencies) {
+        this.dependencies = dependencies;
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,282 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wsdl2js;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.maven_plugin.AbstractCodegenMoho;
+import org.apache.cxf.maven_plugin.GenericWsdlOption;
+import org.apache.cxf.maven_plugin.WsdlUtilities;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @goal wsdl2js
+ * @phase generate-sources
+ * @description CXF WSDL To JavaScript Tool
+ * @requiresDependencyResolution test
+ * @threadSafe
+ */
+public class WSDL2JavaScriptMojo extends AbstractCodegenMoho {
+
+    /**
+     * WSDL files to process. Each wsdl file is specified as an option element, with possible options.
+     * 
+     * @parameter
+     * @required
+     */
+    WsdlOption[] wsdls;
+
+    /**
+     * @parameter expression="${cxf.testJavascriptRoot}"
+     */
+    File testSourceRoot;
+
+    /**
+     * Path where the generated sources should be placed
+     * 
+     * @parameter expression="${cxf.sourceJavascriptRoot}"
+     *            default-value="${project.build.directory}/generated-sources/cxf-js"
+     * @required
+     */
+    File sourceRoot;
+
+    /**
+     * Default options to be applied to all of the wsdls.
+     * 
+     * @parameter
+     */
+    Option defaultOptions;
+    
+    /**
+     * @parameter
+     */
+    WsdlOption wsdlOptions[];
+
+    @Override
+    protected Bus generate(GenericWsdlOption genericWsdlOption, 
+                           Bus bus, Set<URI> classPath)
+        throws MojoExecutionException {
+
+        WsdlOption wsdlOption = (WsdlOption)genericWsdlOption;
+        File outputDirFile = wsdlOption.getOutputDir();
+        outputDirFile.mkdirs();
+        URI basedir = project.getBasedir().toURI();
+        URI wsdlURI;
+        try {
+            wsdlURI = new URI(wsdlOption.getUri());
+        } catch (URISyntaxException e) {
+            throw new MojoExecutionException("Failed to get URI for wsdl " + wsdlOption.getUri(), e);
+        }
+        File doneFile = getDoneFile(basedir, wsdlURI, "js");
+
+        if (!shouldRun(wsdlOption, doneFile, wsdlURI)) {
+            return bus;
+        }
+        doneFile.delete();
+
+        List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir, wsdlURI, getLog()
+            .isDebugEnabled());
+        String[] args = (String[])list.toArray(new String[list.size()]);
+        getLog().debug("Calling wsdl2js with args: " + Arrays.toString(args));
+
+        if (!"false".equals(fork)) {
+            Set<URI> artifactsPath = new LinkedHashSet<URI>();
+            for (Artifact a : pluginArtifacts) {
+                File file = a.getFile();
+                if (file == null) {
+                    throw new MojoExecutionException("Unable to find " + file + " for artifact "
+                                                     + a.getGroupId() + ":" + a.getArtifactId() + ":"
+                                                     + a.getVersion());
+                }
+                artifactsPath.add(file.toURI());
+            }
+            addPluginArtifact(artifactsPath);
+            artifactsPath.addAll(classPath);
+
+            runForked(artifactsPath, WSDLToJavaScript.class.getName(), args);
+
+        } else {
+            if (bus == null) {
+                bus = BusFactory.newInstance().createBus();
+                BusFactory.setThreadDefaultBus(bus);
+            }
+            try {
+                new WSDLToJavaScript(args).run(new ToolContext());
+            } catch (Throwable e) {
+                getLog().debug(e);
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+
+        try {
+            doneFile.createNewFile();
+        } catch (Throwable e) {
+            getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+            getLog().debug(e);
+            throw new MojoExecutionException("Failed to create marker file " + doneFile.getAbsolutePath());
+        }
+        if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists()) {
+            project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
+        }
+        if (project != null && getGeneratedTestRoot() != null && getGeneratedTestRoot().exists()) {
+            project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
+        }
+        return bus;
+    }
+
+    @Override
+    protected File getGeneratedSourceRoot() {
+        return sourceRoot;
+    }
+
+    @Override
+    protected File getGeneratedTestRoot() {
+        return testSourceRoot;
+    }
+
+    @Override
+    protected boolean shouldRun(GenericWsdlOption genericWsdlOption, File doneFile,
+                                URI wsdlURI) {
+        WsdlOption wsdlOption = (WsdlOption)genericWsdlOption;
+        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 = false;
+        if (!doneFile.exists()) {
+            doWork = true;
+        } else if (timestamp > doneFile.lastModified()) {
+            doWork = true;
+        } else {
+            File files[] = wsdlOption.getDependencies();
+            if (files != null) {
+                for (int z = 0; z < files.length; ++z) {
+                    if (files[z].lastModified() > doneFile.lastModified()) {
+                        doWork = true;
+                    }
+                }
+            }
+        }
+        return doWork;
+    }
+
+    protected void mergeOptions(List<GenericWsdlOption> effectiveWsdlOptions) {
+        for (GenericWsdlOption wo : wsdls) {
+            WsdlOption option = (WsdlOption)wo;
+            option.merge(defaultOptions);
+        }
+    }
+
+    @Override
+    protected List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
+        throws MojoExecutionException {
+        List<GenericWsdlOption> effectiveWsdlOptions = new ArrayList<GenericWsdlOption>();
+        List<GenericWsdlOption> temp;
+        
+        for (WsdlOption wo : wsdlOptions) {
+            effectiveWsdlOptions.add(wo);
+        }
+        
+        if (wsdlRoot != null && wsdlRoot.exists() && !disableDirectoryScan) {
+            temp = loadWsdlOptionsFromFiles(wsdlRoot, getGeneratedSourceRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        if (testWsdlRoot != null && testWsdlRoot.exists() && !disableDirectoryScan) {
+            temp = loadWsdlOptionsFromFiles(testWsdlRoot, getGeneratedTestRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        if (!disableDependencyScan) {
+            temp = loadWsdlOptionsFromDependencies(project, defaultOptions, getGeneratedSourceRoot());
+            effectiveWsdlOptions.addAll(temp);
+        }
+        mergeOptions(effectiveWsdlOptions);
+        downloadRemoteWsdls(effectiveWsdlOptions);
+        return effectiveWsdlOptions;
+    }
+
+    private List<GenericWsdlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, File defaultOutputDir)
+        throws MojoExecutionException {
+
+        if (wsdlBasedir == null) {
+            return Collections.emptyList();
+        }
+
+        if (!wsdlBasedir.exists()) {
+            throw new MojoExecutionException(wsdlBasedir + " does not exist");
+        }
+
+        List<File> wsdlFiles = WsdlUtilities.getWsdlFiles(wsdlBasedir, includes, excludes);
+        List<GenericWsdlOption> options = new ArrayList<GenericWsdlOption>();
+        for (File wsdl : wsdlFiles) {
+            WsdlOption wsdlOption = new WsdlOption();
+            wsdlOption.setOutputDir(defaultOutputDir);
+            wsdlOption.setUri(wsdl.toURI().toString());
+            options.add(wsdlOption);
+        }
+        return options;
+    }
+
+    public static List<GenericWsdlOption> 
+    loadWsdlOptionsFromDependencies(MavenProject project,
+                                    Option defaultOptions,
+                                    File outputDir) {
+        List<GenericWsdlOption> options 
+            = new ArrayList<GenericWsdlOption>();
+        Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
+        for (Artifact artifact : dependencies) {
+            WsdlOption option = new WsdlOption();
+            WsdlUtilities.fillWsdlOptionFromArtifact(new WsdlOption(), artifact, outputDir);
+            if (option != null) {
+                if (defaultOptions != null) {
+                    option.merge(defaultOptions);
+                }
+                options.add(option);
+            }
+        }
+        return options;
+    }
+
+    @Override
+    protected Class<?> getForkClass() {
+        return ForkOnceWSDL2Javascript.class;
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wsdl2js;
+
+/**
+ * This exists to move this into the same package as the mojo.
+ */
+public class WsdlArtifact extends org.apache.cxf.maven_plugin.WsdlArtifact {
+
+    public WsdlArtifact() {
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java?rev=1213540&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java (added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java Tue Dec 13 02:05:34 2011
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wsdl2js;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.maven_plugin.WsdlArtifact;
+
+/**
+ * An option for javascript generation.
+ */
+public class WsdlOption extends Option implements org.apache.cxf.maven_plugin.GenericWsdlOption {
+    
+    private String wsdl;
+    private WsdlArtifact artifact;
+    
+    /**
+     * @return Pathname or URI to wsdl.
+     */
+    public String getWsdl() {
+        return wsdl;
+    }
+    
+    /**
+     * Set pathname or URI to WSDL.
+     * @param wsdl path.
+     */
+    public void setWsdl(String wsdl) {
+        this.wsdl = wsdl;
+    }
+    
+    /**
+     * Maven coordinates 
+     * @return
+     */
+    public WsdlArtifact getArtifact() {
+        return artifact;
+    }
+    public void setArtifact(WsdlArtifact artifact) {
+        this.artifact = artifact;
+    }
+
+    public String getUri() {
+        return wsdl;
+    }
+
+    public void setUri(String uri) {
+        this.wsdl = uri;
+    }
+
+    public File[] getDeleteDirs() {
+        /*
+         * Until we figure out what this amounts to. I suspect it stays null for Javascript.
+         */
+        return new File[0];
+    }
+
+    public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wsdlURI, boolean debug) {
+        List<String> options = new ArrayList<String>();
+        if (wsdlVersion != null && !"".equals(wsdlVersion)) {
+            options.add("-wv");
+            options.add(wsdlVersion);
+        }
+        if (packagePrefixes != null) {
+            for (UriPrefixPair upp : packagePrefixes) {
+                options.add("-p");
+                options.add(String.format("%s=%s", upp.getPrefix(), upp.getUri()));
+            }
+        }
+        if (catalog != null && !"".equals(catalog)) {
+            options.add("-catalog");
+            options.add(catalog.getAbsolutePath());
+        }
+        
+        options.add("-d");
+        if (output != null) {
+            options.add(output.getAbsolutePath());
+        } else {
+            options.add(outputDirFile.getAbsolutePath());
+        }
+        if (validate != null && validate) {
+            options.add("-validate");
+        }
+        if (debug) {
+            options.add("-v");
+            options.add("-V");
+        }
+        /*
+         * By the time we get here there's supposed to be a string
+         * in 'wsdl' that we can use as the uri.
+         */
+        options.add(wsdl);
+        return options;
+    } 
+}

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message