+ List<String> a2Categories = options.getOrDefault("--dep-categories", new ArrayList<>());
+ List<String> a2Bases = options.getOrDefault("--a2-bases", new ArrayList<>());
+ if (a2Bases.isEmpty()) {
+ a2Bases.add(a2Output.toString());
+ }
+
+ List<String> compilerArgs = new ArrayList<>();
+
+ Path ecjArgs = argeoBuildBase.resolve("ecj.args");
+ compilerArgs.add("@" + ecjArgs);
+
+ // classpath
+ if (!a2Categories.isEmpty()) {
+ compilerArgs.add("-cp");
+ StringJoiner classPath = new StringJoiner(File.pathSeparator);
+ for (String a2Base : a2Bases) {
+ for (String a2Category : a2Categories) {
+ Path a2Dir = Paths.get(a2Base).resolve(a2Category);
+ for (Path jarP : Files.newDirectoryStream(a2Dir,
+ (p) -> p.getFileName().toString().endsWith(".jar"))) {
+ classPath.add(jarP.toString());
+ }
+ }
+ }
+ compilerArgs.add(classPath.toString());
+ }
+
+ // sources
+ for (String bundle : bundles) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(sdkSrcBase.resolve(bundle).resolve("src"));
+ sb.append("[-d");
+ compilerArgs.add(sb.toString());
+ sb = new StringBuilder();
+ sb.append(buildBase.resolve(bundle).resolve("bin"));
+ sb.append("]");
+ compilerArgs.add(sb.toString());
+ }
+
+ // System.out.println(compilerArgs);
+
+ // Use Main instead of BatchCompiler to workaround the fact that
+ // org.eclipse.jdt.core.compiler.batch is not exported
+ org.eclipse.jdt.internal.compiler.batch.Main.compile(compilerArgs.toArray(new String[compilerArgs.size()]),
+ new PrintWriter(System.out), new PrintWriter(System.err), (CompilationProgress) null);
+ }
+
+ void bundle(Map<String, List<String>> options) throws IOException {