cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1080351 - in /cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin: ClassLoaderSwitcher.java WSDL2JavaMojo.java
Date Thu, 10 Mar 2011 21:17:28 GMT
Author: dkulp
Date: Thu Mar 10 21:17:28 2011
New Revision: 1080351

URL: http://svn.apache.org/viewvc?rev=1080351&view=rev
Log:
Remove duplicates from classpath

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

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java?rev=1080351&r1=1080350&r2=1080351&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
Thu Mar 10 21:17:28 2011
@@ -25,8 +25,10 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.maven.artifact.Artifact;
@@ -55,12 +57,12 @@ public class ClassLoaderSwitcher {
      * @param useCompileClasspath
      * @param classesDir
      */
-    public String switchClassLoader(MavenProject project,
-                                     boolean useCompileClasspath,
-                                     File classesDir) {
+    public Set<String> switchClassLoader(MavenProject project,
+                                         boolean useCompileClasspath,
+                                         File classesDir) {
         List<URL> urlList = new ArrayList<URL>();
         StringBuilder buf = new StringBuilder();
-
+        Set<String> ret = new LinkedHashSet<String>();
         
         try {
             urlList.add(classesDir.toURI().toURL());
@@ -72,9 +74,11 @@ public class ClassLoaderSwitcher {
         }
 
         buf.append(classesDir.getAbsolutePath());
+        ret.add(classesDir.getAbsolutePath());
         buf.append(File.pathSeparatorChar);
         if (!useCompileClasspath) {
             buf.append(project.getBuild().getOutputDirectory());
+            ret.add(project.getBuild().getOutputDirectory());
             buf.append(File.pathSeparatorChar);
         }
         List<?> artifacts = useCompileClasspath ? project.getCompileArtifacts() : project.getTestArtifacts();
@@ -83,6 +87,7 @@ public class ClassLoaderSwitcher {
                 if (a.getFile() != null && a.getFile().exists()) {
                     urlList.add(a.getFile().toURI().toURL());
                     buf.append(a.getFile().getAbsolutePath());
+                    ret.add(a.getFile().getAbsolutePath());
                     buf.append(File.pathSeparatorChar);
                     // System.out.println("     " +
                     // a.getFile().getAbsolutePath());
@@ -105,7 +110,7 @@ public class ClassLoaderSwitcher {
 
         Thread.currentThread().setContextClassLoader(loader);
         System.setProperty("java.class.path", newCp);
-        return newCp;
+        return ret;
     }
 
     /**

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java?rev=1080351&r1=1080350&r2=1080351&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Thu Mar 10 21:17:28 2011
@@ -27,6 +27,7 @@ import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -399,7 +400,7 @@ public class WSDL2JavaMojo extends Abstr
 
         Bus bus = null;
         try {
-            String cp = classLoaderSwitcher.switchClassLoader(project, useCompileClasspath,
classesDir);
+            Set<String> cp = classLoaderSwitcher.switchClassLoader(project, useCompileClasspath,
classesDir);
 
             if ("once".equals(fork) || "true".equals(fork)) {
                 forkOnce(cp, effectiveWsdlOptions);
@@ -432,7 +433,7 @@ public class WSDL2JavaMojo extends Abstr
         System.gc();
     }
     
-    private void addPluginArtifact(List<String> artifactsPath) {
+    private void addPluginArtifact(Set<String> artifactsPath) {
         //for Maven 2.x, the actual artifact isn't in the list....  need to try and find
it
         URL url = getClass().getResource(getClass().getSimpleName() + ".class");
         
@@ -461,7 +462,7 @@ public class WSDL2JavaMojo extends Abstr
 
     }
 
-    private void forkOnce(String classPath, List<WsdlOption> effectiveWsdlOptions)

+    private void forkOnce(Set<String> classPath, List<WsdlOption> effectiveWsdlOptions)

         throws MojoExecutionException {
         List<WsdlOption> toDo = new LinkedList<WsdlOption>();
         List<List<String>> wargs = new LinkedList<List<String>>();
@@ -486,7 +487,7 @@ public class WSDL2JavaMojo extends Abstr
             return;
         }
         
-        List<String> artifactsPath = new ArrayList<String>(pluginArtifacts.size());
+        Set<String> artifactsPath = new LinkedHashSet<String>();
         for (Artifact a : pluginArtifacts) {
             File file = a.getFile();
             if (file == null) {
@@ -497,12 +498,12 @@ public class WSDL2JavaMojo extends Abstr
             artifactsPath.add(file.getPath());
         }
         addPluginArtifact(artifactsPath);
+        artifactsPath.addAll(classPath);
         
-        classPath = StringUtils.join(artifactsPath.iterator(), File.pathSeparator) 
-            + File.pathSeparator + classPath;
+        String cp = StringUtils.join(artifactsPath.iterator(), File.pathSeparator);
         
         String args[] = createForkOnceArgs(wargs);
-        runForked(classPath, ForkOnceWSDL2Java.class, args);
+        runForked(cp, ForkOnceWSDL2Java.class, args);
         
         for (WsdlOption wsdlOption : toDo) {
             File dirs[] = wsdlOption.getDeleteDirs();
@@ -543,7 +544,7 @@ public class WSDL2JavaMojo extends Abstr
 
     private Bus callWsdl2Java(WsdlOption wsdlOption, 
                               Bus bus,
-                              String classPath) throws MojoExecutionException {
+                              Set<String> classPath) throws MojoExecutionException
{
         File outputDirFile = wsdlOption.getOutputDir();
         outputDirFile.mkdirs();
         URI basedir = project.getBasedir().toURI();
@@ -561,7 +562,7 @@ public class WSDL2JavaMojo extends Abstr
         getLog().debug("Calling wsdl2java with args: " + Arrays.toString(args));
         
         if (!"false".equals(fork)) {
-            List<String> artifactsPath = new ArrayList<String>(pluginArtifacts.size());
+            Set<String> artifactsPath = new LinkedHashSet<String>();
             for (Artifact a : pluginArtifacts) {
                 File file = a.getFile();
                 if (file == null) {
@@ -572,10 +573,10 @@ public class WSDL2JavaMojo extends Abstr
                 artifactsPath.add(file.getPath());
             }
             addPluginArtifact(artifactsPath);
-            classPath = StringUtils.join(artifactsPath.iterator(), File.pathSeparator) 
-                + File.pathSeparator + classPath;
+            artifactsPath.addAll(classPath);
+            String cp = StringUtils.join(artifactsPath.iterator(), File.pathSeparator);
             
-            runForked(classPath, WSDLToJava.class, args);
+            runForked(cp, WSDLToJava.class, args);
 
         } else {
             if (bus == null) {



Mime
View raw message