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

Spring Boot v3 templates based on https://github.com/jhipster/jhipste… #429

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

import javax.annotation.Generated
import jakarta.annotation.Generated

@Generated(value= ["JHipster"], comments="Generated by JHipster <%= jhipsterVersion %>")
@Retention(RetentionPolicy.SOURCE)
Expand Down
48 changes: 8 additions & 40 deletions generators/spring-boot-v2/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import { basename, dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { existsSync } from 'fs';
import BaseApplicationGenerator from 'generator-jhipster/generators/spring-boot';
import { getEnumInfo } from 'generator-jhipster/generators/base-application/support';
import { files as entityServerFiles } from 'jhipster-7-templates/esm/generators/entity-server';
import { files as serverFiles } from 'jhipster-7-templates/esm/generators/server';
import { convertToKotlinFile } from '../kotlin/support/files.js';
import { migrateApplicationTask } from './preparing-migration.js';
import migration from './migration.cjs';

const { jhipsterConstants } = migration;
const { MAIN_DIR } = jhipsterConstants;
const SERVER_MAIN_SRC_KOTLIN_DIR = `${MAIN_DIR}kotlin/`;

const jhipster7TemplatesPackage = dirname(fileURLToPath(import.meta.resolve('jhipster-7-templates/package.json')));

Expand Down Expand Up @@ -332,38 +326,6 @@ export default class extends BaseApplicationGenerator {
});
}
},

// Can be dropped for jhipster 8.7.0
async writeEnumFiles({ application, entities }) {
for (const entity of entities.filter(entity => !entity.skipServer)) {
for (const field of entity.fields.filter(field => field.fieldIsEnum)) {
const enumInfo = {
...application,
...getEnumInfo(field, entity.clientRootFolder),
frontendAppName: entity.frontendAppName,
packageName: application.packageName,
javaPackageSrcDir: application.javaPackageSrcDir,
entityJavaPackageFolder: entity.entityJavaPackageFolder,
entityAbsolutePackage: entity.entityAbsolutePackage || application.packageName,
};
await this.writeFiles({
blocks: [
{
templates: [
{
file: `${SERVER_MAIN_SRC_KOTLIN_DIR}_package_/_entityPackage_/domain/enumeration/_enumName_.kt`,
renameTo: () =>
`${SERVER_MAIN_SRC_KOTLIN_DIR}${entity.entityAbsoluteFolder}/domain/enumeration/${field.fieldType}.kt`,
},
],
},
],
rootTemplatesPath: ['../../spring-boot/templates/domain/'],
context: enumInfo,
});
}
}
},
});
}

