From d1bb7d4b286c1295cb021f811ab2f7c14d4f47c3 Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Sun, 3 Dec 2023 21:33:25 +0100 Subject: [PATCH 1/5] add htmx webjars module updates #4339 --- .../WebjarsApplicationService.java | 20 ---------- .../HtmxWebjarsApplicationService.java | 20 ++++++++++ .../htmx/domain/HtmxWebjarsModuleFactory.java | 24 ++++++++++++ .../HtmxWebjarsModuleConfiguration.java | 28 +++++++++++++ .../server/webjars/htmx/package-info.java | 2 + .../WebjarsLocatorApplicationService.java | 20 ++++++++++ .../domain/WebjarsLocatorModuleFactory.java} | 4 +- .../WebjarsLocatorModuleConfiguration.java} | 13 +++---- .../server/webjars/locator/package-info.java | 2 + .../server/webjars/package-info.java | 2 - .../slug/domain/JHLiteModuleSlug.java | 3 +- .../resources/generator/dependencies/pom.xml | 6 +++ .../server/webjars/htmx/htmx-webjars.feature | 10 +++++ .../webjars-locator.feature} | 4 +- .../domain/HtmxWebjarsModuleFactoryTest.java | 39 +++++++++++++++++++ .../WebjarsLocatorModuleFactoryTest.java} | 6 +-- 16 files changed, 166 insertions(+), 37 deletions(-) delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java rename src/main/java/tech/jhipster/lite/generator/server/webjars/{domain/WebjarsModuleFactory.java => locator/domain/WebjarsLocatorModuleFactory.java} (86%) rename src/main/java/tech/jhipster/lite/generator/server/webjars/{infrastructure/primary/WebjarsModuleConfiguration.java => locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java} (67%) create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java create mode 100644 src/test/features/server/webjars/htmx/htmx-webjars.feature rename src/test/features/server/webjars/{webjars.feature => locator/webjars-locator.feature} (80%) create mode 100644 src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java rename src/test/java/tech/jhipster/lite/generator/server/webjars/{domain/WebjarsModuleFactoryTest.java => locator/domain/WebjarsLocatorModuleFactoryTest.java} (84%) diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java deleted file mode 100644 index 1707ecd6c87..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java +++ /dev/null @@ -1,20 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.application; - -import org.springframework.stereotype.Service; -import tech.jhipster.lite.generator.server.webjars.domain.WebjarsModuleFactory; -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; - -@Service -public class WebjarsApplicationService { - - private final WebjarsModuleFactory webjarsModuleFactory; - - public WebjarsApplicationService() { - webjarsModuleFactory = new WebjarsModuleFactory(); - } - - public JHipsterModule buildWebjarsModule(JHipsterModuleProperties properties) { - return webjarsModuleFactory.buildModule(properties); - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java new file mode 100644 index 00000000000..5b5ccf2491f --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java @@ -0,0 +1,20 @@ +package tech.jhipster.lite.generator.server.webjars.htmx.application; + +import org.springframework.stereotype.Service; +import tech.jhipster.lite.generator.server.webjars.htmx.domain.HtmxWebjarsModuleFactory; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@Service +public class HtmxWebjarsApplicationService { + + private final HtmxWebjarsModuleFactory htmxWebjarsModuleFactory; + + public HtmxWebjarsApplicationService() { + this.htmxWebjarsModuleFactory = new HtmxWebjarsModuleFactory(); + } + + public JHipsterModule buildWebjarsModule(JHipsterModuleProperties properties) { + return htmxWebjarsModuleFactory.buildModule(properties); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java new file mode 100644 index 00000000000..372c817d7aa --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java @@ -0,0 +1,24 @@ +package tech.jhipster.lite.generator.server.webjars.htmx.domain; + +import static tech.jhipster.lite.module.domain.JHipsterModule.*; + +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.javabuild.GroupId; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; +import tech.jhipster.lite.shared.error.domain.Assert; + +public class HtmxWebjarsModuleFactory { + + private static final GroupId WEBJARS_NPM_GROUP = groupId("org.webjars.npm"); + + public JHipsterModule buildModule(JHipsterModuleProperties properties) { + Assert.notNull("properties", properties); + //@formatter:off + return moduleBuilder(properties) + .javaDependencies() + .addDependency(WEBJARS_NPM_GROUP, artifactId("htmx.org")) + .and() + .build(); + //@formatter:on + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java new file mode 100644 index 00000000000..0c3651d07c7 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java @@ -0,0 +1,28 @@ +package tech.jhipster.lite.generator.server.webjars.htmx.infrastructure.primary; + +import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.*; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import tech.jhipster.lite.generator.server.webjars.htmx.application.HtmxWebjarsApplicationService; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; +import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; + +@Configuration +class HtmxWebjarsModuleConfiguration { + + @Bean + public JHipsterModuleResource htmxWebjarsModule(HtmxWebjarsApplicationService htmxWebjarsModule) { + return JHipsterModuleResource + .builder() + .slug(HTMX_WEBJARS) + .propertiesDefinition( + JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() + ) + .apiDoc("WebJars", "Add HTMX webjar to the project") + .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) + .tags("server", "web", "webjars", "htmx") + .factory(htmxWebjarsModule::buildWebjarsModule); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java new file mode 100644 index 00000000000..4e305b2043b --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java @@ -0,0 +1,2 @@ +@tech.jhipster.lite.BusinessContext +package tech.jhipster.lite.generator.server.webjars.htmx; diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java new file mode 100644 index 00000000000..85573e2dc84 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java @@ -0,0 +1,20 @@ +package tech.jhipster.lite.generator.server.webjars.locator.application; + +import org.springframework.stereotype.Service; +import tech.jhipster.lite.generator.server.webjars.locator.domain.WebjarsLocatorModuleFactory; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@Service +public class WebjarsLocatorApplicationService { + + private final WebjarsLocatorModuleFactory webjarsModuleFactory; + + public WebjarsLocatorApplicationService() { + webjarsModuleFactory = new WebjarsLocatorModuleFactory(); + } + + public JHipsterModule buildWebjarsModule(JHipsterModuleProperties properties) { + return webjarsModuleFactory.buildModule(properties); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java similarity index 86% rename from src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java rename to src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java index a1f60bae600..214a535d512 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java @@ -1,4 +1,4 @@ -package tech.jhipster.lite.generator.server.webjars.domain; +package tech.jhipster.lite.generator.server.webjars.locator.domain; import static tech.jhipster.lite.module.domain.JHipsterModule.*; @@ -7,7 +7,7 @@ import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; import tech.jhipster.lite.shared.error.domain.Assert; -public class WebjarsModuleFactory { +public class WebjarsLocatorModuleFactory { private static final GroupId WEBJARS_GROUP = groupId("org.webjars"); diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java similarity index 67% rename from src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java rename to src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java index b221ca2ae2e..3a6f87ba8c4 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java @@ -1,23 +1,22 @@ -package tech.jhipster.lite.generator.server.webjars.infrastructure.primary; +package tech.jhipster.lite.generator.server.webjars.locator.infrastructure.primary; -import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.SPRING_BOOT_THYMELEAF; -import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.WEBJARS; +import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.*; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import tech.jhipster.lite.generator.server.webjars.application.WebjarsApplicationService; +import tech.jhipster.lite.generator.server.webjars.locator.application.WebjarsLocatorApplicationService; import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; @Configuration -class WebjarsModuleConfiguration { +class WebjarsLocatorModuleConfiguration { @Bean - public JHipsterModuleResource webjarsModule(WebjarsApplicationService webjarsModule) { + public JHipsterModuleResource webjarsLocatorModule(WebjarsLocatorApplicationService webjarsModule) { return JHipsterModuleResource .builder() - .slug(WEBJARS) + .slug(WEBJARS_LOCATOR) .propertiesDefinition( JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() ) diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java new file mode 100644 index 00000000000..c9d37a928d1 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java @@ -0,0 +1,2 @@ +@tech.jhipster.lite.BusinessContext +package tech.jhipster.lite.generator.server.webjars.locator; diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java deleted file mode 100644 index bfa079f1125..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -@tech.jhipster.lite.BusinessContext -package tech.jhipster.lite.generator.server.webjars; diff --git a/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java b/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java index 3b62dc41be1..a5d71ceaec7 100644 --- a/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java +++ b/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java @@ -118,7 +118,8 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory { SPRINGDOC_OAUTH_2_AUTH_0("springdoc-oauth2-auth0"), SPRINGDOC_OAUTH_2_OKTA("springdoc-oauth2-okta"), SPRINGDOC_WEBFLUX_OPENAPI("springdoc-webflux-openapi"), - WEBJARS("webjars"), + WEBJARS_LOCATOR("webjars-locator"), + HTMX_WEBJARS("htmx-webjars"), SVELTE_CORE("svelte-core"), TYPESCRIPT("typescript"), VUE_CORE("vue-core"), diff --git a/src/main/resources/generator/dependencies/pom.xml b/src/main/resources/generator/dependencies/pom.xml index 526ce78f59c..525a9470268 100644 --- a/src/main/resources/generator/dependencies/pom.xml +++ b/src/main/resources/generator/dependencies/pom.xml @@ -51,6 +51,7 @@ 4.3.1.0 3.3.0 0.50 + 1.9.9 @@ -267,6 +268,11 @@ webjars-locator ${webjars-locator.version} + + org.webjars.npm + htmx.org + ${htmx-webjars.version} + nz.net.ultraq.thymeleaf thymeleaf-layout-dialect diff --git a/src/test/features/server/webjars/htmx/htmx-webjars.feature b/src/test/features/server/webjars/htmx/htmx-webjars.feature new file mode 100644 index 00000000000..bb73d3576cc --- /dev/null +++ b/src/test/features/server/webjars/htmx/htmx-webjars.feature @@ -0,0 +1,10 @@ +Feature: HTMX webjars module + + Scenario: Should add HTMX webjars + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-thymeleaf | + | webjars-locator | + | htmx-webjars | + Then I should have "htmx.org" in "pom.xml" diff --git a/src/test/features/server/webjars/webjars.feature b/src/test/features/server/webjars/locator/webjars-locator.feature similarity index 80% rename from src/test/features/server/webjars/webjars.feature rename to src/test/features/server/webjars/locator/webjars-locator.feature index f4fc3cacdc3..ad13a4baeb6 100644 --- a/src/test/features/server/webjars/webjars.feature +++ b/src/test/features/server/webjars/locator/webjars-locator.feature @@ -1,9 +1,9 @@ -Feature: WebJars module +Feature: WebJars Locator module Scenario: Should add WebJars locator When I apply modules to default project | maven-java | | spring-boot | | spring-boot-thymeleaf | - | webjars | + | webjars-locator | Then I should have "webjars-locator" in "pom.xml" diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java new file mode 100644 index 00000000000..de4d1be5f0d --- /dev/null +++ b/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java @@ -0,0 +1,39 @@ +package tech.jhipster.lite.generator.server.webjars.htmx.domain; + +import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.assertThatModuleWithFiles; +import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.pomFile; + +import org.junit.jupiter.api.Test; +import tech.jhipster.lite.TestFileUtils; +import tech.jhipster.lite.UnitTest; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.JHipsterModulesFixture; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@UnitTest +class HtmxWebjarsModuleFactoryTest { + + private static final HtmxWebjarsModuleFactory factory = new HtmxWebjarsModuleFactory(); + + @Test + void shouldCreateWebjarsModule() { + JHipsterModuleProperties properties = JHipsterModulesFixture + .propertiesBuilder(TestFileUtils.tmpDirForTest()) + .basePackage("com.jhipster.test") + .projectBaseName("myapp") + .build(); + + JHipsterModule module = factory.buildModule(properties); + + assertThatModuleWithFiles(module, pomFile()) + .hasFile("pom.xml") + .containing( + """ + + org.webjars.npm + htmx.org + + """ + ); + } +} diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java similarity index 84% rename from src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java rename to src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java index a00d37c0c5b..344f5d40f61 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java @@ -1,4 +1,4 @@ -package tech.jhipster.lite.generator.server.webjars.domain; +package tech.jhipster.lite.generator.server.webjars.locator.domain; import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.assertThatModuleWithFiles; import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.pomFile; @@ -11,9 +11,9 @@ import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; @UnitTest -class WebjarsModuleFactoryTest { +class WebjarsLocatorModuleFactoryTest { - private static final WebjarsModuleFactory factory = new WebjarsModuleFactory(); + private static final WebjarsLocatorModuleFactory factory = new WebjarsLocatorModuleFactory(); @Test void shouldCreateWebjarsModule() { From 5bb9534da010e521580095ae59730c5cf10e55fc Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Wed, 6 Dec 2023 20:32:21 +0100 Subject: [PATCH 2/5] use a single webjars module supporting multiple webjars --- .../WebjarsApplicationService.java | 28 +++++++ .../webjars/domain/WebjarsModuleFactory.java | 48 +++++++++++ .../HtmxWebjarsApplicationService.java | 20 ----- .../htmx/domain/HtmxWebjarsModuleFactory.java | 24 ------ .../HtmxWebjarsModuleConfiguration.java | 28 ------- .../server/webjars/htmx/package-info.java | 2 - .../primary/WebjarsModuleConfiguration.java | 56 +++++++++++++ .../WebjarsLocatorApplicationService.java | 20 ----- .../domain/WebjarsLocatorModuleFactory.java | 25 ------ .../WebjarsLocatorModuleConfiguration.java | 28 ------- .../server/webjars/locator/package-info.java | 2 - .../server/webjars/package-info.java | 2 + .../slug/domain/JHLiteModuleSlug.java | 1 + .../resources/generator/dependencies/pom.xml | 6 ++ .../server/webjars/htmx/htmx-webjars.feature | 10 --- .../webjars/locator/webjars-locator.feature | 9 -- .../features/server/webjars/webjars.feature | 29 +++++++ .../domain/WebjarsModuleFactoryTest.java | 83 +++++++++++++++++++ .../domain/HtmxWebjarsModuleFactoryTest.java | 39 --------- .../WebjarsLocatorModuleFactoryTest.java | 39 --------- tests-ci/generate.sh | 5 +- 21 files changed, 257 insertions(+), 247 deletions(-) create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java delete mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java create mode 100644 src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java delete mode 100644 src/test/features/server/webjars/htmx/htmx-webjars.feature delete mode 100644 src/test/features/server/webjars/locator/webjars-locator.feature create mode 100644 src/test/features/server/webjars/webjars.feature create mode 100644 src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java delete mode 100644 src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java delete mode 100644 src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java new file mode 100644 index 00000000000..141e3c594cf --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/application/WebjarsApplicationService.java @@ -0,0 +1,28 @@ +package tech.jhipster.lite.generator.server.webjars.application; + +import org.springframework.stereotype.Service; +import tech.jhipster.lite.generator.server.webjars.domain.WebjarsModuleFactory; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@Service +public class WebjarsApplicationService { + + private final WebjarsModuleFactory webjarsModuleFactory; + + public WebjarsApplicationService() { + webjarsModuleFactory = new WebjarsModuleFactory(); + } + + public JHipsterModule buildWebjarsLocatorModule(JHipsterModuleProperties properties) { + return webjarsModuleFactory.buildWebjarsLocatorModule(properties); + } + + public JHipsterModule buildWebjarsHtmxModule(JHipsterModuleProperties properties) { + return webjarsModuleFactory.buildWebjarsHtmxModule(properties); + } + + public JHipsterModule buildWebjarsAlpineJSModule(JHipsterModuleProperties properties) { + return webjarsModuleFactory.buildWebjarsAlpineJSModule(properties); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java new file mode 100644 index 00000000000..51c1d6c2f97 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java @@ -0,0 +1,48 @@ +package tech.jhipster.lite.generator.server.webjars.domain; + +import static tech.jhipster.lite.module.domain.JHipsterModule.*; + +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.javabuild.GroupId; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; +import tech.jhipster.lite.shared.error.domain.Assert; + +public class WebjarsModuleFactory { + + private static final GroupId WEBJARS_GROUP = groupId("org.webjars"); + private static final GroupId WEBJARS_NPM_GROUP = groupId("org.webjars.npm"); + + public JHipsterModule buildWebjarsLocatorModule(JHipsterModuleProperties properties) { + Assert.notNull("properties", properties); + + //@formatter:off + return moduleBuilder(properties) + .javaDependencies() + .addDependency(WEBJARS_GROUP, artifactId("webjars-locator")) + .and() + .build(); + //@formatter:on + } + + public JHipsterModule buildWebjarsHtmxModule(JHipsterModuleProperties properties) { + Assert.notNull("properties", properties); + //@formatter:off + return moduleBuilder(properties) + .javaDependencies() + .addDependency(WEBJARS_NPM_GROUP, artifactId("htmx.org")) + .and() + .build(); + //@formatter:on + } + + public JHipsterModule buildWebjarsAlpineJSModule(JHipsterModuleProperties properties) { + Assert.notNull("properties", properties); + //@formatter:off + return moduleBuilder(properties) + .javaDependencies() + .addDependency(WEBJARS_NPM_GROUP, artifactId("alpinejs")) + .and() + .build(); + //@formatter:on + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java deleted file mode 100644 index 5b5ccf2491f..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/application/HtmxWebjarsApplicationService.java +++ /dev/null @@ -1,20 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.htmx.application; - -import org.springframework.stereotype.Service; -import tech.jhipster.lite.generator.server.webjars.htmx.domain.HtmxWebjarsModuleFactory; -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; - -@Service -public class HtmxWebjarsApplicationService { - - private final HtmxWebjarsModuleFactory htmxWebjarsModuleFactory; - - public HtmxWebjarsApplicationService() { - this.htmxWebjarsModuleFactory = new HtmxWebjarsModuleFactory(); - } - - public JHipsterModule buildWebjarsModule(JHipsterModuleProperties properties) { - return htmxWebjarsModuleFactory.buildModule(properties); - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java deleted file mode 100644 index 372c817d7aa..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.htmx.domain; - -import static tech.jhipster.lite.module.domain.JHipsterModule.*; - -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.javabuild.GroupId; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; -import tech.jhipster.lite.shared.error.domain.Assert; - -public class HtmxWebjarsModuleFactory { - - private static final GroupId WEBJARS_NPM_GROUP = groupId("org.webjars.npm"); - - public JHipsterModule buildModule(JHipsterModuleProperties properties) { - Assert.notNull("properties", properties); - //@formatter:off - return moduleBuilder(properties) - .javaDependencies() - .addDependency(WEBJARS_NPM_GROUP, artifactId("htmx.org")) - .and() - .build(); - //@formatter:on - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java deleted file mode 100644 index 0c3651d07c7..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/infrastructure/primary/HtmxWebjarsModuleConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.htmx.infrastructure.primary; - -import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.*; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import tech.jhipster.lite.generator.server.webjars.htmx.application.HtmxWebjarsApplicationService; -import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; -import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; -import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; - -@Configuration -class HtmxWebjarsModuleConfiguration { - - @Bean - public JHipsterModuleResource htmxWebjarsModule(HtmxWebjarsApplicationService htmxWebjarsModule) { - return JHipsterModuleResource - .builder() - .slug(HTMX_WEBJARS) - .propertiesDefinition( - JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() - ) - .apiDoc("WebJars", "Add HTMX webjar to the project") - .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) - .tags("server", "web", "webjars", "htmx") - .factory(htmxWebjarsModule::buildWebjarsModule); - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java deleted file mode 100644 index 4e305b2043b..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/htmx/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -@tech.jhipster.lite.BusinessContext -package tech.jhipster.lite.generator.server.webjars.htmx; diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java new file mode 100644 index 00000000000..ac65f3cbccc --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java @@ -0,0 +1,56 @@ +package tech.jhipster.lite.generator.server.webjars.infrastructure.primary; + +import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.*; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import tech.jhipster.lite.generator.server.webjars.application.WebjarsApplicationService; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; +import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; +import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; + +@Configuration +class WebjarsModuleConfiguration { + + @Bean + public JHipsterModuleResource webjarsLocatorModule(WebjarsApplicationService webjarsModule) { + return JHipsterModuleResource + .builder() + .slug(WEBJARS_LOCATOR) + .propertiesDefinition( + JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() + ) + .apiDoc("WebJars", "Add webjars locator to the project") + .organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT_THYMELEAF).build()) + .tags("server", "web") + .factory(webjarsModule::buildWebjarsLocatorModule); + } + + @Bean + public JHipsterModuleResource webjarsHtmxModule(WebjarsApplicationService webjarsModule) { + return JHipsterModuleResource + .builder() + .slug(HTMX_WEBJARS) + .propertiesDefinition( + JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() + ) + .apiDoc("WebJars", "Add HTMX webjar to the project") + .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) + .tags("server", "web") + .factory(webjarsModule::buildWebjarsHtmxModule); + } + + @Bean + public JHipsterModuleResource webjarsAlpineJSModule(WebjarsApplicationService webjarsModule) { + return JHipsterModuleResource + .builder() + .slug(ALPINE_JS_WEBJARS) + .propertiesDefinition( + JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() + ) + .apiDoc("WebJars", "Add alpine.js webjar to the project") + .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) + .tags("server", "web") + .factory(webjarsModule::buildWebjarsAlpineJSModule); + } +} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java deleted file mode 100644 index 85573e2dc84..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/application/WebjarsLocatorApplicationService.java +++ /dev/null @@ -1,20 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.locator.application; - -import org.springframework.stereotype.Service; -import tech.jhipster.lite.generator.server.webjars.locator.domain.WebjarsLocatorModuleFactory; -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; - -@Service -public class WebjarsLocatorApplicationService { - - private final WebjarsLocatorModuleFactory webjarsModuleFactory; - - public WebjarsLocatorApplicationService() { - webjarsModuleFactory = new WebjarsLocatorModuleFactory(); - } - - public JHipsterModule buildWebjarsModule(JHipsterModuleProperties properties) { - return webjarsModuleFactory.buildModule(properties); - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java deleted file mode 100644 index 214a535d512..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.locator.domain; - -import static tech.jhipster.lite.module.domain.JHipsterModule.*; - -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.javabuild.GroupId; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; -import tech.jhipster.lite.shared.error.domain.Assert; - -public class WebjarsLocatorModuleFactory { - - private static final GroupId WEBJARS_GROUP = groupId("org.webjars"); - - public JHipsterModule buildModule(JHipsterModuleProperties properties) { - Assert.notNull("properties", properties); - - //@formatter:off - return moduleBuilder(properties) - .javaDependencies() - .addDependency(WEBJARS_GROUP, artifactId("webjars-locator")) - .and() - .build(); - //@formatter:on - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java deleted file mode 100644 index 3a6f87ba8c4..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/infrastructure/primary/WebjarsLocatorModuleConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.locator.infrastructure.primary; - -import static tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug.*; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import tech.jhipster.lite.generator.server.webjars.locator.application.WebjarsLocatorApplicationService; -import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; -import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; -import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; - -@Configuration -class WebjarsLocatorModuleConfiguration { - - @Bean - public JHipsterModuleResource webjarsLocatorModule(WebjarsLocatorApplicationService webjarsModule) { - return JHipsterModuleResource - .builder() - .slug(WEBJARS_LOCATOR) - .propertiesDefinition( - JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() - ) - .apiDoc("WebJars", "Add WebJars to the project") - .organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT_THYMELEAF).build()) - .tags("server", "web") - .factory(webjarsModule::buildWebjarsModule); - } -} diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java deleted file mode 100644 index c9d37a928d1..00000000000 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/locator/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -@tech.jhipster.lite.BusinessContext -package tech.jhipster.lite.generator.server.webjars.locator; diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java new file mode 100644 index 00000000000..bfa079f1125 --- /dev/null +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/package-info.java @@ -0,0 +1,2 @@ +@tech.jhipster.lite.BusinessContext +package tech.jhipster.lite.generator.server.webjars; diff --git a/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java b/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java index a5d71ceaec7..dab3fdec7b9 100644 --- a/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java +++ b/src/main/java/tech/jhipster/lite/generator/slug/domain/JHLiteModuleSlug.java @@ -120,6 +120,7 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory { SPRINGDOC_WEBFLUX_OPENAPI("springdoc-webflux-openapi"), WEBJARS_LOCATOR("webjars-locator"), HTMX_WEBJARS("htmx-webjars"), + ALPINE_JS_WEBJARS("alpinejs-webjars"), SVELTE_CORE("svelte-core"), TYPESCRIPT("typescript"), VUE_CORE("vue-core"), diff --git a/src/main/resources/generator/dependencies/pom.xml b/src/main/resources/generator/dependencies/pom.xml index 525a9470268..174da1c135a 100644 --- a/src/main/resources/generator/dependencies/pom.xml +++ b/src/main/resources/generator/dependencies/pom.xml @@ -52,6 +52,7 @@ 3.3.0 0.50 1.9.9 + 3.13.3 @@ -273,6 +274,11 @@ htmx.org ${htmx-webjars.version} + + org.webjars.npm + alpinejs + ${alpinejs-webjars.version} + nz.net.ultraq.thymeleaf thymeleaf-layout-dialect diff --git a/src/test/features/server/webjars/htmx/htmx-webjars.feature b/src/test/features/server/webjars/htmx/htmx-webjars.feature deleted file mode 100644 index bb73d3576cc..00000000000 --- a/src/test/features/server/webjars/htmx/htmx-webjars.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: HTMX webjars module - - Scenario: Should add HTMX webjars - When I apply modules to default project - | maven-java | - | spring-boot | - | spring-boot-thymeleaf | - | webjars-locator | - | htmx-webjars | - Then I should have "htmx.org" in "pom.xml" diff --git a/src/test/features/server/webjars/locator/webjars-locator.feature b/src/test/features/server/webjars/locator/webjars-locator.feature deleted file mode 100644 index ad13a4baeb6..00000000000 --- a/src/test/features/server/webjars/locator/webjars-locator.feature +++ /dev/null @@ -1,9 +0,0 @@ -Feature: WebJars Locator module - - Scenario: Should add WebJars locator - When I apply modules to default project - | maven-java | - | spring-boot | - | spring-boot-thymeleaf | - | webjars-locator | - Then I should have "webjars-locator" in "pom.xml" diff --git a/src/test/features/server/webjars/webjars.feature b/src/test/features/server/webjars/webjars.feature new file mode 100644 index 00000000000..dde882d4259 --- /dev/null +++ b/src/test/features/server/webjars/webjars.feature @@ -0,0 +1,29 @@ +Feature: WebJars module + + Scenario: Should add WebJars locator + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-thymeleaf | + | webjars-locator | + Then I should have "webjars-locator" in "pom.xml" + + Scenario: Should add HTMX webjar + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-thymeleaf | + | webjars-locator | + | htmx-webjars | + Then I should have "htmx.org" in "pom.xml" + + Scenario: Should add alpine.js webjar + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-thymeleaf | + | webjars-locator | + | alpinejs-webjars | + Then I should have "alpinejs" in "pom.xml" + + diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java new file mode 100644 index 00000000000..65cfe073264 --- /dev/null +++ b/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java @@ -0,0 +1,83 @@ +package tech.jhipster.lite.generator.server.webjars.domain; + +import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.assertThatModuleWithFiles; +import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.pomFile; + +import org.junit.jupiter.api.Test; +import tech.jhipster.lite.TestFileUtils; +import tech.jhipster.lite.UnitTest; +import tech.jhipster.lite.module.domain.JHipsterModule; +import tech.jhipster.lite.module.domain.JHipsterModulesFixture; +import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; + +@UnitTest +class WebjarsModuleFactoryTest { + + private static final WebjarsModuleFactory factory = new WebjarsModuleFactory(); + + @Test + void shouldCreateWebjarsLocatorModule() { + JHipsterModuleProperties properties = JHipsterModulesFixture + .propertiesBuilder(TestFileUtils.tmpDirForTest()) + .basePackage("com.jhipster.test") + .projectBaseName("myapp") + .build(); + + JHipsterModule module = factory.buildWebjarsLocatorModule(properties); + + assertThatModuleWithFiles(module, pomFile()) + .hasFile("pom.xml") + .containing( + """ + + org.webjars + webjars-locator + + """ + ); + } + + @Test + void shouldCreateHtmxWebjarsModule() { + JHipsterModuleProperties properties = JHipsterModulesFixture + .propertiesBuilder(TestFileUtils.tmpDirForTest()) + .basePackage("com.jhipster.test") + .projectBaseName("myapp") + .build(); + + JHipsterModule module = factory.buildWebjarsHtmxModule(properties); + + assertThatModuleWithFiles(module, pomFile()) + .hasFile("pom.xml") + .containing( + """ + + org.webjars.npm + htmx.org + + """ + ); + } + + @Test + void shouldCreateAlpineJSWebjarsModule() { + JHipsterModuleProperties properties = JHipsterModulesFixture + .propertiesBuilder(TestFileUtils.tmpDirForTest()) + .basePackage("com.jhipster.test") + .projectBaseName("myapp") + .build(); + + JHipsterModule module = factory.buildWebjarsAlpineJSModule(properties); + + assertThatModuleWithFiles(module, pomFile()) + .hasFile("pom.xml") + .containing( + """ + + org.webjars.npm + alpinejs + + """ + ); + } +} diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java deleted file mode 100644 index de4d1be5f0d..00000000000 --- a/src/test/java/tech/jhipster/lite/generator/server/webjars/htmx/domain/HtmxWebjarsModuleFactoryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.htmx.domain; - -import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.assertThatModuleWithFiles; -import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.pomFile; - -import org.junit.jupiter.api.Test; -import tech.jhipster.lite.TestFileUtils; -import tech.jhipster.lite.UnitTest; -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.JHipsterModulesFixture; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; - -@UnitTest -class HtmxWebjarsModuleFactoryTest { - - private static final HtmxWebjarsModuleFactory factory = new HtmxWebjarsModuleFactory(); - - @Test - void shouldCreateWebjarsModule() { - JHipsterModuleProperties properties = JHipsterModulesFixture - .propertiesBuilder(TestFileUtils.tmpDirForTest()) - .basePackage("com.jhipster.test") - .projectBaseName("myapp") - .build(); - - JHipsterModule module = factory.buildModule(properties); - - assertThatModuleWithFiles(module, pomFile()) - .hasFile("pom.xml") - .containing( - """ - - org.webjars.npm - htmx.org - - """ - ); - } -} diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java deleted file mode 100644 index 344f5d40f61..00000000000 --- a/src/test/java/tech/jhipster/lite/generator/server/webjars/locator/domain/WebjarsLocatorModuleFactoryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package tech.jhipster.lite.generator.server.webjars.locator.domain; - -import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.assertThatModuleWithFiles; -import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.pomFile; - -import org.junit.jupiter.api.Test; -import tech.jhipster.lite.TestFileUtils; -import tech.jhipster.lite.UnitTest; -import tech.jhipster.lite.module.domain.JHipsterModule; -import tech.jhipster.lite.module.domain.JHipsterModulesFixture; -import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; - -@UnitTest -class WebjarsLocatorModuleFactoryTest { - - private static final WebjarsLocatorModuleFactory factory = new WebjarsLocatorModuleFactory(); - - @Test - void shouldCreateWebjarsModule() { - JHipsterModuleProperties properties = JHipsterModulesFixture - .propertiesBuilder(TestFileUtils.tmpDirForTest()) - .basePackage("com.jhipster.test") - .projectBaseName("myapp") - .build(); - - JHipsterModule module = factory.buildModule(properties); - - assertThatModuleWithFiles(module, pomFile()) - .hasFile("pom.xml") - .containing( - """ - - org.webjars - webjars-locator - - """ - ); - } -} diff --git a/tests-ci/generate.sh b/tests-ci/generate.sh index 9c29892c197..95e534197b6 100755 --- a/tests-ci/generate.sh +++ b/tests-ci/generate.sh @@ -418,7 +418,10 @@ elif [[ $application == 'thymeleafapp' ]]; then spring_boot_mvc sonar_back - applyModules "spring-boot-thymeleaf" + applyModules \ + "spring-boot-thymeleaf" \ + "webjars-locator" \ + "htmx-webjars" else echo "*** Unknown configuration..." From 30932ad9c4820edadf3f770b5fa6a149e64b413c Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Wed, 6 Dec 2023 20:51:02 +0100 Subject: [PATCH 3/5] add missing version slugs --- .../webjars/domain/WebjarsModuleFactory.java | 14 ++++++++------ .../primary/WebjarsModuleConfiguration.java | 16 ++++++++++------ .../webjars/domain/WebjarsModuleFactoryTest.java | 3 +++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java index 51c1d6c2f97..73331fa625d 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactory.java @@ -9,38 +9,40 @@ public class WebjarsModuleFactory { + private static final String PROPERTIES_FIELD = "properties"; private static final GroupId WEBJARS_GROUP = groupId("org.webjars"); private static final GroupId WEBJARS_NPM_GROUP = groupId("org.webjars.npm"); public JHipsterModule buildWebjarsLocatorModule(JHipsterModuleProperties properties) { - Assert.notNull("properties", properties); + Assert.notNull(PROPERTIES_FIELD, properties); //@formatter:off return moduleBuilder(properties) .javaDependencies() - .addDependency(WEBJARS_GROUP, artifactId("webjars-locator")) + .addDependency(javaDependency().groupId(WEBJARS_GROUP).artifactId("webjars-locator").versionSlug("webjars-locator.version").build()) .and() .build(); //@formatter:on } public JHipsterModule buildWebjarsHtmxModule(JHipsterModuleProperties properties) { - Assert.notNull("properties", properties); + Assert.notNull(PROPERTIES_FIELD, properties); //@formatter:off return moduleBuilder(properties) .javaDependencies() - .addDependency(WEBJARS_NPM_GROUP, artifactId("htmx.org")) + .addDependency(javaDependency().groupId(WEBJARS_NPM_GROUP).artifactId("htmx.org").versionSlug("htmx-webjars.version").build()) .and() .build(); //@formatter:on } public JHipsterModule buildWebjarsAlpineJSModule(JHipsterModuleProperties properties) { - Assert.notNull("properties", properties); + Assert.notNull(PROPERTIES_FIELD, properties); + //@formatter:off return moduleBuilder(properties) .javaDependencies() - .addDependency(WEBJARS_NPM_GROUP, artifactId("alpinejs")) + .addDependency(javaDependency().groupId(WEBJARS_NPM_GROUP).artifactId("alpinejs").versionSlug("alpinejs-webjars.version").build()) .and() .build(); //@formatter:on diff --git a/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java index ac65f3cbccc..78f26b482c1 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/webjars/infrastructure/primary/WebjarsModuleConfiguration.java @@ -12,6 +12,10 @@ @Configuration class WebjarsModuleConfiguration { + private static final String SERVER_TAG = "server"; + private static final String WEB_TAG = "web"; + private static final String WEBJARS_GROUP = "WebJars"; + @Bean public JHipsterModuleResource webjarsLocatorModule(WebjarsApplicationService webjarsModule) { return JHipsterModuleResource @@ -20,9 +24,9 @@ public JHipsterModuleResource webjarsLocatorModule(WebjarsApplicationService web .propertiesDefinition( JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() ) - .apiDoc("WebJars", "Add webjars locator to the project") + .apiDoc(WEBJARS_GROUP, "Add webjars locator to the project") .organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT_THYMELEAF).build()) - .tags("server", "web") + .tags(SERVER_TAG, WEB_TAG) .factory(webjarsModule::buildWebjarsLocatorModule); } @@ -34,9 +38,9 @@ public JHipsterModuleResource webjarsHtmxModule(WebjarsApplicationService webjar .propertiesDefinition( JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() ) - .apiDoc("WebJars", "Add HTMX webjar to the project") + .apiDoc(WEBJARS_GROUP, "Add HTMX webjar to the project") .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) - .tags("server", "web") + .tags(SERVER_TAG, WEB_TAG) .factory(webjarsModule::buildWebjarsHtmxModule); } @@ -48,9 +52,9 @@ public JHipsterModuleResource webjarsAlpineJSModule(WebjarsApplicationService we .propertiesDefinition( JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addConfigurationFormat().build() ) - .apiDoc("WebJars", "Add alpine.js webjar to the project") + .apiDoc(WEBJARS_GROUP, "Add alpine.js webjar to the project") .organization(JHipsterModuleOrganization.builder().addDependency(WEBJARS_LOCATOR).build()) - .tags("server", "web") + .tags(SERVER_TAG, WEB_TAG) .factory(webjarsModule::buildWebjarsAlpineJSModule); } } diff --git a/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java index 65cfe073264..3634af3492e 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/webjars/domain/WebjarsModuleFactoryTest.java @@ -32,6 +32,7 @@ void shouldCreateWebjarsLocatorModule() { org.webjars webjars-locator + ${webjars-locator.version} """ ); @@ -54,6 +55,7 @@ void shouldCreateHtmxWebjarsModule() { org.webjars.npm htmx.org + ${htmx-webjars.version} """ ); @@ -76,6 +78,7 @@ void shouldCreateAlpineJSWebjarsModule() { org.webjars.npm alpinejs + ${alpinejs-webjars.version} """ ); From b269e6a25b825314d08287d246181987a3d2dee6 Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Wed, 6 Dec 2023 20:52:44 +0100 Subject: [PATCH 4/5] add missing version slug for thymleag layout dialect --- .../thymeleaf/domain/SpringBootThymeleafModuleFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactory.java index 4884d10c0d4..61e0528b427 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactory.java @@ -18,7 +18,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { return moduleBuilder(properties) .javaDependencies() .addDependency(SPRING_GROUP, artifactId("spring-boot-starter-thymeleaf")) - .addDependency(groupId("nz.net.ultraq.thymeleaf"), artifactId("thymeleaf-layout-dialect")) + .addDependency(javaDependency().groupId("nz.net.ultraq.thymeleaf").artifactId("thymeleaf-layout-dialect").versionSlug("thymeleaf-layout-dialect.version").build()) .and() .build(); //@formatter:on From 8362ea25918755345e4e6a6009170a904861a846 Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Wed, 6 Dec 2023 21:50:23 +0100 Subject: [PATCH 5/5] adapt test for thymeleaf layout dialect version --- .../thymeleaf/domain/SpringBootThymeleafModuleFactoryTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactoryTest.java index 2921edad299..eedbf657098 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/thymeleaf/domain/SpringBootThymeleafModuleFactoryTest.java @@ -42,6 +42,7 @@ void shouldCreateSpringBootThymeleafModule() { nz.net.ultraq.thymeleaf thymeleaf-layout-dialect + ${thymeleaf-layout-dialect.version} """ );