-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Version to Java - clusterformation part1 (#32009)
Implement buildSrc Version in java - This allows to move all all .java files from .groovy. - Will prevent eclipse from tangling up in this setup - make it possible to use Version from Java This backport pulls in some changes from the non backported #27397 but that should be fine
- Loading branch information
Showing
9 changed files
with
460 additions
and
240 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
buildSrc/src/main/groovy/org/elasticsearch/gradle/LoggedExec.java
This file was deleted.
Oops, something went wrong.
157 changes: 0 additions & 157 deletions
157
buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
buildSrc/src/main/java/org/elasticsearch/gradle/LoggedExec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
) | ||
); | ||
} | ||
} | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.