Commits

Jan Lahoda committed 9ea3bc5

Pass compile and source path to showgui.

  • Participants
  • Parent commits 7547f74

Comments (0)

Files changed (2)

cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java

 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 org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.model.Resource;
 
     protected final void doRun(MavenProject project, boolean apply) throws MojoExecutionException, MojoFailureException {
         try {
-            List<String> compileSourceRoots = new ArrayList<String>();
-            compileSourceRoots.addAll((List<String>) project.getCompileSourceRoots());
-            for (Resource r : (List<Resource>) project.getResources()) {
-                compileSourceRoots.add(r.getDirectory());
-            }
             String sourceLevel = "1.5";
             Xpp3Dom sourceLevelConfiguration = Utils.getPluginConfiguration(project, "org.apache.maven.plugins", "maven-compiler-plugin");
 
             else
                 cmdLine.add("--no-apply");
 
-            cmdLine.add("--sourcepath");
-            cmdLine.add(toClassPathString(compileSourceRoots));
-            cmdLine.add("--classpath");
-            cmdLine.add(toClassPathString((List<String>) project.getCompileClasspathElements()));
+            cmdLine.addAll(sourceAndCompileClassPaths(Collections.singletonList(project)));
             cmdLine.add("--source");
             cmdLine.add(sourceLevel);
 
         return classPath.toString();
     }
 
+    @SuppressWarnings("unchecked")
+    public static List<String> sourceAndCompileClassPaths(Iterable<? extends MavenProject> projects) throws DependencyResolutionRequiredException {
+        List<String> compileSourceRoots = new ArrayList<String>();
+        List<String> compileClassPath = new ArrayList<String>();
+
+        for (MavenProject project : projects) {
+            compileSourceRoots.addAll((List<String>) project.getCompileSourceRoots());
+
+            for (Resource r : (List<Resource>) project.getResources()) {
+                compileSourceRoots.add(r.getDirectory());
+            }
+            
+            compileClassPath.addAll((List<String>) project.getCompileClasspathElements());
+        }
+
+        return Arrays.asList("--sourcepath",
+                             toClassPathString(compileSourceRoots),
+                             "--classpath",
+                             toClassPathString(compileClassPath));
+    }
 }

cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/ShowGuiJackpot30.java

 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
     public void execute() throws MojoExecutionException, MojoFailureException {
         try {
             if (!project.isExecutionRoot()) return;
-            
+
             String configurationFile = Utils.getJackpotConfigurationFile(project);
 
             if (configurationFile == null)
 
             cmdLine.add("--config-file");
             cmdLine.add(configurationFile);
+            cmdLine.addAll(RunJackpot30.sourceAndCompileClassPaths(project.getCollectedProjects()));
             cmdLine.add("--show-gui");
+            System.err.println(cmdLine);
 
             Main.compile(cmdLine.toArray(new String[0]));
         } catch (IOException ex) {
             throw new MojoExecutionException(ex.getMessage(), ex);
         } catch (ClassNotFoundException ex) {
             throw new MojoExecutionException(ex.getMessage(), ex);
+        } catch (DependencyResolutionRequiredException ex) {
+            throw new MojoExecutionException(ex.getMessage(), ex);
         }
     }