jhipster-lite icon indicating copy to clipboard operation
jhipster-lite copied to clipboard

Handle Gradle dependencies in modules

Open DamnClin opened this issue 3 years ago • 1 comments

Following https://github.com/jhipster/jhipster-lite/issues/1787 we can add gradle dependencies handling.

TODO:

  • [ ] Update FileSystemCurrentJavaDependenciesVersionsRepository to have a strategy to handle either maven or gradle
  • [ ] Create a JavaDependenciesCommandHandler interface based on MavenCommandHandler
  • [ ] Create a GradleCommandHandler (which is a JavaDependenciesCommandHandler)
  • [ ] Update FileSystemJavaDependenciesCommandsHandler to create the most suited handler (depending on project version management)

DamnClin avatar May 28 '22 07:05 DamnClin

@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 avatar Jul 24 '22 11:07 atomfrede

@atomfrede : do you still intend to work on this feature? otherwise I would be happy to give it a try :-)

murdos avatar Dec 26 '22 20:12 murdos

Feel to go on. I did not much so far. I think I would have tried rewrite to handle e.g. the dependency part.

atomfrede avatar Dec 26 '22 20:12 atomfrede

@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 ;)

pascalgrimaud avatar Dec 27 '22 16:12 pascalgrimaud

@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 SetVersion command: 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] 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 avatar Jan 02 '23 22:01 murdos

@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.

atomfrede avatar Feb 07 '23 13:02 atomfrede

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 :-)

murdos avatar Feb 07 '23 14:02 murdos

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.

atomfrede avatar Feb 07 '23 14:02 atomfrede

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.

atomfrede avatar Feb 07 '23 17:02 atomfrede

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.

atomfrede avatar Jul 17 '23 16:07 atomfrede

Bounty claimed: https://opencollective.com/generator-jhipster/expenses/159351

murdos avatar Sep 02 '23 08:09 murdos

@murdos : approved, thanks for your work

pascalgrimaud avatar Sep 02 '23 08:09 pascalgrimaud