Skip to content

Commit

Permalink
Add spring-mvc-server feature so springdoc-mvc-openapi can depend on it
Browse files Browse the repository at this point in the history
Fixes #4153
  • Loading branch information
murdos committed Jan 2, 2023
1 parent dcbabf0 commit 40336b2
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum JHLiteFeatureSlug implements JHipsterFeatureSlugFactory {
OAUTH_PROVIDER_SPRINGDOC("oauth-provider-springdoc"),
SERVICE_DISCOVERY("service-discovery"),
SPRING_SERVER("spring-server"),
SPRING_MVC_SERVER("spring-mvc-server"),
SPRINGDOC("springdoc");

private final String slug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory {
SPRING_BOOT_OAUTH_2_AUTH_0("spring-boot-oauth2-auth0"),
SPRING_BOOT_OAUTH_2_OKTA("spring-boot-oauth2-okta"),
SPRING_BOOT_PULSAR("spring-boot-pulsar"),
SPRING_BOOT_MVC("spring-boot-mvc"),
SPRING_BOOT_TOMCAT("spring-boot-tomcat"),
SPRING_BOOT_UNDERTOW("spring-boot-undertow"),
SPRING_BOOT_WEBFLUX("spring-boot-webflux"),
SPRING_BOOT_WEBFLUX_NETTY("spring-boot-webflux-netty"),
SPRING_CLOUD("spring-cloud"),
SPRINGDOC_JWT("springdoc-jwt"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ JHipsterModuleResource springdocMvcModule(SpringdocApplicationService springdocA
.slug(SPRINGDOC_MVC_OPENAPI)
.propertiesDefinition(buildPropertiesDefinition())
.apiDoc(API_GROUP, "Add springdoc-openapi for spring MVC")
.organization(JHipsterModuleOrganization.builder().feature(SPRINGDOC).addDependency(SPRING_BOOT_TOMCAT).build())
.organization(JHipsterModuleOrganization.builder().feature(SPRINGDOC).addDependency(SPRING_MVC_SERVER).build())
.tags(SERVER_TAG, SPRING_TAG, SPRING_BOOT_TAG, DOCUMENTATION_TAG, SWAGGER_TAG)
.factory(springdocApplicationService::buildSpringdocMvcModule);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ public JHipsterModule buildTomcatModule(JHipsterModuleProperties properties) {
public JHipsterModule buildUndertowModule(JHipsterModuleProperties properties) {
return factory.buildUndertowModule(properties);
}

public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) {
return factory.buildEmptyModule(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class SpringBootMvcsModulesFactory {

private static final String CORS_PRIMARY = "security/infrastructure/primary";

public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) {
return moduleBuilder(properties).build();
}

public JHipsterModule buildTomcatModule(JHipsterModuleProperties properties) {
Assert.notNull("properties", properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ class SpringBootMvcModulesConfiguration {

private static final String SPRING_BOOT_TAG = "spring-boot";

@Bean
JHipsterModuleResource springBootMvcModule(SpringBootMvcApplicationService springBootMvc) {
return JHipsterModuleResource
.builder()
.slug(SPRING_BOOT_MVC)
.propertiesDefinition(properties())
.apiDoc("Spring Boot MVC", "Add Spring Boot MVC")
.organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build())
.tags("server", "spring", SPRING_BOOT_TAG, "mvc", "web", "undertow")
.factory(springBootMvc::buildEmptyModule);
}

@Bean
JHipsterModuleResource springBootTomcatMvcModule(SpringBootMvcApplicationService springBootMvc) {
return JHipsterModuleResource
.builder()
.slug(SPRING_BOOT_TOMCAT)
.propertiesDefinition(properties())
.apiDoc("Spring Boot - MVC", "Add Spring Boot MVC with Tomcat")
.organization(organization())
.organization(mvcServerOrganization())
.tags("server", "spring", SPRING_BOOT_TAG, "mvc", "web", "tomcat")
.factory(springBootMvc::buildTomcatModule);
}
Expand All @@ -34,7 +46,7 @@ JHipsterModuleResource springBootUndertowMvcModule(SpringBootMvcApplicationServi
.slug(SPRING_BOOT_UNDERTOW)
.propertiesDefinition(properties())
.apiDoc("Spring Boot - MVC", "Add Spring Boot MVC with Undertow")
.organization(organization())
.organization(mvcServerOrganization())
.tags("server", "spring", SPRING_BOOT_TAG, "mvc", "web", "undertow")
.factory(springBootMvc::buildUndertowModule);
}
Expand All @@ -43,7 +55,7 @@ private JHipsterModulePropertiesDefinition properties() {
return JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build();
}

private JHipsterModuleOrganization organization() {
return JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build();
private JHipsterModuleOrganization mvcServerOrganization() {
return JHipsterModuleOrganization.builder().feature(SPRING_MVC_SERVER).addDependency(SPRING_BOOT_MVC).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public SpringBootWebfluxApplicationService() {
factory = new SpringBootWebfluxModuleFactory();
}

public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return factory.buildModule(properties);
public JHipsterModule buildNettyModule(JHipsterModuleProperties properties) {
return factory.buildNettyModule(properties);
}

public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) {
return factory.buildEmptyModule(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public class SpringBootWebfluxModuleFactory {

private static final String EXCEPTION_PRIMARY = "technical/infrastructure/primary/exception";

public JHipsterModule buildModule(JHipsterModuleProperties properties) {
public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) {
return moduleBuilder(properties).build();
}

public JHipsterModule buildNettyModule(JHipsterModuleProperties properties) {
Assert.notNull("properties", properties);

String packagePath = properties.packagePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ class SpringBootWebfluxModuleConfiguration {

@Bean
JHipsterModuleResource springBootWebfluxModule(SpringBootWebfluxApplicationService webflux) {
return JHipsterModuleResource
.builder()
.slug(SPRING_BOOT_WEBFLUX)
.propertiesDefinition(properties())
.apiDoc("Spring Boot - Webflux", "Add Spring Boot Webflux")
.organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build())
.tags("server", "webflux")
.factory(webflux::buildEmptyModule);
}

@Bean
JHipsterModuleResource springBootWebfluxNettyModule(SpringBootWebfluxApplicationService webflux) {
return JHipsterModuleResource
.builder()
.slug(SPRING_BOOT_WEBFLUX_NETTY)
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build())
.propertiesDefinition(properties())
.apiDoc("Spring Boot - Webflux", "Add Spring Boot Webflux with Netty")
.organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build())
.organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT_WEBFLUX).build())
.tags("server", "webflux")
.factory(webflux::buildModule);
.factory(webflux::buildNettyModule);
}

private static JHipsterModulePropertiesDefinition properties() {
return JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class SpringBootWebfluxModuleFactoryTest {
private static final SpringBootWebfluxModuleFactory factory = new SpringBootWebfluxModuleFactory();

@Test
void shouldBuildModule() {
void shouldBuildWebfluxNettyModule() {
JHipsterModuleProperties properties = JHipsterModulesFixture
.propertiesBuilder(TestFileUtils.tmpDirForTest())
.basePackage("com.jhipster.test")
.put("serverPort", 9000)
.build();

JHipsterModule module = factory.buildModule(properties);
JHipsterModule module = factory.buildNettyModule(properties);

assertThatModuleWithFiles(module, pomFile())
.hasFile("pom.xml")
Expand Down

0 comments on commit 40336b2

Please sign in to comment.