Directly derive the parent root folder based on resource name rather than going through classpath closure
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 03 Jun 2014 16:05:21 +0200
branchclosure
changeset 16148eba262bd8cd
parent 1613 81926ff11587
child 1615 80e39583b35d
Directly derive the parent root folder based on resource name rather than going through classpath
launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java
launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java
     1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java	Thu May 29 09:57:01 2014 +0200
     1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java	Tue Jun 03 16:05:21 2014 +0200
     1.3 @@ -754,6 +754,15 @@
     1.4                      }
     1.5                  }
     1.6                  if (url.getProtocol().equals("file")) {
     1.7 +                    final String filePart = url.getFile();
     1.8 +                    if (filePart.endsWith(res)) {
     1.9 +                        url = new URL(
    1.10 +                            url.getProtocol(), 
    1.11 +                            url.getHost(), 
    1.12 +                            url.getPort(), 
    1.13 +                            filePart.substring(0, filePart.length() - res.length())
    1.14 +                        );
    1.15 +                    }
    1.16                      String s = loader.compileFromClassPath(url);
    1.17                      if (s != null) {
    1.18                          Writer w = response.getWriter();
     2.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Thu May 29 09:57:01 2014 +0200
     2.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Tue Jun 03 16:05:21 2014 +0200
     2.3 @@ -65,10 +65,17 @@
     2.4          } catch (URISyntaxException ex) {
     2.5              throw new IOException(ex);
     2.6          }
     2.7 -        for (String s : System.getProperty("java.class.path").split(File.pathSeparator)) {
     2.8 -            if (!f.getPath().startsWith(s)) {
     2.9 -                continue;
    2.10 +        String s = f.isDirectory() ? f.getPath() : null;
    2.11 +        
    2.12 +        for (String candidate : System.getProperty("java.class.path").split(File.pathSeparator)) {
    2.13 +            if (s != null) {
    2.14 +                break;
    2.15              }
    2.16 +            if (f.getPath().startsWith(candidate)) {
    2.17 +                s = candidate;
    2.18 +            }
    2.19 +        }
    2.20 +        if (s != null) {
    2.21              File root = new File(s);
    2.22              List<String> arr = new ArrayList<>();
    2.23              List<String> classes = new ArrayList<>();