Handle Gradle dependencies in modules
Following https://github.com/jhipster/jhipster-lite/issues/1787 we can add gradle dependencies handling.
TODO:
- [ ] Update
FileSystemCurrentJavaDependenciesVersionsRepositoryto have a strategy to handle either maven or gradle - [ ] Create a
JavaDependenciesCommandHandlerinterface based onMavenCommandHandler - [ ] Create a
GradleCommandHandler(which is aJavaDependenciesCommandHandler) - [ ] Update
FileSystemJavaDependenciesCommandsHandlerto create the most suited handler (depending on project version management)
@DamnClin I have created a first draft PR, maybe you can have a short look if thats heading in the right direction https://github.com/jhipster/jhipster-lite/pull/2748
@atomfrede : do you still intend to work on this feature? otherwise I would be happy to give it a try :-)
Feel to go on. I did not much so far. I think I would have tried rewrite to handle e.g. the dependency part.
@murdos : if possible, try to split into small PRs or small tickets, as it will be easier to review and to add small bounties on each ;)
@murdos : if possible, try to split into small PRs or small tickets, as it will be easier to review and to add small bounties on each ;)
My current roadmap is:
For resolving this issue:
- [x] introduce version catalogs feature with TOML in gradle build tool module: it seems to be the good practice, and will ease simplify manipulation of gradle build files that are hard to parse (I was thinking about using needles for that): https://github.com/jhipster/jhipster-lite/pull/4954
- [x] Introduce GradleCommandHandler and JavaDependenciesCommandHandler interface, and implements the handling of the
SetVersioncommand: https://github.com/jhipster/jhipster-lite/pull/5060 - [x] Handle other dependencies related commands:
- [x]
(Add|Remove)DirectJavaDependency: https://github.com/jhipster/jhipster-lite/pull/7091 - [x]
(Add|Remove)JavaDependencyManagement: https://github.com/jhipster/jhipster-lite/pull/7369
- [x]
- [x] Adapt CI tests and scripts to allow testing gradle projects: https://github.com/jhipster/jhipster-lite/pull/4952/
In other issues:
- [ ] Handle plugins related commands, but probably in another issue, since it will probably requires changing API related to build plugins in module builder (related to this comment and to the fact that plugin in gradle only have an id and a version - no groupId and artifactId) : https://github.com/jhipster/jhipster-lite/issues/4955
- [ ] Review all existing modules and add gradle plugins equivalent to maven ones
- [ ] Stop hidding gradle build tool resources slug! :-)
@murdos Did you do already something with regards to dependency handling? If not I will try to have a look at the open rewrite approach. They have recipes for all things we need, so maybe we can use that.
I have work-in-progress using needles. I'm a bit skeptical about using openrewrite for this need, as IMO this would the setup and overhead would be overkill, but feel free to give it a try :-)
I will try. From the documentation it look quite easy to call different recipes from java code. Will keep you updated when I have something to show and discuss.
First thing I notice rewrite recipes only work for groovy based build.gradle not the kotlin dsl. I did the .kts decision a few month ago but not sure we really benefit from it. Anyways, I will to a small poc for manipulating build.gradle with rewrite via code outside of jhipster first.
I have a small sample using openrewrite. The idea would be to have a temp. rewrite.yml file which adds or removes dependencies and the rewrite step is executed via gradle + init script (which is also generated on the fly). But sadly, the gradle kotlin dsl is not supported yet, see here https://github.com/openrewrite/rewrite/issues/3291
The sample can be found here https://github.com/atomfrede/open-rewrite-for-jhipster-lite-sample Its a standard maven project which adds dependencies to an "external" gradle project.
Bounty claimed: https://opencollective.com/generator-jhipster/expenses/159351
@murdos : approved, thanks for your work