cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1335709 - /cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
Date Tue, 08 May 2012 19:34:00 GMT
Author: dkulp
Date: Tue May  8 19:34:00 2012
New Revision: 1335709

URL: http://svn.apache.org/viewvc?rev=1335709&view=rev
Log:
Add an NPE guard

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

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java?rev=1335709&r1=1335708&r2=1335709&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
Tue May  8 19:34:00 2012
@@ -58,7 +58,7 @@ public class WSDL2JavaMojo extends Abstr
      * @required
      */
     File sourceRoot;
-    
+
     /**
      * Options that specify WSDLs to process and/or control the processing of wsdls. 
      * If you have enabled wsdl scanning, these elements attach options to particular wsdls.
@@ -66,21 +66,21 @@ public class WSDL2JavaMojo extends Abstr
      * @parameter
      */
     WsdlOption wsdlOptions[];
-    
+
     /**
      * Default options to be used when a wsdl has not had it's options explicitly specified.
      * 
      * @parameter
      */
     Option defaultOptions = new Option();
-    
+
     /**
      * Encoding to use for generated sources
      * 
      * @parameter default-value="${project.build.sourceEncoding}"
      */
     String encoding;
-    
+
     /**
      * Merge WsdlOptions that point to the same file by adding the extraargs to the first
option and deleting
      * the second from the options list
@@ -90,8 +90,8 @@ public class WSDL2JavaMojo extends Abstr
     protected void mergeOptions(List<GenericWsdlOption> effectiveWsdlOptions) {
 
         File outputDirFile = getGeneratedTestRoot() == null 
-                ? getGeneratedSourceRoot() : getGeneratedTestRoot();
-                
+                             ? getGeneratedSourceRoot() : getGeneratedTestRoot();
+
         List<GenericWsdlOption> newList = new ArrayList<GenericWsdlOption>();
 
         for (GenericWsdlOption go : effectiveWsdlOptions) {
@@ -129,7 +129,7 @@ public class WSDL2JavaMojo extends Abstr
         effectiveWsdlOptions.clear();
         effectiveWsdlOptions.addAll(newList);
     }
-    
+
     /**
      * Determine if code should be generated from the given wsdl
      * 
@@ -170,9 +170,9 @@ public class WSDL2JavaMojo extends Abstr
         }
         return doWork;
     }
-    
+
     protected List<String> generateCommandLine(GenericWsdlOption wsdlOption)
-        throws MojoExecutionException {
+    throws MojoExecutionException {
         List<String> ret = super.generateCommandLine(wsdlOption);
         if (encoding != null) {
             ret.add(0, "-encoding");
@@ -183,8 +183,8 @@ public class WSDL2JavaMojo extends Abstr
 
     @Override
     protected Bus generate(GenericWsdlOption genericWsdlOption, 
-                              Bus bus,
-                              Set<URI> classPath) throws MojoExecutionException {
+                           Bus bus,
+                           Set<URI> classPath) throws MojoExecutionException {
         WsdlOption wsdlOption = (WsdlOption) genericWsdlOption;
         File outputDirFile = wsdlOption.getOutputDir();
         outputDirFile.mkdirs();
@@ -199,11 +199,13 @@ public class WSDL2JavaMojo extends Abstr
 
         List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir,
wsdlURI, 
                                                            getLog().isDebugEnabled());
-        list.add(0, "-encoding");
-        list.add(1, encoding);
+        if (encoding != null) {
+            list.add(0, "-encoding");
+            list.add(1, encoding);
+        }
         String[] args = 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) {
@@ -217,7 +219,7 @@ public class WSDL2JavaMojo extends Abstr
             }
             addPluginArtifact(artifactsPath);
             artifactsPath.addAll(classPath);
-            
+
             runForked(artifactsPath, WSDLToJava.class.getName(), args);
 
         } else {
@@ -230,9 +232,9 @@ public class WSDL2JavaMojo extends Abstr
             } catch (Throwable e) {
                 getLog().debug(e);
                 throw new MojoExecutionException(e.getMessage(), e);
-            }  
+            }
         }
-        
+
 
         try {
             doneFile.createNewFile();
@@ -249,21 +251,21 @@ public class WSDL2JavaMojo extends Abstr
         }
         return bus;
     }
-    
+
     /**
      * @return effective WsdlOptions
      * @throws MojoExecutionException
      */
     protected List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
-        throws MojoExecutionException {
+    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,



Mime
View raw message