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

Gradle plugin support for dependencies in plugin descriptor properties #17178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abseth-amzn
Copy link
Contributor

Description

#11441 added support for semver ranges in dependencies of plugins. This commit updates the opensearchplugin (from org.opensearch.gradle:build-tools) to support dependencies property when building plugins. Without this support, plugin's plugin-descriptor.properties file would require manual update to add dependencies property. With this support, it would be possible to build plugins with semver range support for opensearch using gradle code. Example usage:

opensearchplugin {
  description = '<Plugin description>'
  classname = '<Plugin class name>'
  dependencies = '{opensearch: "3.0.0"}'
}

Since no plugin is currently using dependencies property, this change would simply add empty dependencies property to plugin-descriptor.properties file. Example:

description=The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index.
version=3.0.0-SNAPSHOT
name=mapper-murmur3
classname=org.opensearch.plugin.mapper.MapperMurmur3Plugin
java.version=21
opensearch.version=3.0.0
custom.foldername=
extended.plugins=
has.native.controller=false
dependencies=

Note - before this commit, opensearch process would reject above mentioned plugin-descriptor.properties file since it contains both opensearch.version and dependencies property. With this commit, PluginInfo is being updated to allow files like above since one of these properties is empty.
Hence this is a breaking change in opensearchplugin. The plugin-descriptor.properties file created by this plugin would not be accepted by older opensearch versions.

Following is an example of plugin-descriptor.properties file with dependencies property specified by the plugin in build.gradle (note empty opensearch.version property):

description=The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index.
version=3.0.0-SNAPSHOT
name=mapper-murmur3
classname=org.opensearch.plugin.mapper.MapperMurmur3Plugin
java.version=21
opensearch.version=
custom.foldername=
extended.plugins=
has.native.controller=false
dependencies={opensearch: "3.0.0"}

Related Issues

Resolves #13187

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

Signed-off-by: Abhilasha Seth <abseth@amazon.com>
@github-actions github-actions bot added Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. Build Libraries & Interfaces enhancement Enhancement or improvement to existing feature or request Plugins labels Jan 29, 2025
Copy link
Contributor

✅ Gradle check result for 9814445: SUCCESS

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 72.40%. Comparing base (3c55a31) to head (9814445).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
.../opensearch/gradle/plugin/PluginBuildPlugin.groovy 0.00% 2 Missing and 1 partial ⚠️
...earch/gradle/plugin/PluginPropertiesExtension.java 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17178      +/-   ##
============================================
+ Coverage     72.35%   72.40%   +0.04%     
- Complexity    65500    65662     +162     
============================================
  Files          5298     5306       +8     
  Lines        304603   304929     +326     
  Branches      44187    44256      +69     
============================================
+ Hits         220397   220777     +380     
+ Misses        66095    66035      -60     
- Partials      18111    18117       +6     

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

@rursprung
Copy link
Contributor

thanks @abseth-amzn!
may i (strongly) suggest backporting it to 2.x (namely 2.19 as it's supposed to be the last 2.x release)? that way future 2.19.x fix releases don't need re-releases of 3rd party plugins (if they start using the semver feature for their 2.19.0 release).

@@ -59,3 +59,6 @@ extended.plugins=${extendedPlugins}
#
# 'has.native.controller': whether or not the plugin has a native controller
has.native.controller=${hasNativeController}
#
# 'dependencies': any dependencies specified by the plugin
dependencies=${dependencies}
Copy link
Member

Choose a reason for hiding this comment

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

I see we are adding dependencies as another parameter to plugin-descriptor.properties. Why not re-use opensearch.version ?
PluginInfo.java[1] already processes semver range. May be we might have to change opensearch-plugin install cli but thats pretty much it.

[1] https://github.com/opensearch-project/OpenSearch/blame/e93791bc97b9791c422fa21e365df340cb8e2aa2/server/src/main/java/org/opensearch/plugins/PluginInfo.java#L291

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Support for 'dependencies' as another parameter was already introduced in #11441. After that change, Opensearch expects either 'opensearch.version' or 'dependencies' parameter in the plugin descriptor properties file.
https://github.com/opensearch-project/OpenSearch/blame/e93791bc97b9791c422fa21e365df340cb8e2aa2/server/src/main/java/org/opensearch/plugins/PluginInfo.java#L291

Today, the semver support only works if plugin descriptor file has a 'dependencies' section with 'opensearch' as the only supported dependency.
Example test showing a sample plugin descriptor properties file - https://github.com/opensearch-project/OpenSearch/pull/11441/files#diff-1311b3459a8afb363dd9ff9d584421c3a8292fed4b0d25535f10a2b4a9c98bc7R94

With this commit (17178), we are adding capability for the opensearch-plugin to add this new parameter to the plugin-descriptor.properties file that it generates, so that users can leverage semver feature.

Here is the discussion from one of the discarded PRs regarding adding support for new 'dependencies' section - #6837 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Libraries & Interfaces Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. enhancement Enhancement or improvement to existing feature or request Plugins skip-changelog
Projects
None yet
4 participants