Merge pull request #32643 from izeye
* pr/32643: Polish "Use NBT plugin version from gradle.properties in image tests" Use NBT plugin version from gradle.properties in image tests Closes gh-32643
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.testsupport.gradle.testkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -28,6 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
@@ -57,6 +59,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* A {@code GradleBuild} is used to run a Gradle build using {@link GradleRunner}.
|
||||
@@ -176,6 +179,11 @@ public class GradleBuild {
|
||||
return this;
|
||||
}
|
||||
|
||||
public GradleBuild scriptPropertyFrom(File propertiesFile, String key) {
|
||||
this.scriptProperties.put(key, getProperty(propertiesFile, key));
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildResult build(String... arguments) {
|
||||
try {
|
||||
BuildResult result = prepareRunner(arguments).build();
|
||||
@@ -291,4 +299,23 @@ public class GradleBuild {
|
||||
}
|
||||
}
|
||||
|
||||
private String getProperty(File propertiesFile, String key) {
|
||||
try {
|
||||
assertThat(propertiesFile).withFailMessage("Expecting properties file to exist at path '%s'",
|
||||
propertiesFile.getCanonicalFile()).exists();
|
||||
Properties properties = new Properties();
|
||||
try (FileInputStream input = new FileInputStream(propertiesFile)) {
|
||||
properties.load(input);
|
||||
String value = properties.getProperty(key);
|
||||
assertThat(value).withFailMessage("Expecting properties file '%s' to contain the key '%s'",
|
||||
propertiesFile.getCanonicalFile(), key).isNotEmpty();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
fail("Error reading properties file '" + propertiesFile + "'");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,9 +68,10 @@ class PaketoBuilderTests {
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@BeforeEach
|
||||
void configureGradleBuild() {
|
||||
void configureGradleBuild() throws IOException {
|
||||
this.gradleBuild.scriptProperty("systemTestMavenRepository",
|
||||
new File("build/system-test-maven-repository").getAbsoluteFile().toURI().toASCIIString());
|
||||
this.gradleBuild.scriptPropertyFrom(new File("../../gradle.properties"), "nativeBuildToolsVersion");
|
||||
this.gradleBuild.expectDeprecationMessages("BPL_SPRING_CLOUD_BINDINGS_ENABLED.*true.*Deprecated");
|
||||
this.gradleBuild.expectDeprecationMessages("BOM table is deprecated");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ plugins {
|
||||
id 'org.springframework.boot' version '{bootVersion}'
|
||||
id 'org.springframework.boot.aot' version '{bootVersion}'
|
||||
id 'io.spring.dependency-management' version '{dependencyManagementPluginVersion}'
|
||||
id 'org.graalvm.buildtools.native' version '0.9.14'
|
||||
id 'org.graalvm.buildtools.native' version '{nativeBuildToolsVersion}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user