Skip to content

Convert Version to Java - clusterformation part1 #32009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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