Skip to content
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

Improvement usage of gradle task avoidance api #56627

Merged

Conversation

breskeby
Copy link
Contributor

@breskeby breskeby commented May 12, 2020

Use gradle task avoidance everywhere we generate a task.

  • partially addresses Gradle task avoidance api should be used consistently in the build #56610

  • Moving from task.create() to tasks.register() means that the linked configuration block is not always executed. That leads to side effects in some parts of the elasticsearch build that require more rework of how certain tasks and plugins are cutted. (e.g. how Rest testing is setup). This is out of scope of this PR.

  • also not in scope: minimizing task realisation. We should optimise for that once we finished using the api consistently.

@breskeby breskeby force-pushed the improvement/use-gradle-task-avoidance-api branch from fee92e5 to dd497ec Compare May 13, 2020 10:30
@breskeby
Copy link
Contributor Author

@elasticmachine test this please

@breskeby breskeby force-pushed the improvement/use-gradle-task-avoidance-api branch 3 times, most recently from 4cedb32 to 3b61b94 Compare May 14, 2020 11:24
@breskeby
Copy link
Contributor Author

@elasticmachine test this please

@breskeby breskeby force-pushed the improvement/use-gradle-task-avoidance-api branch from a8d1c06 to 30d4542 Compare May 14, 2020 15:00
@breskeby
Copy link
Contributor Author

@elasticmachine test this please

@breskeby breskeby force-pushed the improvement/use-gradle-task-avoidance-api branch from 5e6334c to d3112a4 Compare May 15, 2020 08:39
@breskeby breskeby force-pushed the improvement/use-gradle-task-avoidance-api branch from 19d2457 to 85ee4b9 Compare May 15, 2020 13:20
@@ -1,5 +1,5 @@
jar {
archiveName = "${project.name}.jar"
archiveFileName = "${project.name}.jar"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix deprecation warning on the way

@breskeby breskeby changed the title Improvement/use gradle task avoidance api Improvement usage of gradle task avoidance api May 15, 2020
@breskeby breskeby marked this pull request as ready for review May 15, 2020 16:21
@breskeby breskeby requested a review from mark-vieira May 15, 2020 16:21
@breskeby breskeby added the :Delivery/Build Build or test infrastructure label May 15, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Build)

@breskeby breskeby self-assigned this May 15, 2020
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label May 15, 2020
@breskeby
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments but otherwise LGTM.

Got any numbers of config time improvement, if any?

@@ -485,7 +485,7 @@ allprojects {
if (realTask == null) {
return
}
project.tasks.create(taskName) {
project.tasks.register(taskName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this strictly beneficial since this task rule should only run when it finds a task matching this naming convention, right? Granted, it doesn't hurt, just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think we just should use register over create where possible. In a later step we need to revisit the actual behaviour and when they got materialised anyhow, but more on a per case fashion I think as thinks get complex there.

There are use cases where tasks in a rule would not be created but registered. You can depend on tasks that are created by a rule, e.g. you could have `myTask.dependsOn tasks.named("cleanCompileJava"). The rule would kick in so the task would be registered, but it doesn't need to be created.

stop.doLast {
project.delete(fixture.pidFile)
TaskProvider<Exec> stop = project.tasks.register("${name}#stop", LoggedExec)
stop.configure{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing space stop.configure {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


// TODO: The task configuration block has side effects that require it currently to be always executed.
// Otherwise tests start failing. Therefore we enforce the task creation for now.
tsk.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just use create() then? This seems even more confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping create() might look like an oversight. I think this way makes it more explicit that there is something wrong with the task setup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, let's create an issue to look into what the task configuration block is doing that's required for test setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done here: #56948

Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM 👍

@breskeby breskeby merged commit 731b282 into elastic:master May 19, 2020
breskeby added a commit to breskeby/elasticsearch that referenced this pull request May 20, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
breskeby added a commit to breskeby/elasticsearch that referenced this pull request May 20, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
breskeby added a commit to breskeby/elasticsearch that referenced this pull request May 20, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
breskeby added a commit that referenced this pull request May 25, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
breskeby added a commit that referenced this pull request May 25, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
breskeby added a commit that referenced this pull request May 25, 2020
Use gradle task avoidance api wherever it is possible as a drop in replacement in the es build
@breskeby
Copy link
Contributor Author

back ported

@mark-vieira mark-vieira added Team:Delivery Meta label for Delivery team and removed Team:Core/Infra Meta label for core/infra team labels Nov 11, 2020
@breskeby breskeby deleted the improvement/use-gradle-task-avoidance-api branch December 10, 2024 13:56
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.7.1 v7.8.1 v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants