From 74d35f739282475cd998ad61713a66da076651d0 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 17:23:54 -0300 Subject: [PATCH] remove unused files --- generators/spring-boot/entity-cleanup.js | 37 --- .../spring-boot/entity-files-couchbase.js | 73 ------ generators/spring-boot/files-sql.js | 212 ------------------ generators/spring-boot/generator.js | 6 +- .../Entity.kt.jhi.javax_persistence.ejs | 41 ---- 5 files changed, 2 insertions(+), 367 deletions(-) delete mode 100644 generators/spring-boot/entity-cleanup.js delete mode 100644 generators/spring-boot/entity-files-couchbase.js delete mode 100644 generators/spring-boot/files-sql.js delete mode 100644 generators/spring-boot/templates/src/main/kotlin/package/domain/enumeration/Entity.kt.jhi.javax_persistence.ejs diff --git a/generators/spring-boot/entity-cleanup.js b/generators/spring-boot/entity-cleanup.js deleted file mode 100644 index ee58c8102..000000000 --- a/generators/spring-boot/entity-cleanup.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2013-2024 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. - */ -/** - * Removes server files that where generated in previous JHipster versions and therefore - * need to be removed. - * - * @param {any} generator - reference to generator - * @param {string} javaDir - Java directory - * @param {string} testDir - Java tests directory - */ -export function cleanupOldFiles(generator, javaDir, testDir) { - if (generator.isJhipsterVersionLessThan('7.6.1')) { - if (generator.searchEngineElasticsearch) { - generator.removeFile(`${javaDir}/repository/search/SortToFieldSortBuilderConverter.kt`); - } - } - if (generator.isJhipsterVersionLessThan('7.7.1')) { - generator.removeFile(`${javaDir}/repository/search/SortToSortBuilderListConverter.kt`); - generator.removeFile(`${testDir}/repository/search/${generator.entityClass}SearchRepositoryMockConfiguration.kt`); - } -} diff --git a/generators/spring-boot/entity-files-couchbase.js b/generators/spring-boot/entity-files-couchbase.js deleted file mode 100644 index 8cdf20368..000000000 --- a/generators/spring-boot/entity-files-couchbase.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2013-2024 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. - */ - -import { KOTLIN_MAIN_RES_DIR, KOTLIN_MAIN_SRC_DIR } from './kotlin-constants.js'; - -export const entityCouchbaseFiles = { - dbChangelog: [ - { - condition: generator => !generator.skipDbChangelog && !generator.embedded, - path: KOTLIN_MAIN_RES_DIR, - templates: [ - { - file: 'config/couchmove/changelog/entity.n1ql', - renameTo: generator => - `config/couchmove/changelog/V${generator.changelogDate}__${generator.entityInstance.toLowerCase()}.n1ql`, - }, - ], - }, - { - condition: generator => generator.searchEngineCouchbase && !generator.skipDbChangelog && !generator.embedded, - path: KOTLIN_MAIN_RES_DIR, - templates: [ - { - file: 'config/couchmove/changelog/entity.fts', - renameTo: generator => - `config/couchmove/changelog/V${ - parseInt(generator.changelogDate, 10) + 10 - }__${generator.entityInstance.toLowerCase()}.fts`, - }, - ], - }, - ], - server: [ - { - path: KOTLIN_MAIN_SRC_DIR, - templates: [ - { - file: 'package/domain/Entity.kt.jhi.spring_data_couchbase', - renameTo: generator => - `${generator.entityAbsoluteFolder}/domain/${generator.persistClass}.kt.jhi.spring_data_couchbase`, - useBluePrint: true, - }, - ], - }, - { - condition: generator => !generator.embedded, - path: KOTLIN_MAIN_SRC_DIR, - templates: [ - { - file: 'package/repository/EntityRepository.kt', - renameTo: generator => `${generator.entityAbsoluteFolder}/repository/${generator.entityClass}Repository.kt`, - useBluePrint: true, - }, - ], - }, - ], -}; diff --git a/generators/spring-boot/files-sql.js b/generators/spring-boot/files-sql.js deleted file mode 100644 index 1f9844ac4..000000000 --- a/generators/spring-boot/files-sql.js +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Copyright 2013-2024 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. - */ -import { addSectionsCondition, mergeSections } from 'generator-jhipster/generators/base/support'; -import { JAVA_DOCKER_DIR } from 'generator-jhipster'; -import { KOTLIN_MAIN_RES_DIR, KOTLIN_MAIN_SRC_DIR, KOTLIN_TEST_RES_DIR, KOTLIN_TEST_SRC_DIR } from './kotlin-constants.js'; - -const dockerFiles = { - docker: [ - { - condition: generator => !generator.prodDatabaseTypeOracle, - path: JAVA_DOCKER_DIR, - templates: [{ file: generator => `${generator.prodDatabaseType}.yml` }], - }, - { - condition: generator => !generator.devDatabaseTypeOracle && !generator.devDatabaseTypeH2Any, - path: JAVA_DOCKER_DIR, - templates: [{ file: generator => `${generator.devDatabaseType}.yml` }], - }, - ], -}; - -const sqlFiles = { - reactiveJavaUserManagement: [ - { - condition: generator => generator.reactive && (!generator.skipUserManagement || generator.authenticationTypeOauth2), - path: KOTLIN_MAIN_SRC_DIR, - templates: [ - { - file: 'package/repository/UserSqlHelper.kt', - renameTo: generator => `${generator.javaDir}repository/UserSqlHelper.kt`, - }, - ], - }, - { - condition: generator => generator.reactive && (!generator.skipUserManagement || generator.authenticationTypeOauth2), - path: KOTLIN_MAIN_SRC_DIR, - templates: [ - { - file: 'package/repository/rowmapper/UserRowMapper.kt', - renameTo: generator => `${generator.javaDir}repository/rowmapper/UserRowMapper.kt`, - }, - ], - }, - ], - reactiveCommon: [ - { - condition: generator => generator.reactive, - path: KOTLIN_MAIN_SRC_DIR, - templates: [ - { - file: 'package/repository/rowmapper/ColumnConverter.kt', - renameTo: generator => `${generator.javaDir}repository/rowmapper/ColumnConverter.kt`, - }, - { - file: 'package/repository/EntityManager.kt', - renameTo: generator => `${generator.javaDir}repository/EntityManager.kt`, - }, - ], - }, - ], - hibernate: [ - { - condition: generator => !generator.reactive, - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/timezone/HibernateTimeZoneIT.kt', - renameTo: generator => `${generator.testDir}config/timezone/HibernateTimeZoneIT.kt`, - }, - { - file: 'package/repository/timezone/DateTimeWrapper.kt', - renameTo: generator => `${generator.testDir}repository/timezone/DateTimeWrapper.kt`, - }, - { - file: 'package/repository/timezone/DateTimeWrapperRepository.kt', - renameTo: generator => `${generator.testDir}repository/timezone/DateTimeWrapperRepository.kt`, - }, - ], - }, - ], - testContainers: [ - { - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/EmbeddedSQL.kt', - renameTo: generator => `${generator.testDir}config/EmbeddedSQL.kt`, - }, - { - file: 'package/config/SqlTestContainer.kt', - renameTo: generator => `${generator.testDir}config/SqlTestContainer.kt`, - }, - ], - }, - { - path: KOTLIN_TEST_RES_DIR, - templates: ['config/application-testdev.yml'], - }, - { - condition: generator => !generator.reactive, - path: KOTLIN_TEST_RES_DIR, - templates: ['config/application-testprod.yml'], - }, - ], -}; - -const h2Files = { - serverResource: [ - { - path: KOTLIN_MAIN_RES_DIR, - templates: [{ file: 'h2.server.properties', renameTo: () => '.h2.server.properties' }], - }, - ], -}; - -const mysqlFiles = { - serverTestSources: [ - { - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/MysqlTestContainer.kt', - renameTo: generator => `${generator.testDir}config/MysqlTestContainer.kt`, - }, - ], - }, - { - path: KOTLIN_TEST_RES_DIR, - templates: [{ file: 'testcontainers/mysql/my.cnf', method: 'copy', noEjs: true }], - }, - { - path: JAVA_DOCKER_DIR, - templates: [{ file: 'config/mysql/my.cnf', method: 'copy', noEjs: true }], - }, - ], -}; - -const mariadbFiles = { - serverTestSources: [ - { - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/MariadbTestContainer.kt', - renameTo: generator => `${generator.testDir}config/MariadbTestContainer.kt`, - }, - ], - }, - { - path: KOTLIN_TEST_RES_DIR, - templates: [{ file: 'testcontainers/mariadb/my.cnf', method: 'copy', noEjs: true }], - }, - { - path: JAVA_DOCKER_DIR, - templates: [{ file: 'config/mariadb/my.cnf', method: 'copy', noEjs: true }], - }, - ], -}; - -const mssqlFiles = { - serverTestSources: [ - { - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/MsSqlTestContainer.kt', - renameTo: generator => `${generator.testDir}config/MsSqlTestContainer.kt`, - }, - ], - }, - ], -}; - -const postgresFiles = { - serverTestSources: [ - { - path: KOTLIN_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/PostgreSqlTestContainer.kt', - renameTo: generator => `${generator.testDir}config/PostgreSqlTestContainer.kt`, - }, - ], - }, - ], -}; - -export const serverFiles = mergeSections( - sqlFiles, - dockerFiles, - addSectionsCondition(h2Files, context => context.devDatabaseTypeH2Any), - addSectionsCondition(mysqlFiles, context => context.devDatabaseTypeMysql || context.prodDatabaseTypeMysql), - addSectionsCondition(mariadbFiles, context => context.devDatabaseTypeMariadb || context.prodDatabaseTypeMariadb), - addSectionsCondition(mssqlFiles, context => context.devDatabaseTypeMssql || context.prodDatabaseTypeMssql), - addSectionsCondition(postgresFiles, context => context.devDatabaseTypePostgresql || context.prodDatabaseTypePostgresql), -); diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 0ce420a49..616bd877b 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -367,11 +367,9 @@ export default class extends BaseApplicationGenerator { } get [BaseApplicationGenerator.WRITING]() { - const { resetFakeDataSeed, generateKeyStore } = super.writing; return this.asWritingTaskGroup({ - resetFakeDataSeed, - generateKeyStore, - async writingTemplateTask({ application }) { + ...super.writing, + async writeFiles({ application }) { await this.writeFiles({ sections: serverFiles, context: application, diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/enumeration/Entity.kt.jhi.javax_persistence.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/enumeration/Entity.kt.jhi.javax_persistence.ejs deleted file mode 100644 index 6b4432470..000000000 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/enumeration/Entity.kt.jhi.javax_persistence.ejs +++ /dev/null @@ -1,41 +0,0 @@ -<%# - Copyright 2013-2024 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. --%> -<%# - This is a fragment file, it will be merged into to root template if available. - EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process. --%> -<&_ if (fragment.importSection) { -&> - import org.hibernate.annotations.Cache; - import org.hibernate.annotations.CacheConcurrencyStrategy; -<&_ } -&> - -<&_ if (fragment.annotationSection) { -&> - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) -<&_ } -&> - - <%_ for (const relationship of relationships) { _%> -<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&> - <%_ if (relationship.relationshipOneToMany) { _%> - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) - <%_ } _%> - <%_ if (relationship.relationshipManyToMany) { _%> - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) - <%_ } _%> -<&_ } -&> - <%_ } -%>