-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Gradle plugin opensearch.pluginzip
Add implicit dependency.
#3189
Gradle plugin opensearch.pluginzip
Add implicit dependency.
#3189
Conversation
Signed-off-by: pgodithi <[email protected]>
Signed-off-by: pgodithi <[email protected]>
Signed-off-by: pgodithi <[email protected]>
Signed-off-by: pgodithi <[email protected]>
Signed-off-by: pgodithi <[email protected]>
Signed-off-by: pgodithi <[email protected]>
configMaven(project); | ||
Task validatePluginZipPom = project.getTasks().findByName("validatePluginZipPom"); | ||
if (validatePluginZipPom != null) { | ||
project.getTasks().getByName("validatePluginZipPom").mustRunAfter("generatePomFileForNebulaPublication"); |
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.
Just curious, why mustRunAfter
but not dependsOn
? We do not rely on any order, right?
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.
mustRunAfter controls the execution order of tasks explicitly, so this ensures the task generatePomFileForNebulaPublication
is called before the validatePluginZipPom
and publishPluginZipPublicationToZipStagingRepository
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.
dependsOn
does the same, mustRunAfter
mandates that task has to run exactly in order after the task in question: I don't think we have such exact order requirements, dependsOn
should be sufficient
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.
mustRunAfter
would ensure that task has been called out before those tasks. I have tested with mustRunAfter
and I dont see the warnings anymore, as mustRunAfter
calls that task before the dependent tasks @reta
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.
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.
I would suggest to switch to dependsOn
, it introduces implicit dependencies (which is what we need, because our publication depends on it) [1]:
A task may have dependencies on other tasks or might be scheduled to always run after another task. Gradle ensures that all task dependencies and ordering rules are honored when executing tasks, so that the task is executed after all of its dependencies and any "must run after" tasks have been executed.
but mustRunAfter
does merely controls the order [2]:
When you use the “must run after” ordering rule you specify that taskB must always run after taskA, whenever both taskA and taskB will be run.
The difference is actually very easy to demonstrate: if you just run a single publishPluginZipPublicationToZipStagingRepository
task, none of the mustRunAfter
tasks will be executed (notice generatePomFileForNebulaPublication
is not there):
./gradlew -m publishPluginZipPublicationToZipStagingRepository
:generateNotice SKIPPED
:compileJava SKIPPED
:processResources SKIPPED
:classes SKIPPED
:jar SKIPPED
:copyPluginPropertiesTemplate SKIPPED
:pluginProperties SKIPPED
:bundlePlugin SKIPPED
:generatePomFileForPluginZipPublication SKIPPED
:publishPluginZipPublicationToZipStagingRepository SKIPPED
Now, using dependsOn
(notice generatePomFileForNebulaPublication
is there):
./gradlew -m publishPluginZipPublicationToZipStagingRepository
:generateNotice SKIPPED
:compileJava SKIPPED
:processResources SKIPPED
:classes SKIPPED
:jar SKIPPED
:copyPluginPropertiesTemplate SKIPPED
:pluginProperties SKIPPED
:bundlePlugin SKIPPED
:generatePomFileForNebulaPublication SKIPPED
:generatePomFileForPluginZipPublication SKIPPED
:publishPluginZipPublicationToZipStagingRepository SKIPPED
Hope it is sufficient to justify dependsOn
usage.
[1] https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#N18A16
[2] https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:ordering_tasks
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.
But both works here slightly_smiling_face
I hope the examples above help to clarify when it does not work
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.
Thanks for the info @reta .
-m
shows the task actions disabled, here our initial error is because we have a task generatePomFileForNebulaPublication
that has been not called and these validatePluginZipPom
& publishPluginZipPublicationToZipStagingRepository
actually uses the output of generatePomFileForNebulaPublication
, using mustRun
will ensure this task generatePomFileForNebulaPublication
has been invoked when ever the tasks validatePluginZipPom
& publishPluginZipPublicationToZipStagingRepository
are triggered, which should solve the output dependency, hence I mentioned running build
should work, even though it does not show with -m
output mustRun
ensures it will execute the task.
But that said dependsOn
should also work as we are adding exclusive graph dependency, I have updated my latest commit with dependsOn
and ran few plugins build.sh
and runs fine, please check @reta
if (validatePluginZipPom != null) { | ||
project.getTasks().getByName("validatePluginZipPom").mustRunAfter("generatePomFileForNebulaPublication"); | ||
} | ||
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks() |
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.
I think we should not use exact task name here but rely on the task type as per [1]:
project.getTasks().withType(PublishToMavenRepository.class).configureEach(t -> {
if (t.getPublication().getName().equals(PUBLICATION_NAME)) {
t.dependsOn(pomFileTask);
}
});
The reason for it is that we may publish to different repositories (fe local Maven) and that would be different task name, still requiring same task dependencies.
[1] https://github.com/opensearch-project/OpenSearch/pull/3183/files
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.
True, I already have PUBLICATION_NAME
var declared I can use that. I will push the change shortly.
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.
Hey @reta I assumed wrong, my bad, here we should be good, using this Plugin we dont push to any other repos, its strictly to pluginZip
repo that generates fixed task publishPluginZipPublicationToZipStagingRepository
, hence we should be good to hardcode, initially I have created few utils that can identify the PUBLICATION_NAME
and taskname, but since its only single publication here using this plugin, I have had some conversations in this merged PR to hard code things, so long story short we should be good to hardcode task names.
Signed-off-by: pgodithi <[email protected]>
Thanks @reta |
@reta You should feel free to merge anything that you see fit without any additional approvals. |
* Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add dependsOn Signed-off-by: pgodithi <[email protected]> (cherry picked from commit 2fe2e37)
* Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add dependsOn Signed-off-by: pgodithi <[email protected]> (cherry picked from commit 2fe2e37)
…#3211) * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add dependsOn Signed-off-by: pgodithi <[email protected]> (cherry picked from commit 2fe2e37) Co-authored-by: Prudhvi Godithi <[email protected]>
…#3212) * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add implicit dependency Signed-off-by: pgodithi <[email protected]> * Add dependsOn Signed-off-by: pgodithi <[email protected]> (cherry picked from commit 2fe2e37) Co-authored-by: Prudhvi Godithi <[email protected]>
Signed-off-by: pgodithi [email protected]
Description
This fix will remove the following warning's during runtime
Issues Resolved
#3183
opensearch-project/opensearch-plugin-template-java#31
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.