Silently ignore projects with no source roots.
authorJan Lahoda <jlahoda@netbeans.org>
Thu, 13 Sep 2012 07:09:58 +0200
changeset 8713d7330f2801e
parent 870 d124ec5ef94d
child 872 08b9ea864ae0
Silently ignore projects with no source roots.
cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java
     1.1 --- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java	Tue Sep 11 10:15:09 2012 +0200
     1.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java	Thu Sep 13 07:09:58 2012 +0200
     1.3 @@ -66,6 +66,7 @@
     1.4  
     1.5      public void execute() throws MojoExecutionException, MojoFailureException {
     1.6          try {
     1.7 +            List<String> compileSourceRoots = (List<String>) project.getCompileSourceRoots();
     1.8              String sourceLevel = "1.5";
     1.9              Xpp3Dom sourceLevelConfiguration = Utils.getPluginConfiguration(project, "org.apache.maven.plugins", "maven-compiler-plugin");
    1.10  
    1.11 @@ -82,7 +83,7 @@
    1.12              List<String> cmdLine = new ArrayList<String>();
    1.13              cmdLine.add("--no-apply");
    1.14              cmdLine.add("--sourcepath");
    1.15 -            cmdLine.add(toClassPathString((List<String>) project.getCompileSourceRoots()));
    1.16 +            cmdLine.add(toClassPathString(compileSourceRoots));
    1.17              cmdLine.add("--classpath");
    1.18              cmdLine.add(toClassPathString((List<String>) project.getCompileClasspathElements()));
    1.19              cmdLine.add("--source");
    1.20 @@ -93,10 +94,20 @@
    1.21                  cmdLine.add(configurationFile);
    1.22              }
    1.23  
    1.24 -            for (String sr : (List<String>) project.getCompileSourceRoots()) {
    1.25 +            boolean hasSourceRoots = false;
    1.26 +
    1.27 +            for (String sr : compileSourceRoots) {
    1.28 +                if (!hasSourceRoots && new File(sr).isDirectory()) {
    1.29 +                    hasSourceRoots = true;
    1.30 +                }
    1.31                  cmdLine.add(sr);
    1.32              }
    1.33  
    1.34 +            if (!hasSourceRoots) {
    1.35 +                getLog().debug("jackpot30 analyze: Not source roots to operate on");
    1.36 +                return ;
    1.37 +            }
    1.38 +
    1.39              Main.compile(cmdLine.toArray(new String[0]));
    1.40          } catch (IOException ex) {
    1.41              throw new MojoExecutionException(ex.getMessage(), ex);