Broaden deprecation warning check in Gradle Plugin's tests

Closes gh-21111
This commit is contained in:
Andy Wilkinson 2020-04-24 17:15:45 +01:00
parent 581ce09f88
commit 29dc236bb2
1 changed files with 9 additions and 6 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.
@ -81,7 +81,7 @@ public class GradleBuild {
}
void after() {
GradleBuild.this.script = null;
this.script = null;
FileSystemUtils.deleteRecursively(this.projectDir);
}
@ -113,8 +113,8 @@ public class GradleBuild {
public BuildResult build(String... arguments) {
try {
BuildResult result = prepareRunner(arguments).build();
if (this.gradleVersion != null && this.expectDeprecationWarnings != null
&& this.expectDeprecationWarnings.compareTo(GradleVersion.version(this.gradleVersion)) > 0) {
if (this.expectDeprecationWarnings == null || (this.gradleVersion != null
&& this.expectDeprecationWarnings.compareTo(GradleVersion.version(this.gradleVersion)) > 0)) {
assertThat(result.getOutput()).doesNotContain("Deprecated").doesNotContain("deprecated");
}
return result;
@ -149,13 +149,16 @@ public class GradleBuild {
if (this.gradleVersion != null) {
gradleRunner.withGradleVersion(this.gradleVersion);
}
else if (this.dsl == Dsl.KOTLIN) {
gradleRunner.withGradleVersion("4.10.3");
else {
File settingsFile = new File(this.projectDir, "settings" + this.dsl.getExtension());
FileCopyUtils.copy("enableFeaturePreview(\"STABLE_PUBLISHING\")", new FileWriter(settingsFile));
}
List<String> allArguments = new ArrayList<>();
allArguments.add("-PbootVersion=" + getBootVersion());
allArguments.add("--stacktrace");
allArguments.addAll(Arrays.asList(arguments));
allArguments.add("--warning-mode");
allArguments.add("all");
return gradleRunner.withArguments(allArguments);
}