Skip to content

Conversation

@uttam282005
Copy link

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

  • Added GradleModuleMetadataHandler to parse *.module JSON metadata files.
  • Registered the new handler in APPLICATION_PACKAGE_DATAFILE_HANDLERS.
  • Added tests + fixture using opentest4j-1.3.0.module.
  • Updated --list-packages fixture output (Linux) after registering the handler.

Tests

  • py.test tests/packagedcode/test_gradle_module_metadata.py
  • py.test tests/packagedcode/test_plugin_package.py::TestPlugins::test_package_list_command

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled and links the original issue above
  • Tests pass locally
  • Commits are in a uniquely-named feature branch and has no merge conflicts
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Signed-off-by: uttam282005 uttam282005@gmail.com

Copilot AI review requested due to automatic review settings December 30, 2025 08:28
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>
Signed-off-by: uttam282005 <uttam282005@gmail.com>
@uttam282005 uttam282005 force-pushed the gradle-module-metadata branch from 308ae08 to b8a5afd Compare December 30, 2025 08:33
Copy link

Copilot AI left a 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 GradleModuleMetadataHandler class that extends MavenBasePackageHandler to parse *.module files
  • 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>
Copy link

Copilot AI left a 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)"
Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1554 to +1555
with io.open(location, encoding='utf-8') as f:
module_data = json.load(f)
Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.
Signed-off-by: uttam282005 <uttam282005@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collect Java modules details

1 participant