Compile src and write each resulting class file beneath outputDir as a standard package directory tree (e.g. com.example.Foo$Bar becomes /com/example/Foo$Bar.class). Intermediate directories are created as needed; existing class files at those locations are
(String className, Iterable<String> options,
String src, Path outputDir)
| 244 | * @since 6.0.0 |
| 245 | */ |
| 246 | @Incubating |
| 247 | public Map<String, Path> compileAllTo(String className, Iterable<String> options, |
| 248 | String src, Path outputDir) |
| 249 | throws IOException { |
| 250 | doCompile(className, src, options); // populates jscl's classMap |
| 251 | |
| 252 | Map<String, byte[]> classes = jscl.getClassMap(); // already public internally |
| 253 | Map<String, Path> written = new LinkedHashMap<>(); |
| 254 | for (Map.Entry<String, byte[]> e : classes.entrySet()) { |
| 255 | // binary name -> relative path: com.example.Foo$Bar -> com/example/Foo$Bar.class |
| 256 | Path target = outputDir.resolve(e.getKey().replace('.', '/') + ".class"); |
| 257 | Files.createDirectories(target.getParent() == null ? outputDir : target.getParent()); |
| 258 | Files.write(target, e.getValue()); // CREATE + TRUNCATE_EXISTING by default |
| 259 | written.put(e.getKey(), target); |
| 260 | } |
| 261 | return written; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Convenience overload of {@link #compileAllTo(String, Iterable, String, Path)} that |