Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions buildSrc/src/main/groovy/org/elasticsearch/gradle/LoggedExec.java

This file was deleted.

147 changes: 0 additions & 147 deletions buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy

This file was deleted.

44 changes: 44 additions & 0 deletions buildSrc/src/main/java/org/elasticsearch/gradle/LoggedExec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.elasticsearch.gradle;

import org.gradle.api.GradleException;
import org.gradle.api.tasks.Exec;

import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;

/**
* A wrapper around gradle's Exec task to capture output and log on error.
*/
@SuppressWarnings("unchecked")
public class LoggedExec extends Exec {

protected ByteArrayOutputStream output = new ByteArrayOutputStream();

public LoggedExec() {
if (getLogger().isInfoEnabled() == false) {
setStandardOutput(output);
setErrorOutput(output);
setIgnoreExitValue(true);
doLast((unused) -> {
if (getExecResult().getExitValue() != 0) {
try {
for (String line : output.toString("UTF-8").split("\\R")) {
getLogger().error(line);
}
} catch (UnsupportedEncodingException e) {
throw new GradleException("Failed to read exec output", e);
}
throw new GradleException(
String.format(
"Process '%s %s' finished with non-zero exit value %d",
getExecutable(),
getArgs(),
getExecResult().getExitValue()
)
);
}
}
);
}
}
}
Loading