Exemple #1
0
 /** Updates {@link #requiredClasspath} to include dependencies from the given output artifact. */
 private void collectDependenciesFromArtifact(String path) throws IOException {
   try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path))) {
     Deps.Dependencies deps = Deps.Dependencies.parseFrom(bis);
     // Sanity check to make sure we have a valid proto.
     if (!deps.hasRuleLabel()) {
       throw new IOException("Could not parse Deps.Dependencies message from proto.");
     }
     for (Deps.Dependency dep : deps.getDependencyList()) {
       if (dep.getKind() == Kind.EXPLICIT || dep.getKind() == Kind.IMPLICIT) {
         requiredClasspath.add(dep.getPath());
       }
     }
   } catch (IOException e) {
     throw new IOException(String.format("error reading deps artifact: %s", path), e);
   }
 }
Exemple #2
0
 @VisibleForTesting
 Deps.Dependencies buildDependenciesProto(String classpath, boolean successful) {
   Deps.Dependencies.Builder deps = Deps.Dependencies.newBuilder();
   if (targetLabel != null) {
     deps.setRuleLabel(targetLabel);
   }
   deps.setSuccess(successful);
   // Filter using the original classpath, to preserve ordering.
   for (String entry : classpath.split(":")) {
     if (explicitDependenciesMap.containsKey(entry)) {
       deps.addDependency(explicitDependenciesMap.get(entry));
     } else if (implicitDependenciesMap.containsKey(entry)) {
       deps.addDependency(implicitDependenciesMap.get(entry));
     }
   }
   return deps.build();
 }