Skip to content

Avoid eager getByName in pom validation plugin#19974

Merged
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:pom-validate-lazy
Nov 13, 2025
Merged

Avoid eager getByName in pom validation plugin#19974
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:pom-validate-lazy

Conversation

@andrross
Copy link
Copy Markdown
Member

The getByName() call is eager, which means this can fail non-deterministically if the dependent gradle tasks have not yet been configured. I ran into this error when doing other gradle refactorings. This change avoids the eager call while also avoiding the nested publications.all() call.

Check List

  • Functionality includes testing.

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.

The `getByName()` call is eager, which means this can fail
non-deterministically if the dependent gradle tasks have not yet been
configured. I ran into this error when doing other gradle refactorings.
This change avoids the eager call while also avoiding the nested
publications.all() call.

Signed-off-by: Andrew Ross <andrross@amazon.com>
@andrross andrross requested a review from a team as a code owner November 12, 2025 21:34
@andrross
Copy link
Copy Markdown
Member Author

@cwperks @zelinh Can you take a look? You were both involved in the original change here.

I did test this locally by removing the lines here in the geospatial plugin and verified that ./gradlew :libs:h3:validatePom still worked. Prior to @zelinh's change those extra dependencies were sometimes required in plugins to get things to work correctly.

@cwperks
Copy link
Copy Markdown
Member

cwperks commented Nov 12, 2025

The getByName() call is eager, which means this can fail non-deterministically if the dependent gradle tasks have not yet been configured.

Any idea what changed in gradle? I ran into issues updating the security plugin to gradle 9 due to eager loading as well.

@andrross
Copy link
Copy Markdown
Member Author

andrross commented Nov 12, 2025

The getByName() call is eager, which means this can fail non-deterministically if the dependent gradle tasks have not yet been configured.

Any idea what changed in gradle? I ran into issues updating the security plugin to gradle 9 due to eager loading as well.

@cwperks I think this is just fragile because there is an implicit dependency between tasks/projects that isn't fully modeled. As I understand it, you need to make sure every thing is lazy to avoid these issues. Alternatively, you can add evaluationDependsOn(...) to model dependencies between projects but that is generally not recommended and can lead to other problems.

@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 448b4db: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 448b4db: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.28%. Comparing base (2fddcd8) to head (448b4db).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...gradle/precommit/PomValidationPrecommitPlugin.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19974      +/-   ##
============================================
+ Coverage     73.25%   73.28%   +0.03%     
+ Complexity    71612    71602      -10     
============================================
  Files          5785     5785              
  Lines        326905   326900       -5     
  Branches      47280    47280              
============================================
+ Hits         239480   239584     +104     
+ Misses        68220    68090     -130     
- Partials      19205    19226      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrross andrross merged commit f0a1dba into opensearch-project:main Nov 13, 2025
42 of 49 checks passed
@andrross andrross deleted the pom-validate-lazy branch November 13, 2025 00:08
rgsriram pushed a commit to rgsriram/OpenSearch that referenced this pull request Dec 5, 2025
)

The `getByName()` call is eager, which means this can fail
non-deterministically if the dependent gradle tasks have not yet been
configured. I ran into this error when doing other gradle refactorings.
This change avoids the eager call while also avoiding the nested
publications.all() call.

Signed-off-by: Andrew Ross <andrross@amazon.com>
liuguoqingfz pushed a commit to liuguoqingfz/OpenSearch that referenced this pull request Dec 15, 2025
)

The `getByName()` call is eager, which means this can fail
non-deterministically if the dependent gradle tasks have not yet been
configured. I ran into this error when doing other gradle refactorings.
This change avoids the eager call while also avoiding the nested
publications.all() call.

Signed-off-by: Andrew Ross <andrross@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants