org.gradle.process.internal.ExecException Java Examples

The following examples show how to use org.gradle.process.internal.ExecException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavadocGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(JavadocSpec spec) {
    JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
    javadocExecHandleBuilder.setExecutable(spec.getExecutable());
    javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (spec.isIgnoreFailures()) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        LOG.info("Problems generating Javadoc. The generated Javadoc options file used by Gradle has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
        throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
    }

    return new SimpleWorkResult(true);
}
 
Example #2
Source File: Javadoc.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void executeExternalJavadoc() {
    javadocExecHandleBuilder.setExecutable(executable);
    javadocExecHandleBuilder.execDirectory(getProject().getRootDir()).options(options).optionsFile(
            getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (!failOnError) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        throw new GradleException("Javadoc generation failed.", e);
    }
}
 
Example #3
Source File: CommandLineTool.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(T spec) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (workDir != null) {
        compiler.workingDir(workDir);
    }

    List<String> args = specToArgs.transform(specTransformer.transform(spec));
    compiler.args(args);

    if (!path.isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(path);
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(environment);

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
    return new SimpleWorkResult(true);
}
 
Example #4
Source File: JavadocGenerator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(JavadocSpec spec) {
    JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
    javadocExecHandleBuilder.setExecutable(spec.getExecutable());
    javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (spec.isIgnoreFailures()) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        LOG.info("Problems generating Javadoc. The generated Javadoc options file used by Gradle has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
        throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
    }

    return new SimpleWorkResult(true);
}
 
Example #5
Source File: CommandLineTool.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(CommandLineToolInvocation invocation) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (invocation.getWorkDirectory() != null) {
        GFileUtils.mkdirs(invocation.getWorkDirectory());
        compiler.workingDir(invocation.getWorkDirectory());
    }

    compiler.args(invocation.getArgs());

    if (!invocation.getPath().isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(invocation.getPath());
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(invocation.getEnvironment());

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
}
 
Example #6
Source File: Javadoc.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void executeExternalJavadoc() {
    javadocExecHandleBuilder.setExecutable(executable);
    javadocExecHandleBuilder.execDirectory(getProject().getRootDir()).options(options).optionsFile(
            getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (!failOnError) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        throw new GradleException("Javadoc generation failed.", e);
    }
}
 
Example #7
Source File: CommandLineTool.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(T spec) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (workDir != null) {
        compiler.workingDir(workDir);
    }

    List<String> args = specToArgs.transform(specTransformer.transform(spec));
    compiler.args(args);

    if (!path.isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(path);
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(environment);

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
    return new SimpleWorkResult(true);
}
 
Example #8
Source File: CommandLineTool.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(CommandLineToolInvocation invocation) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (invocation.getWorkDirectory() != null) {
        GFileUtils.mkdirs(invocation.getWorkDirectory());
        compiler.workingDir(invocation.getWorkDirectory());
    }

    compiler.args(invocation.getArgs());

    if (!invocation.getPath().isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(invocation.getPath());
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(invocation.getEnvironment());

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
}
 
Example #9
Source File: GradleProcessResult.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ProcessResult assertNormalExitValue() throws ProcessException {
    try {
        result.assertNormalExitValue();
    } catch (ExecException e) {
        throw new ProcessException(e);
    }

    return this;
}
 
Example #10
Source File: GradleProcessResult.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ProcessResult rethrowFailure() throws ProcessException {
    try {
        result.rethrowFailure();
    } catch (ExecException e) {
        throw new ProcessException(e);
    }
    return this;
}
 
Example #11
Source File: SuccessExecResult.java    From javaccPlugin with MIT License 4 votes vote down vote up
@Override
public ExecResult rethrowFailure() throws ExecException {
    return this;
}
 
Example #12
Source File: SuccessExecResult.java    From javaccPlugin with MIT License 4 votes vote down vote up
@Override
public ExecResult assertNormalExitValue() throws ExecException {
    return this;
}
 
Example #13
Source File: FailureExecResult.java    From javaccPlugin with MIT License 4 votes vote down vote up
@Override
public ExecResult rethrowFailure() throws ExecException {
    throw execException();
}
 
Example #14
Source File: FailureExecResult.java    From javaccPlugin with MIT License 4 votes vote down vote up
private ExecException execException() {
    return new ExecException(String.format("Non-zero exit value: %d", getExitValue()));
}
 
Example #15
Source File: FailureExecResult.java    From javaccPlugin with MIT License 4 votes vote down vote up
@Override
public ExecResult assertNormalExitValue() throws ExecException {
    throw execException();
}
 
Example #16
Source File: ExecResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Re-throws any failure executing this process.
 *
 * @return this
 * @throws ExecException the execution failure
 */
ExecResult rethrowFailure() throws ExecException;
 
Example #17
Source File: ExecResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Re-throws any failure executing this process.
 *
 * @return this
 * @throws ExecException the execution failure
 */
ExecResult rethrowFailure() throws ExecException;
 
Example #18
Source File: ExecResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Throws an {@link org.gradle.process.internal.ExecException} if the process exited with a non-zero exit value.
 *
 * @return this
 * @throws ExecException if the process exited with a non-zero exit value
 */
ExecResult assertNormalExitValue() throws ExecException;
 
Example #19
Source File: ExecResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Throws an {@link org.gradle.process.internal.ExecException} if the process exited with a non-zero exit value.
 *
 * @return this
 * @throws ExecException if the process exited with a non-zero exit value
 */
ExecResult assertNormalExitValue() throws ExecException;
 
Example #20
Source File: ExecResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Re-throws any failure executing this process.
 *
 * @return this
 * @throws ExecException the execution failure
 */
ExecResult rethrowFailure() throws ExecException;
 
Example #21
Source File: ExecResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Throws an {@link org.gradle.process.internal.ExecException} if the process exited with a non-zero exit value.
 *
 * @return this
 * @throws ExecException if the process exited with a non-zero exit value
 */
ExecResult assertNormalExitValue() throws ExecException;
 
Example #22
Source File: ExecResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Re-throws any failure executing this process.
 *
 * @return this
 * @throws ExecException the execution failure
 */
ExecResult rethrowFailure() throws ExecException;
 
Example #23
Source File: ExecResult.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Re-throws any failure executing this process.
 *
 * @return this
 * @throws ExecException the execution failure
 */
ExecResult rethrowFailure() throws ExecException;
 
Example #24
Source File: ExecResult.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Throws an {@link org.gradle.process.internal.ExecException} if the process exited with a non-zero exit value.
 *
 * @return this
 * @throws ExecException if the process exited with a non-zero exit value
 */
ExecResult assertNormalExitValue() throws ExecException;
 
Example #25
Source File: ExecResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Throws an {@link org.gradle.process.internal.ExecException} if the process exited with a non-zero exit value.
 *
 * @return this
 * @throws ExecException if the process exited with a non-zero exit value
 */
ExecResult assertNormalExitValue() throws ExecException;