Search in sources :

Example 1 with BuildOperationDescriptor

use of org.gradle.internal.operations.BuildOperationDescriptor in project gradle by gradle.

the class TestListenerBuildOperationAdapter method started.

@Override
public void started(final TestDescriptorInternal testDescriptor, TestStartEvent startEvent) {
    long currentTime = clock.getCurrentTime();
    BuildOperationDescriptor testBuildOperationDescriptor = createTestBuildOperationDescriptor(testDescriptor, startEvent);
    runningTests.put(testDescriptor, new InProgressExecuteTestBuildOperation(testBuildOperationDescriptor, currentTime));
    listener.started(testBuildOperationDescriptor, new OperationStartEvent(currentTime));
}
Also used : OperationStartEvent(org.gradle.internal.operations.OperationStartEvent) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor)

Example 2 with BuildOperationDescriptor

use of org.gradle.internal.operations.BuildOperationDescriptor in project gradle by gradle.

the class DefaultCommandLineToolInvocationWorker method execute.

@Override
public void execute(CommandLineToolInvocation invocation, BuildOperationContext context) {
    BuildOperationDescriptor description = invocation.description().build();
    ExecAction toolExec = execActionFactory.newExecAction();
    toolExec.executable(executable);
    if (invocation.getWorkDirectory() != null) {
        GFileUtils.mkdirs(invocation.getWorkDirectory());
        toolExec.workingDir(invocation.getWorkDirectory());
    }
    toolExec.args(invocation.getArgs());
    if (!invocation.getPath().isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String toolPath = Joiner.on(File.pathSeparator).join(invocation.getPath());
        toolPath = toolPath + File.pathSeparator + System.getenv(pathVar);
        toolExec.environment(pathVar, toolPath);
        if (OperatingSystem.current().isWindows() && toolExec.getEnvironment().containsKey(pathVar.toUpperCase())) {
            toolExec.getEnvironment().remove(pathVar.toUpperCase());
        }
    }
    toolExec.environment(invocation.getEnvironment());
    StreamByteBuffer errOutput = new StreamByteBuffer();
    StreamByteBuffer stdOutput = new StreamByteBuffer();
    toolExec.setErrorOutput(errOutput.getOutputStream());
    toolExec.setStandardOutput(stdOutput.getOutputStream());
    try {
        toolExec.execute();
        invocation.getLogger().operationSuccess(description.getDisplayName(), combineOutput(stdOutput, errOutput));
    } catch (ExecException e) {
        invocation.getLogger().operationFailed(description.getDisplayName(), combineOutput(stdOutput, errOutput));
        throw new CommandLineToolInvocationFailure(invocation, String.format("%s failed while %s.", name, description.getDisplayName()));
    }
}
Also used : ExecAction(org.gradle.process.internal.ExecAction) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) ExecException(org.gradle.process.internal.ExecException) StreamByteBuffer(org.gradle.internal.io.StreamByteBuffer)

Aggregations

BuildOperationDescriptor (org.gradle.internal.operations.BuildOperationDescriptor)2 StreamByteBuffer (org.gradle.internal.io.StreamByteBuffer)1 OperationStartEvent (org.gradle.internal.operations.OperationStartEvent)1 ExecAction (org.gradle.process.internal.ExecAction)1 ExecException (org.gradle.process.internal.ExecException)1