Remove redundant junit-vintage-engine exclusion with Boot 2.4

Spring Boot 2.4 has switched from providing JUnit 5 in the test starter
(JUnit Jupiter and the JUnit Vintage Engine) to only providing JUnit
Jupiter. As such, the exclusion of junit-vintage-engine is no longer
required for projects that are using Spring Boot 2.4.

Closes gh-1095
This commit is contained in:
Andy Wilkinson
2020-06-05 15:25:26 +01:00
parent cf45c6313e
commit ca4bd57139
3 changed files with 49 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class BuildProjectGenerationConfiguration {
@Bean
@ConditionalOnPlatformVersion("[2.2.0.M3,2.2.0.M4]")
@Deprecated
public BuildCustomizer<Build> junitJupiterLegacyTestStarterContributor() {
public BuildCustomizer<Build> junit5LegacyTestStarterContributor() {
return (build) -> build.dependencies().add("test",
Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter-test")
.scope(DependencyScope.TEST_COMPILE)
@@ -58,14 +58,22 @@ public class BuildProjectGenerationConfiguration {
}
@Bean
@ConditionalOnPlatformVersion("2.2.0.M5")
public BuildCustomizer<Build> junitJupiterTestStarterContributor() {
@ConditionalOnPlatformVersion("[2.2.0.M5,2.4.0-SNAPSHOT)")
public BuildCustomizer<Build> junit5TestStarterContributor() {
return (build) -> build.dependencies().add("test",
Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter-test")
.scope(DependencyScope.TEST_COMPILE)
.exclusions(new Exclusion("org.junit.vintage", "junit-vintage-engine")));
}
@Bean
@ConditionalOnPlatformVersion("2.4.0-M1")
public BuildCustomizer<Build> junitJupiterTestStarterContributor() {
return (build) -> build.dependencies().add("test",
Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter-test")
.scope(DependencyScope.TEST_COMPILE));
}
@Bean
public DefaultStarterBuildCustomizer defaultStarterContributor(InitializrMetadata metadata) {
return new DefaultStarterBuildCustomizer(metadata);

View File

@@ -181,6 +181,24 @@ class GradleProjectGenerationConfigurationTests {
assertThat(project).textFile("build.gradle").doesNotContain("exclude group");
}
@Test
void testStarterDoesNotExcludeVintageEngineWith24Snapshot() {
MutableProjectDescription description = new MutableProjectDescription();
description.setPlatformVersion(Version.parse("2.4.0-SNAPSHOT"));
description.setLanguage(new JavaLanguage());
ProjectStructure project = this.projectTester.generate(description);
assertThat(project).textFile("build.gradle").doesNotContain("exclude group");
}
@Test
void testStarterDoesNotExcludeVintageEngineWith24Milestone() {
MutableProjectDescription description = new MutableProjectDescription();
description.setPlatformVersion(Version.parse("2.4.0-M1"));
description.setLanguage(new JavaLanguage());
ProjectStructure project = this.projectTester.generate(description);
assertThat(project).textFile("build.gradle").doesNotContain("exclude group");
}
static Stream<Arguments> annotationProcessorScopeBuildParameters() {
return Stream.of(Arguments.arguments("1.5.17.RELEASE", false), Arguments.arguments("2.0.6.RELEASE", true),
Arguments.arguments("2.1.3.RELEASE", true));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -125,4 +125,22 @@ class MavenProjectGenerationConfigurationTests {
assertThat(project).textFile("pom.xml").doesNotContain(" <exclusions>");
}
@Test
void testStarterDoesNotExcludeVintageEngineWith24Snapshot() {
MutableProjectDescription description = new MutableProjectDescription();
description.setPlatformVersion(Version.parse("2.4.0-SNAPSHOT"));
description.setLanguage(new JavaLanguage());
ProjectStructure project = this.projectTester.generate(description);
assertThat(project).textFile("pom.xml").doesNotContain(" <exclusions>");
}
@Test
void testStarterDoesNotExcludeVintageEngineWith24Milestone() {
MutableProjectDescription description = new MutableProjectDescription();
description.setPlatformVersion(Version.parse("2.4.0-M1"));
description.setLanguage(new JavaLanguage());
ProjectStructure project = this.projectTester.generate(description);
assertThat(project).textFile("pom.xml").doesNotContain(" <exclusions>");
}
}