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

cleanup dependencies #353

Merged
merged 41 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d7687f8
drop netty constant
mshima May 14, 2024
2145c17
gradle.properties.ejs adjusts
mshima May 14, 2024
1c09d6e
drop rxJava3Version usage from build.gradle.ejs
mshima May 14, 2024
f819707
drop javassist.version from pom.xml
mshima May 14, 2024
9812acb
cleanup dependencies.
mshima May 14, 2024
a790fed
drop jackson constant
mshima May 14, 2024
fb8f299
move swagger-annotations to dependabot
mshima May 14, 2024
b5fe090
drop prometheusSimpleclient constant
mshima May 14, 2024
61bdbb8
move mockito-core to dependabot
mshima May 14, 2024
d90b933
drop assertj constant
mshima May 14, 2024
89acb31
drop jbcrypt from constants
mshima May 14, 2024
e805712
adjusts
mshima May 14, 2024
cc72580
remove non used variables
mshima May 14, 2024
f08c895
move zalando to dependabot
mshima May 14, 2024
c1965f6
cleanup caffeine constants
mshima May 14, 2024
fbf3f51
jbcrypt adjusts
mshima May 14, 2024
da62d37
drop testcontainers constant
mshima May 14, 2024
ecf2c4c
cleanup pom.xml
mshima May 14, 2024
620a522
cleanup build.gradle and gradle.properties
mshima May 14, 2024
c80fe82
move gradle plugins to dependabot
mshima May 14, 2024
7f2b012
cleanup eclipse from pom.xml
mshima May 14, 2024
d4308df
add update micronaut-platform workflow
mshima May 14, 2024
5123a14
use hibernate version from micronaut-platform pom.
mshima May 14, 2024
11a7b27
Update generator.js
mshima May 14, 2024
a3794f6
drop plugins
mshima May 14, 2024
bc9c0e7
use liquibase version from micronaut-platform
mshima May 14, 2024
ef393e9
add typesafe dependency
mshima May 14, 2024
34ae01f
add javaDependencies.hibernate
mshima May 14, 2024
493517a
use ehcache.version from micronaut-platform
mshima May 14, 2024
91dd1a4
drop jakarta-validation version
mshima May 14, 2024
20b7b5d
drop h2 version
mshima May 14, 2024
ebb1002
drop mockito-core version
mshima May 14, 2024
da70ff6
replace swagger-annotations with micronaut-openapi-annotations
mshima May 14, 2024
68bc119
Revert "drop jakarta-validation version"
mshima May 14, 2024
7252b22
Revert "drop h2 version"
mshima May 14, 2024
241cc66
add comment to h2 and jakarta-validation versions
mshima May 14, 2024
dc8b3a7
use h2.version from micronaut-platform
mshima May 14, 2024
32ff88b
drop registerSpringFactory override
mshima May 14, 2024
befb46a
drop DOCKER_REDIS
mshima May 14, 2024
e81e968
drop logback constant
mshima May 14, 2024
ba855fe
don't show micronaut version in cli logo
mshima May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/update-micronaut-platform-pom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright the original author or authors from the JHipster project.
#
# This file is part of the JHipster project, see https://www.jhipster.tech/
# for more information.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: update micronaut-platform bom
on:
workflow_dispatch:
inputs:
micronautPlatformVersion:
description: 'Micronaut Platform version'
required: true
type: string

permissions:
contents: read

jobs:
build:
permissions:
contents: write # for peter-evans/create-pull-request to create branch
pull-requests: write # for peter-evans/create-pull-request to create a PR
name: update micronaut-platform bom
if: github.repository == 'jhipster/generator-jhipster'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/checkout@v4
- uses: jhipster/actions/setup-git@v0
- uses: jhipster/actions/restore-cache@v0
with:
npm: true
- name: Create commit
run: |
wget -O micronaut-platform.pom https://repo1.maven.org/maven2/io/micronaut/platform/micronaut-platform/${{ inputs.micronautPlatformVersion }}/micronaut-platform-${{ inputs.micronautPlatformVersion }}.pom
git add .
git commit -a -m "update micronaut-platform bom to v${{ inputs.micronautPlatformVersion }}"
working-directory: generators/micronaut/resources
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'update micronaut-platform bom to v${{ inputs.micronautPlatformVersion }}'
title: 'update micronaut-platform bom to v${{ inputs.micronautPlatformVersion }}'
body: update micronaut-platform bom to v${{ inputs.micronautPlatformVersion }}
labels: 'theme: dependencies'
7 changes: 1 addition & 6 deletions cli/logo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import chalk from 'chalk';
import constants from '../generators/constants.cjs';
import { readFileSync } from 'fs';

const {
versions: { micronaut: MICRONAUT_VERSION },
} = constants;

export function getLogo() {
const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));

