in src/java/io/bazel/rulesscala/scalac/ScalacWorker.java [29:78]
public void work(String[] args) throws Exception {
CompileOptions ops = new CompileOptions(args);
Path outputJar = Paths.get(ops.outputName);
Path workdir = ensureEmptyWorkDirectory(outputJar, ops.currentTarget);
Path classes = Files.createDirectories(workdir.resolve("classes"));
Path sources = Files.createDirectories(workdir.resolve("sources"));
List<File> jarFiles = extractSourceJars(ops, sources);
List<File> scalaJarFiles = filterFilesByExtension(jarFiles, ".scala");
List<File> javaJarFiles = filterFilesByExtension(jarFiles, ".java");
if (!ops.expectJavaOutput && ops.javaFiles.length != 0) {
throw new RuntimeException("Cannot have java source files when no expected java output");
}
if (!ops.expectJavaOutput && !javaJarFiles.isEmpty()) {
throw new RuntimeException(
"Found java files in source jars but expect Java output is set to false");
}
String[] scalaSources = collectSrcJarSources(ops.files, scalaJarFiles, javaJarFiles);
String[] javaSources = appendToString(ops.javaFiles, javaJarFiles);
if (scalaSources.length == 0 && javaSources.length == 0) {
throw new RuntimeException("Must have input files from either source jars or local files.");
}
/**
* Compile scala sources if available (if there are none, we will simply compile java sources).
*/
if (scalaSources.length > 0) {
compileScalaSources(ops, scalaSources, classes);
}
/** Copy the resources */
copyResources(ops.resourceSources, ops.resourceTargets, classes);
/** Extract and copy resources from resource jars */
copyResourceJars(ops.resourceJars, classes);
/** Copy classpath resources to root of jar */
copyClasspathResourcesToRoot(ops.classpathResourceFiles, classes);
/** Now build the output jar */
String[] jarCreatorArgs = {
"-m", ops.manifestPath, "-t", ops.stampLabel, outputJar.toString(), classes.toString()
};
JarCreator.main(jarCreatorArgs);
}