Skip to content

Commit 29dc236

Browse files
committed
Broaden deprecation warning check in Gradle Plugin's tests
Closes gh-21111
1 parent 581ce09 commit 29dc236

File tree

1 file changed

+9
-6
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit

1 file changed

+9
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -81,7 +81,7 @@ void before() throws IOException {
8181
}
8282

8383
void after() {
84-
GradleBuild.this.script = null;
84+
this.script = null;
8585
FileSystemUtils.deleteRecursively(this.projectDir);
8686
}
8787

@@ -113,8 +113,8 @@ public GradleBuild expectDeprecationWarningsWithAtLeastVersion(String gradleVers
113113
public BuildResult build(String... arguments) {
114114
try {
115115
BuildResult result = prepareRunner(arguments).build();
116-
if (this.gradleVersion != null && this.expectDeprecationWarnings != null
117-
&& this.expectDeprecationWarnings.compareTo(GradleVersion.version(this.gradleVersion)) > 0) {
116+
if (this.expectDeprecationWarnings == null || (this.gradleVersion != null
117+
&& this.expectDeprecationWarnings.compareTo(GradleVersion.version(this.gradleVersion)) > 0)) {
118118
assertThat(result.getOutput()).doesNotContain("Deprecated").doesNotContain("deprecated");
119119
}
120120
return result;
@@ -149,13 +149,16 @@ public GradleRunner prepareRunner(String... arguments) throws IOException {
149149
if (this.gradleVersion != null) {
150150
gradleRunner.withGradleVersion(this.gradleVersion);
151151
}
152-
else if (this.dsl == Dsl.KOTLIN) {
153-
gradleRunner.withGradleVersion("4.10.3");
152+
else {
153+
File settingsFile = new File(this.projectDir, "settings" + this.dsl.getExtension());
154+
FileCopyUtils.copy("enableFeaturePreview(\"STABLE_PUBLISHING\")", new FileWriter(settingsFile));
154155
}
155156
List<String> allArguments = new ArrayList<>();
156157
allArguments.add("-PbootVersion=" + getBootVersion());
157158
allArguments.add("--stacktrace");
158159
allArguments.addAll(Arrays.asList(arguments));
160+
allArguments.add("--warning-mode");
161+
allArguments.add("all");
159162
return gradleRunner.withArguments(allArguments);
160163
}
161164

0 commit comments

Comments
 (0)