Skip to content

Commit

Permalink
JavaBuilder: Remove old logic that tries to parse protos as textfiles.
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=92255081
  • Loading branch information
philwo authored and hanwen committed Apr 28, 2015
1 parent 67944d8 commit 76c6536
Showing 1 changed file with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
Expand Down Expand Up @@ -257,7 +255,8 @@ public boolean reduceClasspath() {
* Computes a reduced compile-time classpath from the union of direct dependencies and their
* dependencies, as listed in the associated .deps artifacts.
*/
public String computeStrictClasspath(String originalClasspath, String classDir) {
public String computeStrictClasspath(String originalClasspath, String classDir)
throws IOException {
if (!strictClasspathMode) {
return originalClasspath;
}
Expand Down Expand Up @@ -289,33 +288,19 @@ void setStrictClasspath(Set<String> strictClasspath) {

/**
* Updates {@link #requiredClasspath} to include dependencies from the given output artifact.
*
* During the .deps migration from text to proto format, this method will try to handle both.
* Blaze can thus switch the .deps artifacts independently.
*/
private void collectDependenciesFromArtifact(String path) {
// Try reading in proto format first
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, not a text file that happened to match.
// Sanity check to make sure we have a valid proto.
if (!deps.hasRuleLabel()) {
throw new IOException("Text file");
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 ex) {
// TODO(bazel-team): Remove this fallback to text format when Blaze is ready.
try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
for (String dep = reader.readLine(); dep != null; dep = reader.readLine()) {
requiredClasspath.add(dep);
}
} catch (IOException exc) {
// At this point we can give up altogether
exc.printStackTrace();
}
}
}

Expand Down

0 comments on commit 76c6536

Please sign in to comment.