launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java
branchclosure
changeset 1492 e38025e9536a
parent 1491 4a1398eff4fb
child 1498 9583bcc50db3
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Sat Apr 26 21:30:06 2014 +0200
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Sun Apr 27 08:33:38 2014 +0200
     1.3 @@ -21,6 +21,7 @@
     1.4  import java.io.IOException;
     1.5  import java.io.InputStream;
     1.6  import java.io.StringWriter;
     1.7 +import java.net.JarURLConnection;
     1.8  import java.net.URISyntaxException;
     1.9  import java.net.URL;
    1.10  import java.util.ArrayList;
    1.11 @@ -29,6 +30,7 @@
    1.12  import java.util.jar.JarEntry;
    1.13  import java.util.jar.JarFile;
    1.14  import java.util.zip.ZipEntry;
    1.15 +import org.apidesign.bck2brwsr.launcher.BaseHTTPLauncher.Res;
    1.16  import org.apidesign.vm4brwsr.Bck2Brwsr;
    1.17  
    1.18  /**
    1.19 @@ -97,6 +99,9 @@
    1.20          while (en.hasMoreElements()) {
    1.21              JarEntry e = en.nextElement();
    1.22              final String n = e.getName();
    1.23 +            if (n.contains("package-info")) {
    1.24 +                continue;
    1.25 +            }
    1.26              if (n.endsWith("/")) {
    1.27                  continue;
    1.28              }
    1.29 @@ -133,6 +138,19 @@
    1.30          }
    1.31      }
    1.32  
    1.33 +    static void compileVM(StringBuilder sb, Res r) throws IOException {
    1.34 +        URL u = r.get(InterruptedException.class.getName().replace('.', '/') + ".class");
    1.35 +        JarURLConnection juc = (JarURLConnection)u.openConnection();
    1.36 +        
    1.37 +        List<String> arr = new ArrayList<>();
    1.38 +        List<String> classes = new ArrayList<>();
    1.39 +        listJAR(juc.getJarFile(), classes, arr);
    1.40 +
    1.41 +        Bck2Brwsr.newCompiler().addRootClasses(classes.toArray(new String[0]))
    1.42 +            .resources(new EmulationResources())
    1.43 +            .generate(sb);
    1.44 +    }
    1.45 +
    1.46      static class EmulationResources implements Bck2Brwsr.Resources {
    1.47  
    1.48          @Override