Bazel: Generate Eclipse classpath
To guess what build system is used, we create now .primary_build_tool file in the root of the project during the eclipse classpath generation. Change the working directory for GWT SDM session to be .gwt_work_dir. The reason for that Bazel doesn't allow to write to bazel-out. Change-Id: I984068350244ee9d66807e4bc8c6779b34a26bab
This commit is contained in:
@@ -14,8 +14,11 @@
|
||||
|
||||
package com.google.gerrit.httpd.raw;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
public class BazelBuild extends BuildSystem {
|
||||
public BazelBuild(Path sourceRoot) {
|
||||
@@ -24,7 +27,13 @@ public class BazelBuild extends BuildSystem {
|
||||
|
||||
@Override
|
||||
protected ProcessBuilder newBuildProcess(Label label) throws IOException {
|
||||
ProcessBuilder proc = new ProcessBuilder("bazel", "build", label.fullName());
|
||||
Properties properties = loadBuildProperties(
|
||||
sourceRoot.resolve(".primary_build_tool"));
|
||||
String buck = firstNonNull(properties.getProperty("bazel"), "bazel");
|
||||
ProcessBuilder proc = new ProcessBuilder(buck, "build", label.fullName());
|
||||
if (properties.containsKey("PATH")) {
|
||||
proc.environment().put("PATH", properties.getProperty("PATH"));
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,6 @@ package com.google.gerrit.httpd.raw;
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -30,7 +27,7 @@ class BuckUtils extends BuildSystem {
|
||||
|
||||
@Override
|
||||
protected ProcessBuilder newBuildProcess(Label label) throws IOException {
|
||||
Properties properties = loadBuckProperties(
|
||||
Properties properties = loadBuildProperties(
|
||||
sourceRoot.resolve("buck-out/gen/tools/buck/buck.properties"));
|
||||
String buck = firstNonNull(properties.getProperty("buck"), "buck");
|
||||
ProcessBuilder proc = new ProcessBuilder(buck, "build", label.fullName());
|
||||
@@ -40,17 +37,6 @@ class BuckUtils extends BuildSystem {
|
||||
return proc;
|
||||
}
|
||||
|
||||
private static Properties loadBuckProperties(Path propPath)
|
||||
throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream in = Files.newInputStream(propPath)) {
|
||||
properties.load(in);
|
||||
} catch (NoSuchFileException e) {
|
||||
// Ignore; will be run from PATH, with a descriptive error if it fails.
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path targetPath(Label label) {
|
||||
return sourceRoot.resolve("buck-out")
|
||||
|
@@ -30,7 +30,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -46,6 +49,17 @@ public abstract class BuildSystem {
|
||||
|
||||
protected abstract ProcessBuilder newBuildProcess(Label l) throws IOException;
|
||||
|
||||
protected static Properties loadBuildProperties(Path propPath)
|
||||
throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream in = Files.newInputStream(propPath)) {
|
||||
properties.load(in);
|
||||
} catch (NoSuchFileException e) {
|
||||
// Ignore; will be run from PATH, with a descriptive error if it fails.
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
// builds the given label.
|
||||
public void build(Label label)
|
||||
throws IOException, BuildFailureException {
|
||||
|
Reference in New Issue
Block a user