mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-20 02:29:44 +08:00
Simplify project generation version checks
This commit simplifies project generation by only checking for supported Spring Boot version (i.e. 1.5 and later) and therefore removing any logic that is specified to a non supported version. Concretely, initializr is no longer able to generate a project for a Spring Boot version prior to 1.5 Closes gh-763
This commit is contained in:
@@ -64,21 +64,7 @@ public class ProjectGenerator {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ProjectGenerator.class);
|
private static final Logger log = LoggerFactory.getLogger(ProjectGenerator.class);
|
||||||
|
|
||||||
private static final Version VERSION_1_2_0_RC1 = Version.parse("1.2.0.RC1");
|
private static final Version VERSION_2_0_0 = Version.parse("2.0.0.RELEASE");
|
||||||
|
|
||||||
private static final Version VERSION_1_3_0_M1 = Version.parse("1.3.0.M1");
|
|
||||||
|
|
||||||
private static final Version VERSION_1_4_0_M2 = Version.parse("1.4.0.M2");
|
|
||||||
|
|
||||||
private static final Version VERSION_1_4_0_M3 = Version.parse("1.4.0.M3");
|
|
||||||
|
|
||||||
private static final Version VERSION_1_4_2_M1 = Version.parse("1.4.2.M1");
|
|
||||||
|
|
||||||
private static final Version VERSION_2_0_0_M1 = Version.parse("2.0.0.M1");
|
|
||||||
|
|
||||||
private static final Version VERSION_2_0_0_M3 = Version.parse("2.0.0.M3");
|
|
||||||
|
|
||||||
private static final Version VERSION_2_0_0_M6 = Version.parse("2.0.0.M6");
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
@@ -365,8 +351,8 @@ public class ProjectGenerator {
|
|||||||
model.put("war", true);
|
model.put("war", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kotlin supported as of M6
|
// Kotlin supported as of 2.0
|
||||||
final boolean kotlinSupport = VERSION_2_0_0_M6.compareTo(bootVersion) <= 0;
|
final boolean kotlinSupport = VERSION_2_0_0.compareTo(bootVersion) <= 0;
|
||||||
model.put("kotlinSupport", kotlinSupport);
|
model.put("kotlinSupport", kotlinSupport);
|
||||||
|
|
||||||
if (isMavenBuild(request)) {
|
if (isMavenBuild(request)) {
|
||||||
@@ -443,25 +429,15 @@ public class ProjectGenerator {
|
|||||||
model.put("isRelease", request.getBootVersion().contains("RELEASE"));
|
model.put("isRelease", request.getBootVersion().contains("RELEASE"));
|
||||||
setupApplicationModel(request, model);
|
setupApplicationModel(request, model);
|
||||||
|
|
||||||
// Gradle plugin has changed as from 1.3.0
|
final boolean bootTwoZeroAvailable = VERSION_2_0_0.compareTo(bootVersion) <= 0;
|
||||||
model.put("bootOneThreeAvailable", VERSION_1_3_0_M1.compareTo(bootVersion) <= 0);
|
|
||||||
|
|
||||||
final boolean bootTwoZeroAvailable = VERSION_2_0_0_M1.compareTo(bootVersion) <= 0;
|
|
||||||
model.put("bootTwoZeroAvailable", bootTwoZeroAvailable);
|
model.put("bootTwoZeroAvailable", bootTwoZeroAvailable);
|
||||||
|
|
||||||
// Gradle plugin has changed again as from 1.4.2
|
|
||||||
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0)
|
|
||||||
? "org.springframework.boot" : "spring-boot");
|
|
||||||
|
|
||||||
// New testing stuff
|
|
||||||
model.put("newTestInfrastructure", isNewTestInfrastructureAvailable(request));
|
|
||||||
|
|
||||||
// Servlet Initializer
|
// Servlet Initializer
|
||||||
model.put("servletInitializrImport", new Imports(request.getLanguage())
|
model.put("servletInitializrImport", new Imports(request.getLanguage())
|
||||||
.add(getServletInitializrClass(request)).toString());
|
.add(getServletInitializrClass(request)).toString());
|
||||||
|
|
||||||
// Kotlin-specific dep
|
// Kotlin-specific dep
|
||||||
model.put("kotlinStdlibArtifactId", getKotlinStdlibArtifactId(request));
|
model.put("kotlinStdlibArtifactId", "kotlin-stdlib-jdk8");
|
||||||
|
|
||||||
// Java versions
|
// Java versions
|
||||||
model.put("java8OrLater", isJava8OrLater(request));
|
model.put("java8OrLater", isJava8OrLater(request));
|
||||||
@@ -513,19 +489,8 @@ public class ProjectGenerator {
|
|||||||
Map<String, Object> model) {
|
Map<String, Object> model) {
|
||||||
Imports imports = new Imports(request.getLanguage());
|
Imports imports = new Imports(request.getLanguage());
|
||||||
Annotations annotations = new Annotations();
|
Annotations annotations = new Annotations();
|
||||||
boolean useSpringBootApplication = VERSION_1_2_0_RC1
|
|
||||||
.compareTo(Version.safeParse(request.getBootVersion())) <= 0;
|
|
||||||
if (useSpringBootApplication) {
|
|
||||||
imports.add("org.springframework.boot.autoconfigure.SpringBootApplication");
|
imports.add("org.springframework.boot.autoconfigure.SpringBootApplication");
|
||||||
annotations.add("@SpringBootApplication");
|
annotations.add("@SpringBootApplication");
|
||||||
}
|
|
||||||
else {
|
|
||||||
imports.add("org.springframework.boot.autoconfigure.EnableAutoConfiguration")
|
|
||||||
.add("org.springframework.context.annotation.ComponentScan")
|
|
||||||
.add("org.springframework.context.annotation.Configuration");
|
|
||||||
annotations.add("@EnableAutoConfiguration").add("@ComponentScan")
|
|
||||||
.add("@Configuration");
|
|
||||||
}
|
|
||||||
model.put("applicationImports", imports.toString());
|
model.put("applicationImports", imports.toString());
|
||||||
model.put("applicationAnnotations", annotations.toString());
|
model.put("applicationAnnotations", annotations.toString());
|
||||||
|
|
||||||
@@ -534,19 +499,8 @@ public class ProjectGenerator {
|
|||||||
protected void setupTestModel(ProjectRequest request, Map<String, Object> model) {
|
protected void setupTestModel(ProjectRequest request, Map<String, Object> model) {
|
||||||
Imports imports = new Imports(request.getLanguage());
|
Imports imports = new Imports(request.getLanguage());
|
||||||
Annotations testAnnotations = new Annotations();
|
Annotations testAnnotations = new Annotations();
|
||||||
boolean newTestInfrastructure = isNewTestInfrastructureAvailable(request);
|
|
||||||
if (newTestInfrastructure) {
|
|
||||||
imports.add("org.springframework.boot.test.context.SpringBootTest")
|
imports.add("org.springframework.boot.test.context.SpringBootTest")
|
||||||
.add("org.springframework.test.context.junit4.SpringRunner");
|
.add("org.springframework.test.context.junit4.SpringRunner");
|
||||||
}
|
|
||||||
else {
|
|
||||||
imports.add("org.springframework.boot.test.SpringApplicationConfiguration")
|
|
||||||
.add("org.springframework.test.context.junit4.SpringJUnit4ClassRunner");
|
|
||||||
}
|
|
||||||
if (request.hasWebFacet() && !newTestInfrastructure) {
|
|
||||||
imports.add("org.springframework.test.context.web.WebAppConfiguration");
|
|
||||||
testAnnotations.add("@WebAppConfiguration");
|
|
||||||
}
|
|
||||||
model.put("testImports", imports.withFinalCarriageReturn().toString());
|
model.put("testImports", imports.withFinalCarriageReturn().toString());
|
||||||
model.put("testAnnotations",
|
model.put("testAnnotations",
|
||||||
testAnnotations.withFinalCarriageReturn().toString());
|
testAnnotations.withFinalCarriageReturn().toString());
|
||||||
@@ -554,27 +508,11 @@ public class ProjectGenerator {
|
|||||||
|
|
||||||
protected String getServletInitializrClass(ProjectRequest request) {
|
protected String getServletInitializrClass(ProjectRequest request) {
|
||||||
Version bootVersion = Version.safeParse(request.getBootVersion());
|
Version bootVersion = Version.safeParse(request.getBootVersion());
|
||||||
if (VERSION_1_4_0_M3.compareTo(bootVersion) > 0) {
|
if (VERSION_2_0_0.compareTo(bootVersion) > 0) {
|
||||||
return "org.springframework.boot.context.web.SpringBootServletInitializer";
|
|
||||||
}
|
|
||||||
else if (VERSION_2_0_0_M1.compareTo(bootVersion) > 0) {
|
|
||||||
return "org.springframework.boot.web.support.SpringBootServletInitializer";
|
return "org.springframework.boot.web.support.SpringBootServletInitializer";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return "org.springframework.boot.web.servlet.support.SpringBootServletInitializer";
|
return "org.springframework.boot.web.servlet.support.SpringBootServletInitializer";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected String getKotlinStdlibArtifactId(ProjectRequest request) {
|
|
||||||
String javaVersion = request.getJavaVersion();
|
|
||||||
if ("1.6".equals(javaVersion)) {
|
|
||||||
return "kotlin-stdlib";
|
|
||||||
}
|
|
||||||
else if ("1.7".equals(javaVersion)) {
|
|
||||||
return "kotlin-stdlib-jdk7";
|
|
||||||
}
|
|
||||||
return "kotlin-stdlib-jdk8";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isJava8OrLater(ProjectRequest request) {
|
private static boolean isJava8OrLater(ProjectRequest request) {
|
||||||
return !request.getJavaVersion().equals("1.6")
|
return !request.getJavaVersion().equals("1.6")
|
||||||
@@ -593,13 +531,8 @@ public class ProjectGenerator {
|
|||||||
return "war".equals(request.getPackaging());
|
return "war".equals(request.getPackaging());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isNewTestInfrastructureAvailable(ProjectRequest request) {
|
|
||||||
return VERSION_1_4_0_M2
|
|
||||||
.compareTo(Version.safeParse(request.getBootVersion())) <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isGradle4Available(Version bootVersion) {
|
private static boolean isGradle4Available(Version bootVersion) {
|
||||||
return VERSION_2_0_0_M3.compareTo(bootVersion) < 0;
|
return VERSION_2_0_0.compareTo(bootVersion) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] doGenerateMavenPom(Map<String, Object> model) {
|
private byte[] doGenerateMavenPom(Map<String, Object> model) {
|
||||||
|
@@ -3,14 +3,8 @@ package {{packageName}}
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
{{testImports}}
|
{{testImports}}
|
||||||
{{#newTestInfrastructure}}
|
|
||||||
@RunWith(SpringRunner)
|
@RunWith(SpringRunner)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{^newTestInfrastructure}}
|
|
||||||
@RunWith(SpringJUnit4ClassRunner)
|
|
||||||
@SpringApplicationConfiguration(classes = {{applicationName}})
|
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{testAnnotations}}class {{applicationName}}Tests {
|
{{testAnnotations}}class {{applicationName}}Tests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -3,14 +3,8 @@ package {{packageName}};
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
{{testImports}}
|
{{testImports}}
|
||||||
{{#newTestInfrastructure}}
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{^newTestInfrastructure}}
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringApplicationConfiguration(classes = {{applicationName}}.class)
|
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{testAnnotations}}public class {{applicationName}}Tests {
|
{{testAnnotations}}public class {{applicationName}}Tests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -3,14 +3,8 @@ package {{packageName}}
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
{{testImports}}
|
{{testImports}}
|
||||||
{{#newTestInfrastructure}}
|
|
||||||
@RunWith(SpringRunner::class)
|
@RunWith(SpringRunner::class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{^newTestInfrastructure}}
|
|
||||||
@RunWith(SpringJUnit4ClassRunner::class)
|
|
||||||
@SpringApplicationConfiguration(classes = arrayOf({{applicationName}}::class))
|
|
||||||
{{/newTestInfrastructure}}
|
|
||||||
{{testAnnotations}}class {{applicationName}}Tests {
|
{{testAnnotations}}class {{applicationName}}Tests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -13,9 +13,6 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
|
||||||
{{^bootOneThreeAvailable}}
|
|
||||||
classpath('io.spring.gradle:dependency-management-plugin:{{dependencyManagementPluginVersion}}')
|
|
||||||
{{/bootOneThreeAvailable}}
|
|
||||||
{{#kotlin}}
|
{{#kotlin}}
|
||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
|
||||||
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
|
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
|
||||||
@@ -39,10 +36,7 @@ apply plugin: 'eclipse-wtp'
|
|||||||
{{^war}}
|
{{^war}}
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
{{/war}}
|
{{/war}}
|
||||||
apply plugin: '{{springBootPluginName}}'
|
apply plugin: 'org.springframework.boot'
|
||||||
{{^bootOneThreeAvailable}}
|
|
||||||
apply plugin: 'io.spring.dependency-management'
|
|
||||||
{{/bootOneThreeAvailable}}
|
|
||||||
{{#bootTwoZeroAvailable}}
|
{{#bootTwoZeroAvailable}}
|
||||||
apply plugin: 'io.spring.dependency-management'
|
apply plugin: 'io.spring.dependency-management'
|
||||||
{{/bootTwoZeroAvailable}}
|
{{/bootTwoZeroAvailable}}
|
||||||
|
@@ -28,10 +28,7 @@ import org.junit.Rule;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@@ -98,9 +95,9 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
@Test
|
@Test
|
||||||
public void mavenPomWithBootSnapshot() {
|
public void mavenPomWithBootSnapshot() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setBootVersion("1.0.1.BUILD-SNAPSHOT");
|
request.setBootVersion("2.1.1.BUILD-SNAPSHOT");
|
||||||
generateMavenPom(request).hasSnapshotRepository()
|
generateMavenPom(request).hasSnapshotRepository()
|
||||||
.hasSpringBootParent("1.0.1.BUILD-SNAPSHOT")
|
.hasSpringBootParent("2.1.1.BUILD-SNAPSHOT")
|
||||||
.hasSpringBootStarterDependency("web");
|
.hasSpringBootStarterDependency("web");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,92 +281,33 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
verifyProjectSuccessfulEventFor(request);
|
verifyProjectSuccessfulEventFor(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springBoot11UseEnableAutoConfigurationJava() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setBootVersion("1.1.9.RELEASE");
|
|
||||||
request.setName("MyDemo");
|
|
||||||
request.setPackageName("foo");
|
|
||||||
generateProject(request)
|
|
||||||
.sourceCodeAssert("src/main/java/foo/MyDemoApplication.java")
|
|
||||||
.hasImports(EnableAutoConfiguration.class.getName(),
|
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.doesNotHaveImports(SpringBootApplication.class.getName())
|
|
||||||
.contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
|
|
||||||
.doesNotContain("@SpringBootApplication");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void springBootUseSpringBootApplicationJava() {
|
public void springBootUseSpringBootApplicationJava() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setBootVersion("1.2.0.RC1");
|
|
||||||
request.setName("MyDemo");
|
request.setName("MyDemo");
|
||||||
request.setPackageName("foo");
|
request.setPackageName("foo");
|
||||||
generateProject(request)
|
generateProject(request)
|
||||||
.sourceCodeAssert("src/main/java/foo/MyDemoApplication.java")
|
.sourceCodeAssert("src/main/java/foo/MyDemoApplication.java")
|
||||||
.hasImports(SpringBootApplication.class.getName())
|
.hasImports(SpringBootApplication.class.getName())
|
||||||
.doesNotHaveImports(EnableAutoConfiguration.class.getName(),
|
.contains("@SpringBootApplication");
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.contains("@SpringBootApplication").doesNotContain(
|
|
||||||
"@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springBoot11UseEnableAutoConfigurationGroovy() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setLanguage("groovy");
|
|
||||||
request.setBootVersion("1.1.9.RELEASE");
|
|
||||||
request.setName("MyDemo");
|
|
||||||
request.setPackageName("foo");
|
|
||||||
generateProject(request)
|
|
||||||
.sourceCodeAssert("src/main/groovy/foo/MyDemoApplication.groovy")
|
|
||||||
.hasImports(EnableAutoConfiguration.class.getName(),
|
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.doesNotHaveImports(SpringBootApplication.class.getName())
|
|
||||||
.contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
|
|
||||||
.doesNotContain("@SpringBootApplication");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void springBootUseSpringBootApplicationGroovy() {
|
public void springBootUseSpringBootApplicationGroovy() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setLanguage("groovy");
|
request.setLanguage("groovy");
|
||||||
request.setBootVersion("1.2.0.RC1");
|
|
||||||
request.setName("MyDemo");
|
request.setName("MyDemo");
|
||||||
request.setPackageName("foo");
|
request.setPackageName("foo");
|
||||||
generateProject(request)
|
generateProject(request)
|
||||||
.sourceCodeAssert("src/main/groovy/foo/MyDemoApplication.groovy")
|
.sourceCodeAssert("src/main/groovy/foo/MyDemoApplication.groovy")
|
||||||
.hasImports(SpringBootApplication.class.getName())
|
.hasImports(SpringBootApplication.class.getName())
|
||||||
.doesNotHaveImports(EnableAutoConfiguration.class.getName(),
|
.contains("@SpringBootApplication");
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.contains("@SpringBootApplication").doesNotContain(
|
|
||||||
"@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springBoot11UseEnableAutoConfigurationKotlin() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setLanguage("kotlin");
|
|
||||||
request.setBootVersion("1.1.9.RELEASE");
|
|
||||||
request.setName("MyDemo");
|
|
||||||
request.setPackageName("foo");
|
|
||||||
|
|
||||||
applyMetadata(initializeTestMetadataBuilder().addDependencyGroup("core", "web")
|
|
||||||
.setKotlinEnv("1.0.0").build());
|
|
||||||
generateProject(request)
|
|
||||||
.sourceCodeAssert("src/main/kotlin/foo/MyDemoApplication.kt")
|
|
||||||
.hasImports(EnableAutoConfiguration.class.getName(),
|
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.doesNotHaveImports(SpringBootApplication.class.getName())
|
|
||||||
.contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
|
|
||||||
.doesNotContain("@SpringBootApplication");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void springBootUseSpringBootApplicationKotlin() {
|
public void springBootUseSpringBootApplicationKotlin() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setLanguage("kotlin");
|
request.setLanguage("kotlin");
|
||||||
request.setBootVersion("1.2.0.RC1");
|
|
||||||
request.setName("MyDemo");
|
request.setName("MyDemo");
|
||||||
request.setPackageName("foo");
|
request.setPackageName("foo");
|
||||||
|
|
||||||
@@ -378,10 +316,7 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
generateProject(request)
|
generateProject(request)
|
||||||
.sourceCodeAssert("src/main/kotlin/foo/MyDemoApplication.kt")
|
.sourceCodeAssert("src/main/kotlin/foo/MyDemoApplication.kt")
|
||||||
.hasImports(SpringBootApplication.class.getName())
|
.hasImports(SpringBootApplication.class.getName())
|
||||||
.doesNotHaveImports(EnableAutoConfiguration.class.getName(),
|
.contains("@SpringBootApplication");
|
||||||
ComponentScan.class.getName(), Configuration.class.getName())
|
|
||||||
.contains("@SpringBootApplication").doesNotContain(
|
|
||||||
"@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -393,26 +328,10 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void springBoot20M3UseGradle3() {
|
public void springBoot20UsesGradle4() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setType("gradle-project");
|
request.setType("gradle-project");
|
||||||
request.setBootVersion("2.0.0.M3");
|
request.setBootVersion("2.0.0.RELEASE");
|
||||||
generateProject(request).isGradleProject("3.5.1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springBoot20M4UsesGradle4() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setType("gradle-project");
|
|
||||||
request.setBootVersion("2.0.0.M4");
|
|
||||||
generateProject(request).isGradleProject("4.10.2");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springBoot20SnapshotsUseGradle4() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setType("gradle-project");
|
|
||||||
request.setBootVersion("2.0.0.BUILD-SNAPSHOT");
|
|
||||||
generateProject(request).isGradleProject("4.10.2");
|
generateProject(request).isGradleProject("4.10.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +430,7 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
@Test
|
@Test
|
||||||
public void gradleBuildWithBootSnapshot() {
|
public void gradleBuildWithBootSnapshot() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setBootVersion("1.0.1.BUILD-SNAPSHOT");
|
request.setBootVersion("2.1.1.BUILD-SNAPSHOT");
|
||||||
generateGradleBuild(request).hasSnapshotRepository();
|
generateGradleBuild(request).hasSnapshotRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,50 +501,11 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gradleBuildBeforeWithSpringBoot13() {
|
public void gradleBuildWithSpringBoot15() {
|
||||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
|
|
||||||
.addDependencyGroup("core", "web", "jpa").setGradleEnv("0.5.9.RELEASE")
|
|
||||||
.build();
|
|
||||||
applyMetadata(metadata);
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setBootVersion("1.2.3.RELEASE");
|
request.setBootVersion("1.5.20.BUILD-SNAPSHOT");
|
||||||
generateGradleBuild(request).contains("springBootVersion = '1.2.3.RELEASE'")
|
|
||||||
.contains(
|
|
||||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
|
||||||
.contains("apply plugin: 'spring-boot'")
|
|
||||||
.contains("apply plugin: 'io.spring.dependency-management'")
|
|
||||||
.contains(
|
|
||||||
"implementation('org.springframework.boot:spring-boot-starter-web')")
|
|
||||||
.contains(
|
|
||||||
"testImplementation('org.springframework.boot:spring-boot-starter-test')");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void gradleBuildAsFromSpringBoot13() {
|
|
||||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
|
|
||||||
.addDependencyGroup("core", "web", "jpa").setGradleEnv("0.5.9.RELEASE")
|
|
||||||
.build();
|
|
||||||
applyMetadata(metadata);
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setBootVersion("1.3.0.BUILD-SNAPSHOT");
|
|
||||||
generateGradleBuild(request)
|
generateGradleBuild(request)
|
||||||
.contains("springBootVersion = '1.3.0.BUILD-SNAPSHOT'")
|
.contains("springBootVersion = '1.5.20.BUILD-SNAPSHOT'")
|
||||||
.contains("apply plugin: 'spring-boot'")
|
|
||||||
.contains(
|
|
||||||
"implementation('org.springframework.boot:spring-boot-starter-web')")
|
|
||||||
.contains(
|
|
||||||
"testImplementation('org.springframework.boot:spring-boot-starter-test')")
|
|
||||||
.doesNotContain(
|
|
||||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
|
||||||
.doesNotContain("apply plugin: 'io.spring.dependency-management'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void gradleBuildAsFromSpringBoot142() {
|
|
||||||
ProjectRequest request = createProjectRequest("web");
|
|
||||||
request.setBootVersion("1.4.2.BUILD-SNAPSHOT");
|
|
||||||
generateGradleBuild(request)
|
|
||||||
.contains("springBootVersion = '1.4.2.BUILD-SNAPSHOT'")
|
|
||||||
.contains("apply plugin: 'org.springframework.boot'")
|
.contains("apply plugin: 'org.springframework.boot'")
|
||||||
.contains(
|
.contains(
|
||||||
"implementation('org.springframework.boot:spring-boot-starter-web')")
|
"implementation('org.springframework.boot:spring-boot-starter-web')")
|
||||||
@@ -635,11 +515,10 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gradleBuildAsFromSpringBoot20() {
|
public void gradleBuildWithSpringBoot20() {
|
||||||
ProjectRequest request = createProjectRequest("web");
|
ProjectRequest request = createProjectRequest("web");
|
||||||
request.setBootVersion("2.0.0.BUILD-SNAPSHOT");
|
request.setBootVersion("2.0.0.RELEASE");
|
||||||
generateGradleBuild(request)
|
generateGradleBuild(request).contains("springBootVersion = '2.0.0.RELEASE'")
|
||||||
.contains("springBootVersion = '2.0.0.BUILD-SNAPSHOT'")
|
|
||||||
.contains("apply plugin: 'org.springframework.boot'")
|
.contains("apply plugin: 'org.springframework.boot'")
|
||||||
.doesNotContain("apply plugin: 'spring-boot'")
|
.doesNotContain("apply plugin: 'spring-boot'")
|
||||||
.contains("apply plugin: 'io.spring.dependency-management'")
|
.contains("apply plugin: 'io.spring.dependency-management'")
|
||||||
|
Reference in New Issue
Block a user