Skip to content

Commit

Permalink
Improve configuration-cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Aug 11, 2023
1 parent 36be493 commit d7c1e0b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions plugin-utils/src/main/java/io/freefair/gradle/util/GitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.experimental.UtilityClass;
import org.codehaus.groovy.runtime.ProcessGroovyMethods;
import org.gradle.api.Project;
import org.gradle.process.ExecOutput;
import org.gradle.process.ExecResult;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -53,18 +54,14 @@ public String getRef(Project project) {

public static String execute(Project project, String... command) {

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

ExecResult execResult = project.exec(execSpec -> {
execSpec.workingDir(project.getProjectDir());
ExecOutput execOutput = project.getProviders().exec(execSpec -> {
execSpec.setWorkingDir(project.getProjectDir());
execSpec.commandLine((Object[]) command);
execSpec.setStandardOutput(outputStream);
});

if (execResult.getExitValue() == 0) {
return outputStream.toString().trim();
} else {
return null;
}
return execOutput.getStandardOutput().getAsText()
.map(String::trim)
.get();

}
}

0 comments on commit d7c1e0b

Please sign in to comment.