1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java Tue Apr 29 10:23:55 2014 +0200
1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java Tue Apr 29 14:28:52 2014 +0200
1.3 @@ -67,7 +67,7 @@
1.4 }
1.5 }
1.6
1.7 - static String compileFromClassPath(URL u) throws IOException, URISyntaxException {
1.8 + static String compileFromClassPath(URL u, final Res r) throws IOException, URISyntaxException {
1.9 File f = new File(u.toURI());
1.10 for (String s : System.getProperty("java.class.path").split(File.pathSeparator)) {
1.11 if (!f.getPath().startsWith(s)) {
1.12 @@ -83,7 +83,12 @@
1.13 .addRootClasses(classes.toArray(new String[0]))
1.14 .addResources(arr.toArray(new String[0]))
1.15 .library(true)
1.16 - .resources(new EmulationResources())
1.17 + .resources(new EmulationResources() {
1.18 + @Override
1.19 + public InputStream get(String resource) throws IOException {
1.20 + return r != null ? r.get(resource).openStream() : super.get(resource);
1.21 + }
1.22 + })
1.23 .generate(w);
1.24 w.flush();
1.25 return w.toString();
1.26 @@ -127,6 +132,9 @@
1.27 private static void listDir(File f, String pref, List<String> classes, List<String> resources) throws IOException {
1.28 File[] arr = f.listFiles();
1.29 if (arr == null) {
1.30 + if (f.getName().equals("package-info.class")) {
1.31 + return;
1.32 + }
1.33 if (f.getName().endsWith(".class")) {
1.34 classes.add(pref + f.getName().substring(0, f.getName().length() - 6));
1.35 } else {
1.36 @@ -140,7 +148,7 @@
1.37 }
1.38 }
1.39
1.40 - static void compileVM(StringBuilder sb, Res r) throws IOException {
1.41 + static void compileVM(StringBuilder sb, final Res r) throws IOException {
1.42 URL u = r.get(InterruptedException.class.getName().replace('.', '/') + ".class");
1.43 JarURLConnection juc = (JarURLConnection)u.openConnection();
1.44
1.45 @@ -149,8 +157,12 @@
1.46 listJAR(juc.getJarFile(), classes, arr);
1.47
1.48 Bck2Brwsr.newCompiler().addRootClasses(classes.toArray(new String[0]))
1.49 - .resources(new EmulationResources())
1.50 - .generate(sb);
1.51 + .resources(new Bck2Brwsr.Resources() {
1.52 + @Override
1.53 + public InputStream get(String resource) throws IOException {
1.54 + return r.get(resource).openStream();
1.55 + }
1.56 + }).generate(sb);
1.57 }
1.58
1.59 static class EmulationResources implements Bck2Brwsr.Resources {