From 0079c8dfedca1675d53083711720817fa583cddd Mon Sep 17 00:00:00 2001 From: BingZi-233 Date: Tue, 5 Nov 2024 23:24:56 +0800 Subject: [PATCH 1/2] Kotlin Language Supports --- .../application/KotlinApplicationService.java | 20 ++++++++++++ .../kotlin/domain/KotlinModuleFactory.java | 31 +++++++++++++++++++ .../primary/KotlinModuleConfiguration.java | 26 ++++++++++++++++ .../language/kotlin/package-info.java | 1 + .../shared/slug/domain/JHLiteFeatureSlug.java | 1 + .../shared/slug/domain/JHLiteModuleSlug.java | 1 + 6 files changed, 80 insertions(+) create mode 100644 src/main/java/tech/jhipster/lite/generator/language/kotlin/application/KotlinApplicationService.java create mode 100644 src/main/java/tech/jhipster/lite/generator/language/kotlin/domain/KotlinModuleFactory.java create mode 100644 src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java create mode 100644 src/main/java/tech/jhipster/lite/generator/language/kotlin/package-info.java diff --git a/src/main/java/tech/jhipster/lite/generator/language/kotlin/application/KotlinApplicationService.java b/src/main/java/tech/jhipster/lite/generator/language/kotlin/application/KotlinApplicationService.java new file mode 100644 index 00000000000..7947b08b88b --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/language/kotlin/application/KotlinApplicationService.java @@ -0,0 +1,20 @@ +package tech.jhipster.lite.generator.language.kotlin.application; + +import org.springframework.stereotype.Service; +import tech.jhipster.lite.generator.language.kotlin.domain.KotlinModuleFactory; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@Service +public class KotlinApplicationService { + + private final KotlinModuleFactory factory; + + public KotlinApplicationService() { + factory = new KotlinModuleFactory(); + } + + public JHipsterModule buildKotlinLanguageModule(JHipsterModuleProperties properties) { + return factory.buildKotlinLanguageModule(properties); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/language/kotlin/domain/KotlinModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/language/kotlin/domain/KotlinModuleFactory.java new file mode 100644 index 00000000000..f4f176b3e57 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/language/kotlin/domain/KotlinModuleFactory.java @@ -0,0 +1,31 @@ +package tech.jhipster.lite.generator.language.kotlin.domain; + +import static tech.jhipster.lite.module.domain.JHipsterModule.moduleBuilder; + +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.gradleplugin.GradleCorePlugin; +import tech.jhipster.lite.module.domain.gradleplugin.GradlePluginId; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; +import tech.jhipster.lite.shared.error.domain.Assert; + +public class KotlinModuleFactory { + + public JHipsterModule buildKotlinLanguageModule(JHipsterModuleProperties properties) { + Assert.notNull("properties", properties); + + //@formatter:off + return moduleBuilder(properties) + .gitIgnore() + .comment("Kotlin Language") + .and() + .gradlePlugins() + .plugin(kotlinPluginManagement()) + .and() + .build(); + //@formatter:on + } + + private GradleCorePlugin kotlinPluginManagement() { + return GradleCorePlugin.builder().id(new GradlePluginId("kotlin(\"jvm\") version \"1.9.25\"")).build(); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java new file mode 100644 index 00000000000..86a71378be7 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java @@ -0,0 +1,26 @@ +package tech.jhipster.lite.generator.language.kotlin.infrastructure.primary; + +import static tech.jhipster.lite.shared.slug.domain.JHLiteFeatureSlug.EXTRA_LANGUAGE; +import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.GRADLE_JAVA; +import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.GRADLE_KOTLIN; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import tech.jhipster.lite.generator.language.kotlin.application.KotlinApplicationService; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; + +@Configuration +public class KotlinModuleConfiguration { + + @Bean + JHipsterModuleResource gradleKotlinLanguageModule(KotlinApplicationService gradle) { + return JHipsterModuleResource.builder() + .slug(GRADLE_KOTLIN) + .withoutProperties() + .apiDoc("Extra Language", "Add Kotlin Language Supports") + .organization(JHipsterModuleOrganization.builder().feature(EXTRA_LANGUAGE).addDependency(GRADLE_JAVA).build()) + .tags("buildtool", "test") + .factory(gradle::buildKotlinLanguageModule); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/language/kotlin/package-info.java b/src/main/java/tech/jhipster/lite/generator/language/kotlin/package-info.java new file mode 100644 index 00000000000..69cc0c6d722 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/language/kotlin/package-info.java @@ -0,0 +1 @@ +package tech.jhipster.lite.generator.language.kotlin; diff --git a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java index cca8f6c2a05..9ec0ab7e082 100644 --- a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java +++ b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java @@ -21,6 +21,7 @@ public enum JHLiteFeatureSlug implements JHipsterFeatureSlugFactory { CODE_COVERAGE_JAVA("code-coverage-java"), JAVA_BUILD_TOOL("java-build-tool"), JAVA_BUILD_TOOL_WRAPPER("java-build-tool-wrapper"), + EXTRA_LANGUAGE("extra-language"), JPA_PERSISTENCE("jpa-persistence"), LICENSE("license"), OAUTH_PROVIDER("oauth-provider"), diff --git a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteModuleSlug.java b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteModuleSlug.java index e31a781e8cc..c769698cc71 100644 --- a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteModuleSlug.java +++ b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteModuleSlug.java @@ -46,6 +46,7 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory { RENOVATE("renovate"), GITPOD("gitpod"), GRADLE_JAVA("gradle-java"), + GRADLE_KOTLIN("gradle-kotlin"), GRADLE_WRAPPER("gradle-wrapper"), HIBERNATE_2ND_LEVEL_CACHE("hibernate-2nd-level-cache"), INFINITEST_FILTERS("infinitest-filters"), From d4abc2552233681cec72b670b72bf44ab696aa4f Mon Sep 17 00:00:00 2001 From: BingZi-233 Date: Thu, 14 Nov 2024 09:58:06 +0800 Subject: [PATCH 2/2] remove kotlin module feature attribute --- .../infrastructure/primary/KotlinModuleConfiguration.java | 3 +-- .../jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java index 86a71378be7..86cf781ef38 100644 --- a/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/language/kotlin/infrastructure/primary/KotlinModuleConfiguration.java @@ -1,6 +1,5 @@ package tech.jhipster.lite.generator.language.kotlin.infrastructure.primary; -import static tech.jhipster.lite.shared.slug.domain.JHLiteFeatureSlug.EXTRA_LANGUAGE; import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.GRADLE_JAVA; import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.GRADLE_KOTLIN; @@ -19,7 +18,7 @@ JHipsterModuleResource gradleKotlinLanguageModule(KotlinApplicationService gradl .slug(GRADLE_KOTLIN) .withoutProperties() .apiDoc("Extra Language", "Add Kotlin Language Supports") - .organization(JHipsterModuleOrganization.builder().feature(EXTRA_LANGUAGE).addDependency(GRADLE_JAVA).build()) + .organization(JHipsterModuleOrganization.builder().addDependency(GRADLE_JAVA).build()) .tags("buildtool", "test") .factory(gradle::buildKotlinLanguageModule); } diff --git a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java index 9ec0ab7e082..cca8f6c2a05 100644 --- a/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java +++ b/src/main/java/tech/jhipster/lite/shared/slug/domain/JHLiteFeatureSlug.java @@ -21,7 +21,6 @@ public enum JHLiteFeatureSlug implements JHipsterFeatureSlugFactory { CODE_COVERAGE_JAVA("code-coverage-java"), JAVA_BUILD_TOOL("java-build-tool"), JAVA_BUILD_TOOL_WRAPPER("java-build-tool-wrapper"), - EXTRA_LANGUAGE("extra-language"), JPA_PERSISTENCE("jpa-persistence"), LICENSE("license"), OAUTH_PROVIDER("oauth-provider"),