-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make LoggedExec gradle task configuration cache compatible #87621
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
breskeby
merged 19 commits into
elastic:master
from
breskeby:make-logged-exec-cc-compatible
Jul 11, 2022
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4a3e0fd
Make LoggedExec gradle task configuration cache compatible
breskeby ade700a
WIP
breskeby 7b303eb
Rework LoggedExec task to not extend Exec
breskeby 4c8b35c
Apply changed LoggedExec api
breskeby fdf1310
Fix LoggedExec api usage in scripts
breskeby 95c157f
Fix environment nesting in LoggedExec task
breskeby 112b818
Api Polishing on LoggedExec task
breskeby 7988923
Fix AntFixture rework
breskeby 6606874
Tweak some api and test coverage
breskeby 0cfdb49
Simplify output handling
breskeby 72549d5
Some more cleanup
breskeby 4ec6fdd
Update AbstractGradleFuncTest.groovy
breskeby c234915
Update build-tools/src/main/java/org/elasticsearch/gradle/LoggedExec.…
breskeby c23f96e
Apply review feedback and add test coverage
breskeby ad69568
Fix gradle plugin tests
breskeby 92108e3
Fix tests on linux
breskeby 35569b7
Apply review feedback
breskeby b7b42d1
Apply review feedback
breskeby 50367f7
Fix tests after reworking indented output handling
breskeby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -69,29 +69,27 @@ public void apply(Project project) { | |
| TaskContainer tasks = project.getTasks(); | ||
| TaskProvider<LoggedExec> createCloneTaskProvider = tasks.register("createClone", LoggedExec.class, createClone -> { | ||
| createClone.onlyIf(task -> this.gitExtension.getCheckoutDir().get().exists() == false); | ||
| createClone.setCommandLine(asList("git", "clone", buildLayout.getRootDirectory(), gitExtension.getCheckoutDir().get())); | ||
| createClone.commandLine("git", "clone", buildLayout.getRootDirectory(), gitExtension.getCheckoutDir().get()); | ||
| }); | ||
|
|
||
| ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties(); | ||
| TaskProvider<LoggedExec> findRemoteTaskProvider = tasks.register("findRemote", LoggedExec.class, findRemote -> { | ||
| findRemote.dependsOn(createCloneTaskProvider); | ||
| // TODO Gradle should provide property based configuration here | ||
| findRemote.setWorkingDir(gitExtension.getCheckoutDir().get()); | ||
| findRemote.setCommandLine(asList("git", "remote", "-v")); | ||
| ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
| findRemote.setStandardOutput(output); | ||
| findRemote.doLast(t -> { extraProperties.set("remoteExists", isRemoteAvailable(remote, output)); }); | ||
| findRemote.getWorkingDir().set(gitExtension.getCheckoutDir()); | ||
| findRemote.commandLine("git", "remote", "-v"); | ||
| findRemote.getCaptureOutput().set(true); | ||
| findRemote.doLast(t -> { extraProperties.set("remoteExists", isRemoteAvailable(remote, findRemote.getOutput())); }); | ||
| }); | ||
|
|
||
| TaskProvider<LoggedExec> addRemoteTaskProvider = tasks.register("addRemote", LoggedExec.class, addRemote -> { | ||
| addRemote.dependsOn(findRemoteTaskProvider); | ||
| addRemote.onlyIf(task -> ((boolean) extraProperties.get("remoteExists")) == false); | ||
| addRemote.setWorkingDir(gitExtension.getCheckoutDir().get()); | ||
| addRemote.getWorkingDir().set(gitExtension.getCheckoutDir().get()); | ||
|
||
| String remoteRepo = remote.get(); | ||
| // for testing only we can override the base remote url | ||
| String remoteRepoUrl = providerFactory.systemProperty("testRemoteRepo") | ||
| .getOrElse("https://github.com/" + remoteRepo + "/elasticsearch.git"); | ||
| addRemote.setCommandLine(asList("git", "remote", "add", remoteRepo, remoteRepoUrl)); | ||
| addRemote.commandLine("git", "remote", "add", remoteRepo, remoteRepoUrl); | ||
| }); | ||
|
|
||
| boolean isOffline = project.getGradle().getStartParameter().isOffline(); | ||
|
|
@@ -107,8 +105,8 @@ public void apply(Project project) { | |
| }); | ||
| fetchLatest.onlyIf(t -> isOffline == false && gitFetchLatest.get()); | ||
| fetchLatest.dependsOn(addRemoteTaskProvider); | ||
| fetchLatest.setWorkingDir(gitExtension.getCheckoutDir().get()); | ||
| fetchLatest.setCommandLine(asList("git", "fetch", "--all")); | ||
| fetchLatest.getWorkingDir().set(gitExtension.getCheckoutDir().get()); | ||
|
||
| fetchLatest.commandLine("git", "fetch", "--all"); | ||
| }); | ||
|
|
||
| String projectPath = project.getPath(); | ||
|
|
@@ -210,7 +208,7 @@ private String execInCheckoutDir(Action<ExecSpec> execSpecConfig) { | |
| return os.toString().trim(); | ||
| } | ||
|
|
||
| private static boolean isRemoteAvailable(Provider<String> remote, ByteArrayOutputStream output) { | ||
| return new String(output.toByteArray()).lines().anyMatch(l -> l.contains(remote.get() + "\t")); | ||
| private static boolean isRemoteAvailable(Provider<String> remote, String output) { | ||
| return output.lines().anyMatch(l -> l.contains(remote.get() + "\t")); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to call
get()here oncheckoutDir.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