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

@BuildSteps in an extension processor are considered unused methods #1095

Closed
gastaldi opened this issue Aug 9, 2023 · 8 comments · Fixed by #1099
Closed

@BuildSteps in an extension processor are considered unused methods #1095

gastaldi opened this issue Aug 9, 2023 · 8 comments · Fixed by #1099
Assignees
Labels
enhancement New feature or request quarkus Quarkus support
Milestone

Comments

@gastaldi
Copy link
Contributor

gastaldi commented Aug 9, 2023

@BuildSteps in an extension processor are considered unused methods in IJ, which is not true

Originally posted by @gastaldi in #1094 (comment)

@gastaldi
Copy link
Contributor Author

gastaldi commented Aug 9, 2023

The plugin should only mark the method as unused if it's not reachable by the Quarkus build processor

@fbricon
Copy link
Contributor

fbricon commented Aug 10, 2023

@gastaldi do you have a small project example of @BuildStep usage?
How do we know if the annotated method is "not reachable by the Quarkus build processor"?

@gastaldi
Copy link
Contributor Author

gastaldi commented Aug 10, 2023

@gastaldi do you have a small project example of @BuildStep usage?

@fbricon yes, any Quarkus extension does that, here is an example: https://github.com/quarkiverse/quarkus-prettytime/blob/main/deployment/src/main/java/io/quarkiverse/prettytime/deployment/PrettyTimeProcessor.java

How do we know if the annotated method is "not reachable by the Quarkus build processor"?

That's the tricky part. If you build the integration-tests project with -Djboss.builder.graph-output=file.dot (changing to quarkus.builder.graph-output in quarkusio/quarkus#35299) you get a DOT file with the invocation graph

@fbricon
Copy link
Contributor

fbricon commented Aug 10, 2023

Making methods annotated with @BuildStep show as used is easy

However, running a build as part of the validation, to check if it's found in a dot file is probably not gonna happen.

  • it requires building the project 1st, then applying it on a test project
  • it might take an unreasonably long time

@gastaldi
Copy link
Contributor Author

Making methods annotated with @BuildStep show as used is easy

I think that's a good start.

However, running a build as part of the validation, to check if it's found in a dot file is probably not gonna happen.

  • it requires building the project 1st, then applying it on a test project
  • it might take an unreasonably long time

I agree, and I am not sure what would be the best solution here. Maybe @dmlloyd has any idea?

@fbricon fbricon added enhancement New feature or request quarkus Quarkus support labels Aug 10, 2023
@fbricon fbricon added this to the 1.25.0 milestone Aug 10, 2023
@fbricon fbricon self-assigned this Aug 10, 2023
@angelozerr angelozerr moved this to ✅ Done in IDE Cloudaptors Aug 10, 2023
@dmlloyd
Copy link

dmlloyd commented Aug 24, 2023

I'm late on this (PTO) but @BuildStep should always be considered used.

Build step methods are contextually part of an extension's deployment module. The deployment module is independent of any particular application. The steps actually used for an application are dependent on the extensions present, the configuration of the application, and the application's content. A build step method may validly rely on an extension that isn't even present for some applications. Since an extension is usable for many applications, it doesn't make sense to make assumptions about the use of a given build step method based on a single application, thus build steps should always be considered used unless it can be proven locally within the extension itself that the step can never run.

@fbricon
Copy link
Contributor

fbricon commented Aug 24, 2023

@dmlloyd thanks that was my intuition. BTW do you know of any other Quarkus annotations that, when used, should mark the code as implicitly used? Feel free to use intellij-quarkus to detect that ;-)

@dmlloyd
Copy link

dmlloyd commented Aug 24, 2023

Not offhand, but if I think of any I'll mention them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request quarkus Quarkus support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants