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

Separate gradle build logic (and other features) #19615

Closed
atomfrede opened this issue Aug 31, 2022 · 11 comments
Closed

Separate gradle build logic (and other features) #19615

atomfrede opened this issue Aug 31, 2022 · 11 comments
Assignees
Labels
area: feature request 💡 $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ changes: major ⭐ theme: gradle v8 $200 https://www.jhipster.tech/bug-bounties/
Milestone

Comments

@atomfrede
Copy link
Member

atomfrede commented Aug 31, 2022

Overview of the feature request

I think our gradle part could have little make over for v8. In particular I am thinking of using some (precompiled) conventions, which reside in buildSrc directory. Having this the generated build.gradle file would in an optimal case just apply a few plugins and thats it.

Furthermore I would like to introduce gradle version catalogs to centralize the versions in an idiomatic gradle way.

Motivation for or Use Case

When talking to the gradle guys in the last couple of years they always suggested to have specific jhipster plugins. We (or me specific me) have always rejected this, because it would have created huge maintenance burden I was not willing to take. Moreover with everything generated we could easily provide workarounds for our users. Compared to having really dedicated plugins we would require both a release of the plugin and the generator.

With using convention plugins in buildSrc directory we can have best of both approaches. We clearly separate specific build logic, dependencies and plugins for specific jhipster configurations and as all is generated users can see everything and opt-out or replace stuff if needed.

This would also simplify our templates as we would try to have e.g. frontend specific stuff inside a dedicated conventions plugin and not different if/else switches inside the main build.gradle template file.

This requires also changes to internal apis and needles as such I would consider this a breaking change and would like to do in v8. This will also most likely make a lot of blueprints not compatible with gradle anymore (thinking about the native blueprint), but I hope the required changes are quite small.

I would try to implement a first prototype for first/initial discussion so we know everyone is happy with the outcome/result.

CC @mraible @jdubois @DanielFran @mshima @deepu105 Your view in this is highly appreciated.

@deepu105
Copy link
Member

deepu105 commented Aug 31, 2022 via email

@thetric
Copy link

thetric commented Aug 31, 2022

Further documentation to the mentions Gradle features:

@atomfrede
Copy link
Member Author

@mshima @DanielFran I would start with extracting the versions into a version catalog. I hope we can reuse the existing toml file which we use for dependabot already and generate it for an application. With regards to convention plugins I think we might start by creating a convention plugin for gatling for example.

@mshima
Copy link
Member

mshima commented Apr 9, 2023

I don't know how a convention plugin looks like but sounds ok.
The toml file can be built from scratch using an external lib

import { parse } from '@iarna/toml';

@deepu105 deepu105 added $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ $200 https://www.jhipster.tech/bug-bounties/ labels Aug 15, 2023
@atomfrede
Copy link
Member Author

@mshima I guess it makes sense to create a sub gen for gradle like you've done for maven? It looks pretty cool the current modularization of the generators

@mshima
Copy link
Member

mshima commented Dec 7, 2023

@atomfrede we already have a grade sub-gen, but it's quite different of maven due to design.
We are mostly writing a gradle script file for each tech and injecting it.
Gradle needles are:

source.applyFromGradle = script => this.editFile('build.gradle', applyFromGradleCallback(script));
source.addGradleDependency = dependency => this.editFile('build.gradle', addGradleDependencyCallback(dependency));
source.addGradlePlugin = plugin => this.editFile('build.gradle', addGradlePluginCallback(plugin));
source.addGradleMavenRepository = repository => this.editFile('build.gradle', addGradleMavenRepositoryCallback(repository));
source.addGradlePluginManagement = plugin => this.editFile('settings.gradle', addGradlePluginManagementCallback(plugin));
source.addGradleProperty = property => this.editFile('gradle.properties', addGradlePropertyCallback(property));

And dependencies are split in separated files instead of api calls:

Database are not split yet.
I am not a gradle expert, maybe you can improve even further.

@atomfrede
Copy link
Member Author

Nice idea with the injection. Maybe we can use the mentioned gradle plugin mechanism for that. I will try something.

@atomfrede
Copy link
Member Author

@mshima I think we can really leverage the current modularization approach and define and generate convention plugins which are than applied. That looks cleaner and easier to me compared to the apply from approach. Let me try something tonight

@atomfrede
Copy link
Member Author

I really like the thing with the convention plugins. You can have look here. Need to figured out how to proceed with the node stuff and the dev/prod profile right now, but in general it looks very nice (for example)

plugins {
    id "com.github.node-gradle.node"
    id 'jhipster.common-conventions'
    id 'jhipster.gatling-conventions'
    id 'jhipster.cucumber-conventions'
    id 'jhipster.test-conventions'
    id 'jhipster.sonar-conventions'
    id 'jhipster.cache-conventions'
    id 'jhipster.docker-conventions'
    id 'jhipster.code-quality-conventions'
    id 'jhipster.liquibase-conventions'
    // jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here
}

Will try to create a PR in the next couple of days.

@mshima As we have removed deprecated deployments, can I safely remove the gae "profile" from gradle?

  gae: {
    desc: 'Deploy the current application to Google App Engine',
    removed: removedV8,
  },

atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 13, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 13, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 14, 2023
mshima pushed a commit that referenced this issue Dec 14, 2023
* [gradle] generate initial files for convention plugin usage

udpates 19615

* fix gradle snapshots

updates #19615

* apply checkstyle dependency resolution workaround

updates #19615
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 15, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 16, 2023
mshima pushed a commit that referenced this issue Dec 18, 2023
* prepare version catalog for convention plugins

updates #19615

* initial gradle convention plugin creation

updates #19615

* add required dependencies and versions to convention plugin
updates #19615

* encapsulate gatling versions in convention plugin

updates #19615

* allow curly braces in strings

updates #19615

* correct toml needle

updates #19615

* fix typo

updates #19615

* correct dependency catalog

updates #19615

* add gatling gradle snapshot tests

updates #19615

* remove obsolete gradle properties from server generator

updates #19615
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 19, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 21, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 22, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 28, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 28, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 28, 2023
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 28, 2023
mshima pushed a commit that referenced this issue Dec 29, 2023
* add code quality gradle convention plugin

updates #19615

* remove now obsolete gradle plugin settings

updates #19615

* remove old sonar application in main gradle build file

updates #19615

* correct cleanup to use next release

udpates #19615
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Dec 30, 2023
mshima added a commit that referenced this issue Dec 30, 2023
* replace gradle apply from cache with cache convention plugin

updates #19615

* drop gradle/cache.gradle.ejs template

---------

Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Jan 1, 2024
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Jan 1, 2024
@mshima
Copy link
Member

mshima commented May 20, 2024

@atomfrede I think we can close this.
Not everything migrated to convention plugins but it's enough.
Next step is probably open api generator that can be reused in micronaut blueprint.

@atomfrede
Copy link
Member Author

Yes let's close it and open dedicated issues for the remaining things.

@mraible mraible added this to the 8.5.0 milestone May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: feature request 💡 $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ changes: major ⭐ theme: gradle v8 $200 https://www.jhipster.tech/bug-bounties/
Projects
None yet
Development

No branches or pull requests

5 participants