micronaut-projects / micronaut-maven-plugin

Maven plugin to execute Micronaut applications
https://micronaut-projects.github.io/micronaut-maven-plugin/latest/
Apache License 2.0
20 stars 19 forks source link

feat: simplify importing beans from project dependencies #1023

Closed auke- closed 4 months ago

auke- commented 4 months ago

Importing beans from dependencies which don't contain Micronaut bean definition classes can be cumbersome, it requires all the packages to be known upfront.

By generating a factory class with the @Import annotation for selected packages changes to the packages in dependencies are automatically handled.

See https://github.com/codegen-io/micronaut-import-plugin

Fixes https://github.com/micronaut-projects/micronaut-maven-plugin/issues/1021

alvarosanchez commented 4 months ago

@auke- thanks a lot for your PR! Looks great except for some minor comments.

Looks like CI fails for external contributions. I will try to fix it once you are done with your changes

auke- commented 4 months ago

@auke- thanks a lot for your PR! Looks great except for some minor comments.

Looks like CI fails for external contributions. I will try to fix it once you are done with your changes

Thanks for the review. Can you also take a look at the naming of the mojo, its goal and the parameters. I feel like generate-import-factory is a bit too technical and could be something like import-beans or something.

alvarosanchez commented 4 months ago

@auke- I fixed the CI and it ran the tests, and they failed:

Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/micronaut-maven-plugin/micronaut-maven-plugin/target/it/import-factory-enabled/target/generated-sources/importfactory/io/micronaut/build/examples/ImportFactory.java:[5,1] class, interface, enum, or record expected
[INFO] 1 error
[INFO] -------------------------------------------------------------

Seems like the generated class doesn't compile.

auke- commented 4 months ago

@auke- I fixed the CI and it ran the tests, and they failed:

Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/micronaut-maven-plugin/micronaut-maven-plugin/target/it/import-factory-enabled/target/generated-sources/importfactory/io/micronaut/build/examples/ImportFactory.java:[5,1] class, interface, enum, or record expected
[INFO] 1 error
[INFO] -------------------------------------------------------------

Seems like the generated class doesn't compile.

Thanks! I'll look at this, probably later this week. Have you seen my comment about the naming? Do you prefer the current names of the mojo and its parameters or the names I suggested (or even something else)?

alvarosanchez commented 4 months ago

Naming isn't really important, since users are not expected to invoke this mojo directly, since it's transparently incorporated into the build lifecycle.

auke- commented 4 months ago

Naming isn't really important, since users are not expected to invoke this mojo directly, since it's transparently incorporated into the build lifecycle.

Okay. I see you already fixed the compilation error, thanks!