Expand All @@ -19,7 +14,7 @@ ${chalk.blue(' ╚═╝ ╚═╝')}${chalk.green(' ╚═╝ ╚═╝

${chalk.white.bold(' https://www.jhipster.tech')}
${chalk.blue.bold(' https://micronaut.io\n')}
${chalk.white(` Welcome to MHipster v${chalk.white.bold(version)} :: Running Micronaut v${chalk.white.bold(MICRONAUT_VERSION)}`)}
${chalk.white(` Welcome to MHipster v${chalk.white.bold(version)}`)}
${chalk.white(' This blueprint generates your backend as a Micronaut Java project.')}
${chalk.green(' _______________________________________________________________________________________________________________\n')}
${chalk.white(` ${chalk.yellow('::')} This project is a ${chalk.blue.bold('Micronaut')} blueprint for ${chalk.green.bold('JHipster')}`)}
Expand Down
21 changes: 0 additions & 21 deletions generators/constants.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

module.exports = {
DOCKER_REDIS: 'redis:6.0.10',
sqlDb: {
h2Disk: {
driver: 'org.h2.Driver',
Expand Down Expand Up @@ -49,24 +48,4 @@ module.exports = {
dialect: 'org.hibernate.dialect.SQLServer2012Dialect',
},
},
versions: {
netty: '4.1.107.Final',
rxJava3: '2.3.0',
hibernate: '6.4.4.Final',
prometheusSimpleclient: '0.16.0',
jackson: '2.15.2',
javassist: '3.27.0-GA', // Should match Hibernate deps
javaxMail: '2.0.1',
jbcrypt: '0.4',
logback: '1.5.3',
mapstruct: '1.5.5.Final',
swaggerAnnotations: '2.2.19',
mockito: '5.10.0',
problem: '0.29.1',
caffeine: '3.1.8',
archunit: '1.2.1',
simplejavamail: '8.6.3',
testcontainers: '1.19.6',
assertj: '3.25.3',
},
};
82 changes: 64 additions & 18 deletions generators/micronaut/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import BaseApplicationGenerator from 'generator-jhipster/generators/server';
import { GENERATOR_DOCKER, GENERATOR_LANGUAGES, GENERATOR_LIQUIBASE, GENERATOR_SERVER } from 'generator-jhipster/generators';
import { createNeedleCallback, createBase64Secret } from 'generator-jhipster/generators/base/support';
import { addJavaAnnotation } from 'generator-jhipster/generators/java/support';
import { parseMavenPom } from 'generator-jhipster/generators/maven/support';
import mnConstants from '../constants.cjs';
import { writeFiles } from './files.js';

import { entityFiles } from './entity-files.js';
import { getCommonMavenDefinition, getDatabaseDriverForDatabase, getImperativeMavenDefinition } from './internal/dependencies.js';
import constants from '../constants.cjs';
import { serverTestFrameworkChoices } from './command.js';

export default class extends BaseApplicationGenerator {
Expand Down Expand Up @@ -109,6 +109,22 @@ export default class extends BaseApplicationGenerator {
async loading({ application }) {
await this.loadCurrentJHipsterCommandConfig(application);
},
loadMicronautPlatformPom({ application }) {
const pomFile = this.readTemplate(this.templatePath('../resources/micronaut-platform.pom')).toString();
const pom = parseMavenPom(pomFile);
Object.assign(application.javaManagedProperties, pom.project.properties);

// Liquibase generator uses this property, otherwise it will be used from gradle's dependenciesManagement plugin.
application.javaDependencies.liquibase = application.javaManagedProperties['liquibase.version'];
// Required by Liquibase generator due to liquibase-maven-plugin
application.javaDependencies.h2 = application.javaManagedProperties['h2.version'];

// Used by getImperativeMavenDefinition for annotation processor.
application.javaDependencies.hibernate = application.javaManagedProperties['hibernate.version'];

// Used by micronaut-cache.
application.javaDependencies.ehcache = application.javaManagedProperties['ehcache.version'];
},
});
}

Expand All @@ -122,16 +138,13 @@ export default class extends BaseApplicationGenerator {
prepareForTemplates({ application }) {
// Workaround
application.MN_CONSTANTS = mnConstants;
application.dockerContainers.redis = mnConstants.DOCKER_REDIS;
// Add liquibase h2 database references.
application.liquibaseAddH2Properties = true;
Object.assign(application, {
useNpmWrapper: application.clientFrameworkAny && !application.skipClient,
});
},

registerSpringFactory: undefined,

addLogNeedles({ source, application }) {
source.addIntegrationTestAnnotation = ({ package: packageName, annotation }) =>
this.editFile(this.destinationPath(`${application.javaPackageTestDir}IntegrationTest.java`), content =>
Expand Down Expand Up @@ -193,33 +206,66 @@ export default class extends BaseApplicationGenerator {
addMicronautDependencies({ application, source }) {
const { javaDependencies } = application;
source.addJavaDefinition({
versions: [
{ name: 'logstash-logback-encoder', version: javaDependencies['logstash-logback-encoder'] },
{ name: 'jhipster-framework', version: application.jhipsterDependenciesVersion },
{ name: 'commons-lang3', version: javaDependencies['commons-lang3'] },
],
dependencies: [
{ groupId: 'net.logstash.logback', artifactId: 'logstash-logback-encoder', versionRef: 'logstash-logback-encoder' },
{ groupId: 'tech.jhipster', artifactId: 'jhipster-framework', versionRef: 'jhipster-framework' },
{ groupId: 'org.apache.commons', artifactId: 'commons-lang3', versionRef: 'commons-lang3' },
{ groupId: 'io.micronaut.openapi', artifactId: 'micronaut-openapi-annotations' },
{
groupId: 'net.logstash.logback',
artifactId: 'logstash-logback-encoder',
version: javaDependencies['logstash-logback-encoder'],
},
{ groupId: 'tech.jhipster', artifactId: 'jhipster-framework', version: application.jhipsterDependenciesVersion },
{ groupId: 'org.apache.commons', artifactId: 'commons-lang3', version: javaDependencies['commons-lang3'] },
{ groupId: 'org.mockito', artifactId: 'mockito-core', scope: 'test' },
{ groupId: 'org.zalando', artifactId: 'jackson-datatype-problem', version: javaDependencies['jackson-datatype-problem'] },
{ groupId: 'org.zalando', artifactId: 'problem-violations', version: javaDependencies['problem-violations'] },
],
});
if (application.buildToolMaven) {
source.addMavenDefinition({
properties: [{ property: 'modernizer.failOnViolations', value: 'false' }],
});
} else if (application.buildToolGradle) {
source.addGradleDependencyCatalogPlugin({
id: 'io.micronaut.application',
pluginName: 'micronaut-application',
version: application.javaDependencies['micronaut-application'],
addToBuild: true,
source.addGradleDependencyCatalogPlugins([
{
id: 'io.micronaut.application',
pluginName: 'micronaut-application',
version: application.javaDependencies['micronaut-application'],
addToBuild: true,
},
{
id: 'com.gorylenko.gradle-git-properties',
pluginName: 'gradle-git-properties',
version: application.javaDependencies['gradle-git-properties'],
addToBuild: true,
},
{
id: 'com.github.johnrengelman.shadow',
pluginName: 'shadow',
version: application.javaDependencies['shadow'],
addToBuild: true,
},
]);
if (application.enableSwaggerCodegen) {
source.addGradleDependencyCatalogPlugin({
id: 'org.openapi.generator',
pluginName: 'openapi-generator',
version: application.javaDependencies['openapi-generator'],
addToBuild: true,
});
}
}

if (!application.skipUserManagement) {
source.addJavaDefinition({
dependencies: [{ groupId: 'org.mindrot', artifactId: 'jbcrypt', version: javaDependencies.jbcrypt }],
});
}
},
sqlDependencies({ application, source }) {
if (application.databaseTypeSql) {
source.addMavenDefinition?.(getImperativeMavenDefinition({ javaDependencies: { hibernate: constants.versions.hibernate } }));
source.addMavenDefinition?.(
getImperativeMavenDefinition({ javaDependencies: { hibernate: application.javaManagedProperties['hibernate.version'] } }),
);
source.addMavenDefinition?.(getCommonMavenDefinition());
source.addMavenDependency?.(getDatabaseDriverForDatabase(application.prodDatabaseType).jdbc);
}
Expand Down
22 changes: 16 additions & 6 deletions generators/micronaut/resources/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
[libraries]
commons-lang3 = { module = 'org.apache.commons:commons-lang3', version = '3.14.0' }

ehcache = { module = 'org.ehcache:ehcache', version = '3.10.8' }

# Required by Liquibase generator due to liquibase-maven-plugin
jakarta-validation = { module = 'jakarta.validation:jakarta.validation-api', version = '3.0.2' }

jaxb-runtime = { module = 'org.glassfish.jaxb:jaxb-runtime', version = '4.0.5' }

h2 = { module = 'com.h2database:h2', version = '2.2.224' }

liquibase = { module = 'org.liquibase:liquibase-core', version = '4.27.0' }

logstash-logback-encoder = { module = 'net.logstash.logback:logstash-logback-encoder', version = '7.4' }

micronaut-platform = { module = 'io.micronaut.platform:micronaut-platform', version = '4.4.2' }

redisson = { module = 'org.redisson:redisson', version = '3.30.0' }

jbcrypt = { module = 'org.mindrot:jbcrypt', version = '0.4' }

problem-violations = { module = 'org.zalando:problem-violations', version = '0.29.1' }

jackson-datatype-problem = { module = 'org.zalando:jackson-datatype-problem', version = '0.27.1' }

# caffeine
typesafe = { module = 'com.typesafe:config', version = '1.4.3' }

[plugins]
micronaut-application = { id = 'io.micronaut.application', version = '4.3.8' }

gradle-git-properties = { id = 'com.gorylenko.gradle-git-properties', version = '2.4.1' }

openapi-generator = { id = 'org.openapi.generator', version = '4.3.1' }

shadow = { id = 'com.github.johnrengelman.shadow', version = '7.1.2' }
Loading