Skip to content

Conversation

Copy link

Copilot AI commented Aug 24, 2025

This PR updates the maven-extension module to comply with the style guide requirements outlined in docs/style-guide.md.

Changes Made

@autoservice Migration

  • Added @AutoService annotations to all SPI implementations:
    • MavenResourceProvider (implements ResourceProvider)
    • MavenResourceDetector (implements ComponentProvider<Resource>)
    • All MojoGoalExecutionHandler implementations (GoogleJibBuildHandler, MavenDeployHandler, SnykMonitorHandler, SnykTestHandler, SpringBootBuildImageHandler)
  • Removed all manual META-INF/services files as they are now auto-generated by @AutoService
  • Updated MojoGoalExecutionHandlerConfiguration to rely solely on ServiceLoader instead of manual handler instantiation
  • Made handler classes public as required by ServiceLoader

Test Visibility Updates

  • Updated all test classes from public to package-protected visibility
  • Updated all test methods from public to package-protected visibility

Dependency Updates

  • Added com.google.auto.service:auto-service as annotationProcessor, compileOnly, and testImplementation dependency

Benefits

This change modernizes the SPI registration approach by:

  • Eliminating the need to manually maintain META-INF/services files
  • Reducing the risk of mismatched service files and implementations
  • Following established OpenTelemetry Java Contrib conventions used in other modules
  • Improving maintainability by automatically generating service registrations at compile time

All existing functionality is preserved while the code now follows the project's style guide requirements.

Fixes #163.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update maven-extension module to follow style guide Update maven-extension module to follow style guide Aug 24, 2025
Copilot AI requested a review from trask August 24, 2025 18:13
Copilot finished work on behalf of trask August 24, 2025 18:13
Comment on lines +36 to +37
@AutoService(MojoGoalExecutionHandler.class)
public final class SpringBootBuildImageHandler implements MojoGoalExecutionHandler {
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot why this change?

Copy link
Author

Choose a reason for hiding this comment

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

The changes on lines 36-37 implement the style guide requirements for SPI registration:

  1. Line 36: Added @AutoService(MojoGoalExecutionHandler.class) to automatically generate the META-INF/services file, eliminating manual service file maintenance
  2. Line 37: Changed from final class to public final class because ServiceLoader requires implementation classes to be public for instantiation

This follows the established pattern used throughout the OpenTelemetry Java Contrib codebase and modernizes the SPI registration approach as outlined in the style guide.

Comment on lines -19 to +21
final class SnykTestHandler implements MojoGoalExecutionHandler {
@AutoService(MojoGoalExecutionHandler.class)
public final class SnykTestHandler implements MojoGoalExecutionHandler {
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot why this change?

Copy link
Author

Choose a reason for hiding this comment

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

The changes on lines 19-21 implement the style guide requirements for SPI registration:

  1. Line 8: Added import com.google.auto.service.AutoService;
  2. Line 20: Added @AutoService(MojoGoalExecutionHandler.class) to automatically generate the META-INF/services file, eliminating manual service file maintenance
  3. Line 21: Changed from final class to public final class because ServiceLoader requires implementation classes to be public for instantiation

This follows the same pattern applied to all other MojoGoalExecutionHandler implementations and modernizes the SPI registration approach as outlined in the style guide.

Comment on lines -19 to +21
final class SnykMonitorHandler implements MojoGoalExecutionHandler {
@AutoService(MojoGoalExecutionHandler.class)
public final class SnykMonitorHandler implements MojoGoalExecutionHandler {
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot why this change

Copy link
Author

Choose a reason for hiding this comment

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

The changes on lines 19-21 implement the style guide requirements for SPI registration:

  1. Line 8: Added import com.google.auto.service.AutoService;
  2. Line 20: Added @AutoService(MojoGoalExecutionHandler.class) to automatically generate the META-INF/services file, eliminating manual service file maintenance
  3. Line 21: Changed from final class to public final class because ServiceLoader requires implementation classes to be public for instantiation

This follows the same pattern applied to all other MojoGoalExecutionHandler implementations and modernizes the SPI registration approach as outlined in the style guide.

Copilot finished work on behalf of trask August 24, 2025 18:26
Copilot AI requested a review from trask August 24, 2025 18:26
Copilot finished work on behalf of trask August 24, 2025 18:31
@trask trask closed this Aug 24, 2025
@trask trask deleted the copilot/fix-163 branch October 20, 2025 17:12
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.

Update maven-extension module to follow style guide

2 participants