Ensure Gradle tasks are configured lazily

At present, generated Gradle build scripts that use Groovy DSL configure
tasks eagerly. This is both suboptimal and actually not aligned with the
generated build scripts that use Kotlin DSL, which configures tasks
lazily.

This commit updates `GroovyDslGradleBuildWriter` to ensure tasks are
configured lazily.

See gh-1292
This commit is contained in:
Vedran Pavic
2021-12-30 12:59:19 +01:00
committed by Stephane Nicoll
parent 35e41a8f08
commit 27fc9d4067
17 changed files with 24 additions and 22 deletions

View File

@@ -129,7 +129,7 @@ class GradleProjectGenerationConfigurationTests {
" testImplementation 'org.springframework.boot:spring-boot-starter-test'",
"}",
"",
"test {",
"tasks.named('test') {",
" useJUnitPlatform()",
"}"); // @formatter:on
}
@@ -150,7 +150,8 @@ class GradleProjectGenerationConfigurationTests {
description.setPlatformVersion(Version.parse("2.2.4.RELEASE"));
description.setLanguage(new JavaLanguage());
ProjectStructure project = this.projectTester.generate(description);
assertThat(project).textFile("build.gradle").lines().containsSequence("test {", " useJUnitPlatform()", "}");
assertThat(project).textFile("build.gradle").lines().containsSequence("tasks.named('test') {",
" useJUnitPlatform()", "}");
}
@Test

View File

@@ -25,6 +25,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -25,6 +25,6 @@ dependencyManagement {
}
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -27,6 +27,6 @@ dependencyManagement {
}
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -19,6 +19,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -29,6 +29,6 @@ tasks.withType(KotlinCompile) {
}
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -20,6 +20,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -18,6 +18,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -22,6 +22,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -18,6 +18,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -20,6 +20,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -17,6 +17,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -19,6 +19,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -29,6 +29,6 @@ tasks.withType(KotlinCompile) {
}
}
test {
tasks.named('test') {
useJUnitPlatform()
}

View File

@@ -31,6 +31,6 @@ tasks.withType(KotlinCompile) {
}
}
test {
tasks.named('test') {
useJUnitPlatform()
}