rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java
branchclosure
changeset 1618 f62b42f0b751
parent 1604 7665471a56c1
child 1636 eb97a082741b
     1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java	Tue May 27 12:25:41 2014 +0200
     1.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java	Mon Jun 09 12:40:40 2014 +0200
     1.3 @@ -104,7 +104,12 @@
     1.4              File aot = new File(prj.getBuild().getDirectory(), classPathPrefix);
     1.5              aot.mkdirs();
     1.6              File js = new File(aot, n.substring(0, n.length() - 4) + ".js");
     1.7 +            if (js.exists()) {
     1.8 +                getLog().info("Skipping " + js + " as it already exists.");
     1.9 +                continue;
    1.10 +            }
    1.11              try {
    1.12 +                getLog().info("Generating " + js);
    1.13                  aotLibrary(a, js , loader);
    1.14              } catch (IOException ex) {
    1.15                  throw new MojoFailureException("Can't compile" + a.getFile(), ex);
    1.16 @@ -112,18 +117,23 @@
    1.17          }
    1.18          
    1.19          try {
    1.20 -            Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar);
    1.21 -            if (exports != null) {
    1.22 -                for (String e : exports) {
    1.23 -                    c = c.addExported(e.replace('.', '/'));
    1.24 +            if (mainJavaScript.exists()) {
    1.25 +                getLog().info("Skipping " + mainJavaScript + " as it already exists.");
    1.26 +            } else {
    1.27 +                getLog().info("Generating " + mainJavaScript);
    1.28 +                Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar);
    1.29 +                if (exports != null) {
    1.30 +                    for (String e : exports) {
    1.31 +                        c = c.addExported(e.replace('.', '/'));
    1.32 +                    }
    1.33                  }
    1.34 +                FileWriter w = new FileWriter(mainJavaScript);
    1.35 +                c.
    1.36 +                        obfuscation(obfuscation).
    1.37 +                        resources(loader).
    1.38 +                        generate(w);
    1.39 +                w.close();
    1.40              }
    1.41 -            FileWriter w = new FileWriter(mainJavaScript);
    1.42 -            c.
    1.43 -                    obfuscation(obfuscation).
    1.44 -                    resources(loader).
    1.45 -                    generate(w);
    1.46 -            w.close();
    1.47          } catch (IOException ex) {
    1.48              throw new MojoFailureException("Cannot generate script for " + mainJar, ex);
    1.49          }