Search in sources :

Example 1 with CompilationUnit

use of com.google.devtools.build.buildjar.proto.JavaCompilation.CompilationUnit in project bazel by bazelbuild.

the class AnnotationProcessingModule method buildManifestProto.

private Manifest buildManifestProto() {
    Manifest.Builder builder = Manifest.newBuilder();
    List<String> keys = new ArrayList<>(units.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        CompilationUnit unit = units.get(key);
        builder.addCompilationUnit(unit);
    }
    return builder.build();
}
Also used : CompilationUnit(com.google.devtools.build.buildjar.proto.JavaCompilation.CompilationUnit) ArrayList(java.util.ArrayList) Manifest(com.google.devtools.build.buildjar.proto.JavaCompilation.Manifest)

Example 2 with CompilationUnit

use of com.google.devtools.build.buildjar.proto.JavaCompilation.CompilationUnit in project bazel by bazelbuild.

the class IdlClass method writeSourceJar.

private static void writeSourceJar(IdlClassOptions options, List<Path> idlSources, Manifest manifest) throws IOException {
    Path tempDir = options.tempDir.resolve("sourcejar");
    Path idlSourceBaseDir = options.idlSourceBaseDir;
    for (Path path : idlSources) {
        for (CompilationUnit unit : manifest.getCompilationUnitList()) {
            if (Paths.get(unit.getPath()).equals(path)) {
                String pkg = unit.getPkg();
                Path source = idlSourceBaseDir != null ? idlSourceBaseDir.resolve(path) : path;
                Path target = tempDir.resolve(pkg.replace('.', '/')).resolve(path.getFileName());
                Files.createDirectories(target.getParent());
                Files.copy(source, target);
                break;
            }
        }
    }
    writeOutputJar(options.outputSourceJar, tempDir);
}
Also used : Path(java.nio.file.Path) CompilationUnit(com.google.devtools.build.buildjar.proto.JavaCompilation.CompilationUnit)

Aggregations

CompilationUnit (com.google.devtools.build.buildjar.proto.JavaCompilation.CompilationUnit)2 Manifest (com.google.devtools.build.buildjar.proto.JavaCompilation.Manifest)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1