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

Get rid of Reflections in PluginCompatTesterHooks #481

Merged
merged 1 commit into from
Mar 3, 2023
Merged

Conversation

basil
Copy link
Member

@basil basil commented Mar 1, 2023

Fixes #394 by dropping the dependency on Reflections in favor of ServiceLoader. This requires each hook to be annotated with @MetaInfServices(PluginCompatTesterHookBeforeCheckout.class), @MetaInfServices(PluginCompatTesterHookBeforeCompile.class), or @MetaInfServices(PluginCompatTesterHookBeforeExecution.class) and obviates the need for a --hook-prefixes option. To test this I verified in the debugger that the same hooks got loaded as before this PR (in the same order).

@basil basil added the breaking label Mar 1, 2023
@basil basil requested a review from a team as a code owner March 1, 2023 23:05
Comment on lines +93 to +95
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<version>1.9</version>
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed to create the META-INF/services entries for these hooks to be loadable via ServiceLoader.

Comment on lines -195 to -211
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- Version specified in parent POM -->
<configuration>
<annotationProcessorPaths>
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>${picocli.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
</compilerArgs>
</configuration>
</plugin>
Copy link
Member Author

Choose a reason for hiding this comment

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

This was interfering with the registration of the metainf-services annotation processor. Since it was optional, I opted to dispense with it rather than debug it.

Comment on lines -133 to -141
@CheckForNull
@CommandLine.Option(
names = "--hook-prefixes",
split = ",",
arity = "1",
paramLabel = "prefix",
description = "Comma-separated list of prefixes of extra hook classes.")
private List<String> hookPrefixes;

Copy link
Member Author

Choose a reason for hiding this comment

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

No longer makes sense now that an annotation is the explicit way to opt in.

@basil basil requested a review from jtnord March 1, 2023 23:08
@basil basil merged commit fc5b653 into master Mar 3, 2023
@basil basil deleted the services branch March 3, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of Reflections in PluginCompatTesterHooks
2 participants