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

jooby-apt: MVC generated controllers require jakarta-inject should be documented because of code generation. #3460

Closed
agentgt opened this issue Jul 2, 2024 · 2 comments

Comments

@agentgt
Copy link
Contributor

agentgt commented Jul 2, 2024

Because we now generate the code for MVC controllers one has to make sure to add the jakarta inject dependency as scope compile/provided.

Alternatively we could make the io.jooby:jooby pom depend on it so it automatically gets pulled in but that may not go over well with folks that use the fluent api instead.

So at the minimum I'm thinking we just add it to the documentation that they need to add:

<dependency>
    <groupId>jakarta.inject</groupId>
    <artifactId>jakarta.inject-api</artifactId>
    <version>2.0.1</version>
</dependency>

Happy to do the changes on this or the previous bugs I filed recently to help out.


Also for the code generation maybe consider doing:

@SuppressWarnings("exports") // add this annotation
public OpsController_(jakarta.inject.Provider<OpsController> provider)

The above annotation will then make modular builds not show a warning if one does only:

requires jakarta.inject;

Otherwise they will have to do:

requires transitive jakarta.inject;

Because the constructor is public.

However it maybe required to use the transitive regardless if reflective access is used (this I'm unsure on and need to test).

If is required than we need to document it as well that one needs to add requires transitive.

@jknack
Copy link
Member

jknack commented Jul 2, 2024

will change to Supplier

@jknack jknack added this to the 3.2.4 milestone Jul 2, 2024
@agentgt
Copy link
Contributor Author

agentgt commented Jul 2, 2024

Well that is a much better solution and feel stupid for not recommending it 😆

@jknack jknack changed the title MVC generated controllers require jakarta-inject should be documented because of code generation. jooby-apt: MVC generated controllers require jakarta-inject should be documented because of code generation. Jul 2, 2024
@jknack jknack closed this as completed in 7826ddd Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants