rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java
branchclosure
changeset 1595 19d0484c1916
parent 1584 7b6295731c30
child 1599 36746c46716a
     1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java	Thu May 22 10:48:09 2014 +0200
     1.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java	Mon May 26 14:33:11 2014 +0200
     1.3 @@ -35,6 +35,8 @@
     1.4  import java.util.Set;
     1.5  import java.util.jar.JarEntry;
     1.6  import java.util.jar.JarFile;
     1.7 +import java.util.logging.Level;
     1.8 +import java.util.logging.Logger;
     1.9  import org.apache.maven.artifact.Artifact;
    1.10  import org.apache.maven.plugin.AbstractMojo;
    1.11  import org.apache.maven.plugin.MojoExecutionException;
    1.12 @@ -81,21 +83,33 @@
    1.13      
    1.14      @Override
    1.15      public void execute() throws MojoExecutionException, MojoFailureException {
    1.16 +        URLClassLoader loader;
    1.17          try {
    1.18 -            URLClassLoader loader = buildClassLoader(null, prj.getArtifacts());
    1.19 -            for (Artifact a : prj.getArtifacts()) {
    1.20 -                if (a.getFile() == null) {
    1.21 -                    continue;
    1.22 -                }
    1.23 -                String n = a.getFile().getName();
    1.24 -                if (!n.endsWith(".jar")) {
    1.25 -                    continue;
    1.26 -                }
    1.27 -                aot.mkdirs();
    1.28 -                File js = new File(aot, n.substring(0, n.length() - 4) + ".js");
    1.29 +            loader = buildClassLoader(null, prj.getArtifacts());
    1.30 +        } catch (MalformedURLException ex) {
    1.31 +            throw new MojoFailureException("Can't initialize classloader");
    1.32 +        }
    1.33 +        for (Artifact a : prj.getArtifacts()) {
    1.34 +            if (a.getFile() == null) {
    1.35 +                continue;
    1.36 +            }
    1.37 +            String n = a.getFile().getName();
    1.38 +            if (!n.endsWith(".jar")) {
    1.39 +                continue;
    1.40 +            }
    1.41 +            if ("provided".equals(a.getScope())) {
    1.42 +                continue;
    1.43 +            }
    1.44 +            aot.mkdirs();
    1.45 +            File js = new File(aot, n.substring(0, n.length() - 4) + ".js");
    1.46 +            try {
    1.47                  aotLibrary(a, js , loader);
    1.48 +            } catch (IOException ex) {
    1.49 +                throw new MojoFailureException("Can't compile" + a.getFile(), ex);
    1.50              }
    1.51 +        }
    1.52              
    1.53 +        try {
    1.54              FileWriter w = new FileWriter(vm);
    1.55              Bck2Brwsr.newCompiler().
    1.56                      obfuscation(obfuscation).