use of org.apache.tools.ant.types.Commandline.Argument in project error-prone by google.
the class ErrorProneExternalCompilerAdapter method createJvmArg.
public Argument createJvmArg() {
Argument arg = new Argument();
jvmArgs.add(arg);
return arg;
}
use of org.apache.tools.ant.types.Commandline.Argument in project error-prone by google.
the class ErrorProneExternalCompilerAdapter method execute.
@Override
public boolean execute() throws BuildException {
if (getJavac().isForkedJavac()) {
attributes.log("Using external Error Prone compiler", Project.MSG_VERBOSE);
Commandline cmd = new Commandline();
cmd.setExecutable(JavaEnvUtils.getJdkExecutable("java"));
if (memoryStackSize != null) {
cmd.createArgument().setValue("-Xss" + memoryStackSize);
}
String memoryParameterPrefix = "-X";
if (memoryInitialSize != null) {
cmd.createArgument().setValue(memoryParameterPrefix + "ms" + this.memoryInitialSize);
// Prevent setupModernJavacCommandlineSwitches() from doing it also
memoryInitialSize = null;
}
if (memoryMaximumSize != null) {
cmd.createArgument().setValue(memoryParameterPrefix + "mx" + this.memoryMaximumSize);
// Prevent setupModernJavacCommandlineSwitches() from doing it also
memoryMaximumSize = null;
}
for (Argument arg : jvmArgs) {
for (String part : arg.getParts()) {
cmd.createArgument().setValue(part);
}
}
Path bootclasspath = new Path(getProject());
addResourceSource(bootclasspath, "com/google/errorprone/ErrorProneExternalCompilerAdapter.class");
cmd.createArgument().setValue("-Xbootclasspath/p:" + bootclasspath);
if (classpath != null) {
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath);
}
cmd.createArgument().setValue(ErrorProneCompiler.class.getName());
setupModernJavacCommandlineSwitches(cmd);
int firstFile = cmd.size();
logAndAddFilesToCompile(cmd);
return executeExternalCompile(cmd.getCommandline(), firstFile, true) == 0;
} else {
attributes.log("You must set fork=\"yes\" to use the external Error Prone compiler", Project.MSG_ERR);
return false;
}
}
Aggregations