Expand Down Expand Up @@ -427,8 +389,14 @@ export default class extends BaseApplicationGenerator {
source.addGradleProperty({ property: 'mapstructVersion', value: application.javaDependencies.mapstruct });
source.addGradleProperty({ property: 'springBootVersion', value: application.javaDependencies['spring-boot'] });
if (application.databaseTypeSql) {
source.addGradleProperty({ property: 'liquibase.version', value: application.javaDependencies.liquibase });
source.addGradleProperty({ property: 'hibernateVersion', value: application.javaDependencies.hibernate });
source.addGradleProperty({
property: 'liquibase.version',
value: application.javaManagedProperties['liquibase.version'],
});
source.addGradleProperty({
property: 'hibernateVersion',
value: application.javaManagedProperties['hibernate.version'],
});
source.addGradleProperty({ property: 'jaxbRuntimeVersion', value: '4.0.0' });
}
if (application.databaseTypeCassandra) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.springframework.web.servlet.i18n.LocaleChangeInterceptor
class LocaleConfiguration : WebMvcConfigurer {

@Bean
fun localeResolver() = AngularCookieLocaleResolver().apply { cookieName = "NG_TRANSLATE_LANG_KEY" }
fun localeResolver() = AngularCookieLocaleResolver("NG_TRANSLATE_LANG_KEY")

override fun addInterceptors(registry: InterceptorRegistry?) {
registry!!.addInterceptor(LocaleChangeInterceptor().apply { paramName = "language" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ import org.springframework.data.annotation.Transient
import org.springframework.data.domain.Persistable
import org.springframework.data.relational.core.mapping.Table
<%_ } else { _%>
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import jakarta.persistence.Column
<%_ } _%>
<%_ } _%>
import javax.validation.constraints.NotNull
import javax.validation.constraints.Size
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.io.Serializable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import reactor.core.publisher.Mono
<%_ } else { _%>
import org.springframework.web.filter.GenericFilterBean

import javax.servlet.FilterChain
import javax.servlet.ServletException
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
import jakarta.servlet.FilterChain
import jakarta.servlet.ServletException
import jakarta.servlet.ServletRequest
import jakarta.servlet.ServletResponse
import jakarta.servlet.http.HttpServletRequest
import java.io.IOException
<%_ } _%>

Expand Down
64 changes: 20 additions & 44 deletions generators/spring-boot/__snapshots__/generator.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,9 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/docker/app.yml": {
"stateCleared": "modified",
},
"src/main/docker/grafana/provisioning/dashboards/JVM.json": {
"stateCleared": "modified",
},
"src/main/docker/grafana/provisioning/dashboards/dashboard.yml": {
"stateCleared": "modified",
},
"src/main/docker/grafana/provisioning/datasources/datasource.yml": {
"stateCleared": "modified",
},
"src/main/docker/jhipster-control-center.yml": {
"stateCleared": "modified",
},
"src/main/docker/jib/entrypoint.sh": {
"stateCleared": "modified",
},
"src/main/docker/monitoring.yml": {
"stateCleared": "modified",
},
"src/main/docker/postgresql.yml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -164,9 +149,6 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/config/LiquibaseConfiguration.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/config/LocaleConfiguration.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/config/LoggingAspectConfiguration.kt": {
"stateCleared": "modified",
},
Expand All @@ -176,6 +158,9 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/config/SecurityConfiguration.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/config/SecurityJwtConfiguration.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/config/StaticResourcesWebConfiguration.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -218,9 +203,6 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/domain/User.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/domain/enumeration/EnumFieldClass.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/management/SecurityMetersService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -269,15 +251,6 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/security/UserNotActivatedException.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/security/jwt/JWTConfigurer.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/security/jwt/JWTFilter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/security/jwt/TokenProvider.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -344,13 +317,19 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/service/mapper/UserMapper.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/filter/SpaWebFilter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/AccountResource.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/AnotherSimpleResource.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/ClientForwardController.kt": {
"src/main/kotlin/com/mycompany/myapp/web/rest/AuthenticateController.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/AuthorityResource.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/CriteriaAndDtoResource.kt": {
Expand All @@ -371,9 +350,6 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/main/kotlin/com/mycompany/myapp/web/rest/SimpleResource.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/UserJWTController.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/myapp/web/rest/UserResource.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -650,13 +626,16 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/test/kotlin/com/mycompany/myapp/security/SecurityUtilsUnitTest.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/security/jwt/JWTFilterTest.kt": {
"src/test/kotlin/com/mycompany/myapp/security/jwt/AuthenticationIntegrationTest.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/security/jwt/JwtAuthenticationTestUtils.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/security/jwt/TokenProviderSecurityMetersTests.kt": {
"src/test/kotlin/com/mycompany/myapp/security/jwt/TokenAuthenticationIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/security/jwt/TokenProviderTest.kt": {
"src/test/kotlin/com/mycompany/myapp/security/jwt/TokenAuthenticationSecurityMetersIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/service/MailServiceIT.kt": {
Expand Down Expand Up @@ -686,7 +665,10 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/test/kotlin/com/mycompany/myapp/web/rest/AnotherSimpleResourceIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/web/rest/ClientForwardControllerTest.kt": {
"src/test/kotlin/com/mycompany/myapp/web/rest/AuthenticateControllerIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/web/rest/AuthorityResourceIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/web/rest/CriteriaAndDtoResourceIT.kt": {
Expand All @@ -710,9 +692,6 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/test/kotlin/com/mycompany/myapp/web/rest/TestUtil.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/web/rest/UserJWTControllerIT.kt": {
"stateCleared": "modified",
},
"src/test/kotlin/com/mycompany/myapp/web/rest/UserResourceIT.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -758,8 +737,5 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed
"src/test/resources/templates/mail/testEmail.html": {
"stateCleared": "modified",
},
"src/test/resources/testcontainers.properties": {
"stateCleared": "modified",
},
}
`;
Loading
Loading