Skip JS aot compilation, if the JS file already exists closure
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 09 Jun 2014 12:40:40 +0200
branchclosure
changeset 1618f62b42f0b751
parent 1617 7271b051b13c
child 1619 a7bf87c2c1d9
Skip JS aot compilation, if the JS file already exists
rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java
     1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java	Mon Jun 09 09:40:32 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          }