-
-
Notifications
You must be signed in to change notification settings - Fork 652
Add Gradle Module Metadata (*.module) package handler
#4652
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
base: develop
Are you sure you want to change the base?
Add Gradle Module Metadata (*.module) package handler
#4652
Conversation
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Signed-off-by: uttam282005 <uttam282005@gmail.com>
308ae08 to
b8a5afd
Compare
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.
Pull request overview
This pull request adds support for parsing Gradle Module Metadata (*.module) files that are published alongside Maven artifacts. The implementation extracts core package information (GAV coordinates), checksums, file sizes, and Gradle-specific metadata from JSON-formatted module files.
Key Changes
- Added
GradleModuleMetadataHandlerclass that extendsMavenBasePackageHandlerto parse*.modulefiles - Registered the new handler in the package datafile handlers list
- Added comprehensive test coverage using a real-world example (opentest4j-1.3.0)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 44 comments.
Show a summary per file
| File | Description |
|---|---|
src/packagedcode/maven.py |
Implements the GradleModuleMetadataHandler class with parsing logic for Gradle module metadata JSON files |
src/packagedcode/__init__.py |
Registers GradleModuleMetadataHandler in the APPLICATION_PACKAGE_DATAFILE_HANDLERS list |
tests/packagedcode/test_gradle_module_metadata.py |
Comprehensive test suite covering basic fields, variant metadata, error handling, and description formatting |
tests/packagedcode/data/gradle_module_metadata/opentest4j-1.3.0/opentest4j-1.3.0.module |
Test fixture containing real Gradle module metadata from Maven Central |
tests/packagedcode/data/plugin/plugins_list_linux.txt |
Updated expected output after registering the new handler |
AUTHORS.rst |
Added contributor credit |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Signed-off-by: uttam282005 <uttam282005@gmail.com>
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.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 21 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pkg = packages[0] | ||
|
|
||
| # Format is defined by _build_description() | ||
| assert pkg.description == "opentest4j version 1.3.0 (status: release)" |
Copilot
AI
Dec 30, 2025
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.
Consider adding a test case to verify the behavior when variants list is empty or when none of the variants contain the primary JAR file. This would ensure robustness of the _extract_primary_file_data method in edge cases.
| with io.open(location, encoding='utf-8') as f: | ||
| module_data = json.load(f) |
Copilot
AI
Dec 30, 2025
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.
The handler lacks JSON parsing error handling. If the file contains invalid JSON, the parse method will raise an unhandled JSONDecodeError. Consider wrapping the json.load call in a try-except block to gracefully handle malformed JSON files, similar to how other handlers in the codebase handle parsing errors.
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Fixes #4624
Summary
Add support for parsing Gradle Module Metadata (
*.module) files published alongside Maven artifacts (e.g. on Maven Central). The new handler extracts core GAV coordinates, checksums/size for the primary jar, Gradle metadata, and variants information.What changed
GradleModuleMetadataHandlerto parse*.moduleJSON metadata files.APPLICATION_PACKAGE_DATAFILE_HANDLERS.opentest4j-1.3.0.module.--list-packagesfixture output (Linux) after registering the handler.Tests
py.test tests/packagedcode/test_gradle_module_metadata.pypy.test tests/packagedcode/test_plugin_package.py::TestPlugins::test_package_list_commandTasks
Signed-off-by: uttam282005 uttam282005@gmail.com