Search in sources :

Example 1 with Argument

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;
}
Also used : Argument(org.apache.tools.ant.types.Commandline.Argument)

Example 2 with Argument

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;
    }
}
Also used : Path(org.apache.tools.ant.types.Path) Commandline(org.apache.tools.ant.types.Commandline) Argument(org.apache.tools.ant.types.Commandline.Argument)

Aggregations

Argument (org.apache.tools.ant.types.Commandline.Argument)2 Commandline (org.apache.tools.ant.types.Commandline)1 Path (org.apache.tools.ant.types.Path)1