Skip to content

Commit

Permalink
Merge pull request #353 from jhipster/cleanup
Browse files Browse the repository at this point in the history
cleanup dependencies
  • Loading branch information
DanielFran authored May 15, 2024
2 parents 5bf29a9 + ba855fe commit 8ab68b3
Show file tree
Hide file tree
Showing 10 changed files with 936 additions and 202 deletions.
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

0 comments on commit 8ab68b3

Please sign in to comment.