rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java
changeset 1914 88b00e03fc8f
parent 1824 9fb23d7831da
child 1916 a9d37af23a00
     1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java	Wed Apr 15 14:32:54 2015 +0200
     1.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java	Mon Mar 28 05:55:43 2016 +0200
     1.3 @@ -18,6 +18,7 @@
     1.4  package org.apidesign.bck2brwsr.mojo;
     1.5  
     1.6  import java.io.File;
     1.7 +import java.io.FileNotFoundException;
     1.8  import java.io.FileOutputStream;
     1.9  import java.io.IOException;
    1.10  import java.io.OutputStreamWriter;
    1.11 @@ -141,10 +142,12 @@
    1.12                  }
    1.13              }
    1.14              
    1.15 -            FileOutputStream fos = new FileOutputStream(this.aotJar);
    1.16 -            JarOutputStream os = new JarOutputStream(fos, m);
    1.17  
    1.18 +            JarOutputStream os = null;
    1.19              if (!"false".equals(debug)) {
    1.20 +                if (os == null) {
    1.21 +                    os = aotJar(m);
    1.22 +                }
    1.23                  os.putNextEntry(new JarEntry(debug));
    1.24                  Writer w = new OutputStreamWriter(os, "UTF-8");
    1.25                  configureMain(loader).
    1.26 @@ -154,6 +157,9 @@
    1.27                  os.closeEntry();
    1.28              }
    1.29              if (!"false".equals(minified)) {
    1.30 +                if (os == null) {
    1.31 +                    os = aotJar(m);
    1.32 +                }
    1.33                  os.putNextEntry(new JarEntry(minified));
    1.34              
    1.35                  Writer w = new OutputStreamWriter(os, "UTF-8");
    1.36 @@ -177,6 +183,9 @@
    1.37                          }
    1.38                      }
    1.39                      {
    1.40 +                        if (os == null) {
    1.41 +                            os = aotJar(m);
    1.42 +                        }
    1.43                          os.putNextEntry(new JarEntry(artifactName(a, true)));
    1.44                          Writer w = new OutputStreamWriter(os, "UTF-8");
    1.45                          c.
    1.46 @@ -197,7 +206,9 @@
    1.47                      }                    
    1.48                  }
    1.49              }
    1.50 -            os.close();
    1.51 +            if (os != null) {
    1.52 +                os.close();
    1.53 +            }
    1.54              
    1.55              projectHelper.attachArtifact(prj, "jar", "bck2brwsr", aotJar);
    1.56          } catch (IOException ex) {
    1.57 @@ -205,6 +216,13 @@
    1.58          }
    1.59      }
    1.60  
    1.61 +    private JarOutputStream aotJar(Manifest m) throws IOException, FileNotFoundException {
    1.62 +        this.aotJar.getParentFile().mkdirs();
    1.63 +        FileOutputStream fos = new FileOutputStream(this.aotJar);
    1.64 +        JarOutputStream os = new JarOutputStream(fos, m);
    1.65 +        return os;
    1.66 +    }
    1.67 +
    1.68      private Bck2Brwsr configureMain(URLClassLoader loader) throws IOException {
    1.69          Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar, loader, ignoreBootClassPath);
    1.70          if (exports != null) {