-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use services for archive and file operations in tasks #62968
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 6 commits into
elastic:master
from
breskeby:do-not-use-project-in-taskaction
Oct 1, 2020
Merged
Use services for archive and file operations in tasks #62968
breskeby
merged 6 commits into
elastic:master
from
breskeby:do-not-use-project-in-taskaction
Oct 1, 2020
Conversation
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
Collaborator
|
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
fde27af to
f4eaa73
Compare
mark-vieira
reviewed
Sep 29, 2020
Contributor
mark-vieira
left a comment
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.
Few comments.
buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchTestBasePlugin.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/java/org/elasticsearch/gradle/FileSystemOperationsAware.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/java/org/elasticsearch/gradle/LoggedExec.java
Outdated
Show resolved
Hide resolved
Contributor
Author
|
My initial thought here was that we should use method injector in favorite of constructor injection as this would have a slight benefit in performance as this service would not have been resolved if it’s not user. But thinking again since you asked we probably can move to the more idiomatic constructor injection as
1. with task avoidance api those tasks should only be created if needed,
2. when the service is used in configuration time it doesn’t matter as it’s always used
3. those services are created already anyhow as they’re likely used within gradle core already.
I‘m moving to constructor invocation.
… On 30. Sep 2020, at 00:57, Mark Vieira ***@***.***> wrote:
@mark-vieira commented on this pull request.
Few comments.
In buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchTestBasePlugin.java:
> @@ -38,6 +38,7 @@
import java.util.Map;
import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure;
+import static org.gradle.util.GFileUtils.mkdirs;
This is psudo-internal. Can we rely on this?
In buildSrc/src/main/java/org/elasticsearch/gradle/FileSystemOperationsAware.java:
> + * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.elasticsearch.gradle;
+
+import org.gradle.api.tasks.WorkResult;
+
+/**
+ * A marker interface for tasks signaling that they support basic file operations.
+ * Methods will be added as needed.
+ */
+
+public interface FileSystemOperationsAware {
+ WorkResult delete(Object... objects);
Not really a "marker" interface if it defines methods. I'm not sure this provides a lot of benefit, as is. Perhaps we can have the interface define the injected method to be implemented by supporting types then provide default method impls that delegate to getFileSystemOperations()?
In buildSrc/src/main/java/org/elasticsearch/gradle/LoggedExec.java:
>
private static final Logger LOGGER = Logging.getLogger(LoggedExec.class);
private Consumer<Logger> outputLogger;
+ @Inject
+ protected FileSystemOperations getFileSystemOperations() {
+ throw new UnsupportedOperationException();
Can't we inject this into the constructor as well? If so, doesn't that avoid having this weird exception throwing method implementation?
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Contributor
Author
|
@elasticmachine test this please |
Contributor
👍 |
mark-vieira
approved these changes
Sep 30, 2020
- Use constructor injection were adequate - Do not rely on pseudo internal gradle api
59be9da to
b491689
Compare
breskeby
added a commit
to breskeby/elasticsearch
that referenced
this pull request
Oct 2, 2020
Referencing a project instance during task execution is discouraged by Gradle and should be avoided. E.g. It is incompatible with Gradles incubating configuration cache. Instead there are services available to handle archive and filesystem operations in task actions. Brings us one step closer to elastic#57918
breskeby
added a commit
that referenced
this pull request
Oct 5, 2020
Referencing a project instance during task execution is discouraged by Gradle and should be avoided. E.g. It is incompatible with Gradles incubating configuration cache. Instead there are services available to handle archive and filesystem operations in task actions. Brings us one step closer to #57918
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
:Delivery/Build
Build or test infrastructure
Team:Delivery
Meta label for Delivery team
v7.10.0
v8.0.0-alpha1
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.
Referencing a project instance during task execution is discouraged by
Gradle and should be avoided. E.g. It is incompatible with Gradles
incubating configuration cache. Instead there are services available to handle
archive and filesystem operations in task actions.
Brings us one step closer to Elasticsearch build and Gradle plugins should support Gradle configuration cache #57918