launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java
branchjdk8
changeset 1679 93f4fbc4d1b7
parent 1614 8eba262bd8cd
child 1747 58fd5ea7ad4e
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Tue Jun 03 16:05:21 2014 +0200
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Sat Sep 13 14:19:43 2014 +0200
     1.3 @@ -77,26 +77,9 @@
     1.4          }
     1.5          if (s != null) {
     1.6              File root = new File(s);
     1.7 -            List<String> arr = new ArrayList<>();
     1.8 -            List<String> classes = new ArrayList<>();
     1.9 -            listDir(root, null, classes, arr);
    1.10              StringWriter w = new StringWriter();
    1.11              try {
    1.12 -                Bck2Brwsr.newCompiler()
    1.13 -                    .addRootClasses(classes.toArray(new String[0]))
    1.14 -                    .addResources(arr.toArray(new String[0]))
    1.15 -                    .library()
    1.16 -                    //.obfuscation(ObfuscationLevel.FULL)
    1.17 -                    .resources(new EmulationResources() {
    1.18 -                        @Override
    1.19 -                        public InputStream get(String resource) throws IOException {
    1.20 -                            if (r != null) {
    1.21 -                                final URL url = r.get(resource, 0);
    1.22 -                                return url == null ? null : url.openStream();
    1.23 -                            }
    1.24 -                            return super.get(resource);
    1.25 -                        }
    1.26 -                    })
    1.27 +                Bck2BrwsrJars.configureFrom(null, root)
    1.28                      .generate(w);
    1.29                  w.flush();
    1.30                  return w.toString();
    1.31 @@ -109,23 +92,6 @@
    1.32          return null;
    1.33      }
    1.34      
    1.35 -
    1.36 -    private static void listDir(File f, String pref, List<String> classes, List<String> resources) throws IOException {
    1.37 -        File[] arr = f.listFiles();
    1.38 -        if (arr == null) {
    1.39 -            if (f.getName().endsWith(".class")) {
    1.40 -                classes.add(pref + f.getName().substring(0, f.getName().length() - 6));
    1.41 -            } else {
    1.42 -                resources.add(pref + f.getName());
    1.43 -            }
    1.44 -        } else {
    1.45 -            for (File ch : arr) {
    1.46 -                
    1.47 -                listDir(ch, pref == null ? "" : pref + f.getName() + "/", classes, resources);
    1.48 -            }
    1.49 -        }
    1.50 -    }
    1.51 -
    1.52      static void compileVM(StringBuilder sb, final Res r) throws IOException {
    1.53          final Bck2Brwsr rt;
    1.54          try {
    1.55 @@ -155,26 +121,4 @@
    1.56                  }
    1.57              }).generate(sb);
    1.58      }
    1.59 -
    1.60 -    static class EmulationResources implements Bck2Brwsr.Resources {
    1.61 -
    1.62 -        @Override
    1.63 -        public InputStream get(String name) throws IOException {
    1.64 -            Enumeration<URL> en = Bck2BrwsrJars.class.getClassLoader().getResources(name);
    1.65 -            URL u = null;
    1.66 -            while (en.hasMoreElements()) {
    1.67 -                u = en.nextElement();
    1.68 -            }
    1.69 -            if (u == null) {
    1.70 -                LOG.log(Level.WARNING, "Cannot find {0}", name);
    1.71 -                return null;
    1.72 -            }
    1.73 -            if (u.toExternalForm().contains("/rt.jar!")) {
    1.74 -                LOG.log(Level.WARNING, "{0}No bootdelegation for ", name);
    1.75 -                return null;
    1.76 -            }
    1.77 -            return u.openStream();
    1.78 -        }
    1.79 -    }
    1.80 -    
    1.81  }