-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2463 from DamnClin/migrate-spring-boot-core
Migrate Spring boot core
- Loading branch information
Showing
65 changed files
with
660 additions
and
1,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...er/springboot/core/domain/SpringBoot.java → .../springboot/common/domain/SpringBoot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 8 additions & 47 deletions
55
...pster/lite/generator/server/springboot/core/application/SpringBootApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,20 @@ | ||
package tech.jhipster.lite.generator.server.springboot.core.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.springboot.core.domain.SpringBootService; | ||
import tech.jhipster.lite.generator.server.springboot.core.domain.SpringBootCoreModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class SpringBootApplicationService { | ||
|
||
private final SpringBootService springBootService; | ||
private final SpringBootCoreModuleFactory factory; | ||
|
||
public SpringBootApplicationService(SpringBootService springBootService) { | ||
this.springBootService = springBootService; | ||
public SpringBootApplicationService() { | ||
factory = new SpringBootCoreModuleFactory(); | ||
} | ||
|
||
public void init(Project project) { | ||
springBootService.init(project); | ||
} | ||
|
||
public void addSpringBootDependenciesBOM(Project project) { | ||
springBootService.addSpringBootDependenciesBOM(project); | ||
} | ||
|
||
public void addSpringBootDependencies(Project project) { | ||
springBootService.addSpringBootDependencies(project); | ||
} | ||
|
||
public void addSpringBootMavenPluginManagement(Project project) { | ||
springBootService.addSpringBootMavenPluginManagement(project); | ||
} | ||
|
||
public void addSpringBootMavenPlugin(Project project) { | ||
springBootService.addSpringBootMavenPlugin(project); | ||
} | ||
|
||
public void addMainApp(Project project) { | ||
springBootService.addMainApp(project); | ||
} | ||
|
||
public void addApplicationProperties(Project project) { | ||
springBootService.addApplicationProperties(project); | ||
} | ||
|
||
public void addApplicationLocalProperties(Project project) { | ||
springBootService.addApplicationLocalProperties(project); | ||
} | ||
|
||
public void addApplicationTestProperties(Project project) { | ||
springBootService.addApplicationTestProperties(project); | ||
} | ||
|
||
public void addLoggingConfiguration(Project project) { | ||
springBootService.addLoggingConfiguration(project); | ||
} | ||
|
||
public void addLoggingTestConfiguration(Project project) { | ||
springBootService.addLoggingTestConfiguration(project); | ||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...ch/jhipster/lite/generator/server/springboot/core/domain/SpringBootCoreModuleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package tech.jhipster.lite.generator.server.springboot.core.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.module.domain.JHipsterDestination; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.JHipsterSource; | ||
import tech.jhipster.lite.module.domain.javabuild.GroupId; | ||
import tech.jhipster.lite.module.domain.javabuildplugin.JavaBuildPlugin; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependency; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyScope; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyType; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
public class SpringBootCoreModuleFactory { | ||
|
||
private static final JHipsterSource SOURCE = from("server/springboot/core"); | ||
|
||
private static final GroupId SRPING_BOOT_GROUP = groupId("org.springframework.boot"); | ||
private static final String APPLICATION_PROPERTIES = "application.properties"; | ||
|
||
private static final JHipsterDestination MAIN_RESOURCE_DESTINATION = to("src/main/resources"); | ||
private static final JHipsterDestination MAIN_CONFIG_DESTINATION = MAIN_RESOURCE_DESTINATION.append("config"); | ||
private static final JHipsterDestination TEST_RESOURCES_DESTINATION = to("src/test/resources"); | ||
private static final JHipsterDestination TEST_CONFIG_DESTINATION = TEST_RESOURCES_DESTINATION.append("config"); | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
String mainClassName = properties.projectBaseName().capitalized(); | ||
String packagePath = properties.basePackage().path(); | ||
JHipsterDestination testDestination = toSrcTestJava().append(packagePath); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.context() | ||
.put("mainClass", mainClassName) | ||
.and() | ||
.javaDependencies() | ||
.dependencyManagement(springBootBom()) | ||
.dependency(SRPING_BOOT_GROUP, artifactId("spring-boot-starter")) | ||
.dependency(springBootConfigurationProcessor()) | ||
.dependency(groupId("org.apache.commons"), artifactId("commons-lang3")) | ||
.dependency(springBootTest()) | ||
.and() | ||
.javaBuildPlugins() | ||
.pluginManagement(springBootPluginManagement()) | ||
.plugin(springBootMavenPlugin()) | ||
.and() | ||
.files() | ||
.add(SOURCE.template("MainApp.java"), toSrcMainJava().append(packagePath).append(mainClassName + "App.java")) | ||
.add(SOURCE.template("MainAppTest.java"), testDestination.append(mainClassName + "AppTest.java")) | ||
.add(SOURCE.template("IntegrationTest.java"), testDestination.append("IntegrationTest.java")) | ||
.add(SOURCE.template(APPLICATION_PROPERTIES), MAIN_CONFIG_DESTINATION.append(APPLICATION_PROPERTIES)) | ||
.add(SOURCE.template("application-local.properties"), MAIN_CONFIG_DESTINATION.append("application-local.properties")) | ||
.add(SOURCE.template("application-test.properties"), TEST_CONFIG_DESTINATION.append(APPLICATION_PROPERTIES)) | ||
.add(SOURCE.template("logback-spring.xml"), MAIN_RESOURCE_DESTINATION.append("logback-spring.xml")) | ||
.add(SOURCE.template("logback.xml"), TEST_RESOURCES_DESTINATION.append("logback.xml")) | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
|
||
private JavaDependency springBootBom() { | ||
return JavaDependency | ||
.builder() | ||
.groupId("org.springframework.boot") | ||
.artifactId("spring-boot-dependencies") | ||
.versionSlug("spring-boot") | ||
.type(JavaDependencyType.POM) | ||
.scope(JavaDependencyScope.IMPORT) | ||
.build(); | ||
} | ||
|
||
private JavaDependency springBootConfigurationProcessor() { | ||
return JavaDependency.builder().groupId(SRPING_BOOT_GROUP).artifactId("spring-boot-configuration-processor").optional().build(); | ||
} | ||
|
||
private JavaDependency springBootTest() { | ||
return JavaDependency | ||
.builder() | ||
.groupId(SRPING_BOOT_GROUP) | ||
.artifactId("spring-boot-starter-test") | ||
.scope(JavaDependencyScope.TEST) | ||
.build(); | ||
} | ||
|
||
private JavaBuildPlugin springBootPluginManagement() { | ||
return JavaBuildPlugin | ||
.builder() | ||
.groupId(SRPING_BOOT_GROUP) | ||
.artifactId("spring-boot-maven-plugin") | ||
.versionSlug("spring-boot") | ||
.additionalElements( | ||
""" | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>${start-class}</mainClass> | ||
</configuration> | ||
""" | ||
) | ||
.build(); | ||
} | ||
|
||
private JavaBuildPlugin springBootMavenPlugin() { | ||
return JavaBuildPlugin.builder().groupId(SRPING_BOOT_GROUP).artifactId("spring-boot-maven-plugin").build(); | ||
} | ||
} |
Oops, something went wrong.