Allow spring-boot-image-tests to run without an existing snapshot
Closes gh-28817
This commit is contained in:
parent
cd4d08d8c0
commit
4bd86a6e20
|
@ -186,16 +186,11 @@ public class GradleBuild {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradleRunner prepareRunner(String... arguments) throws IOException {
|
public GradleRunner prepareRunner(String... arguments) throws IOException {
|
||||||
String scriptContent = FileCopyUtils.copyToString(new FileReader(this.script));
|
|
||||||
this.scriptProperties.put("bootVersion", getBootVersion());
|
this.scriptProperties.put("bootVersion", getBootVersion());
|
||||||
this.scriptProperties.put("dependencyManagementPluginVersion", getDependencyManagementPluginVersion());
|
this.scriptProperties.put("dependencyManagementPluginVersion", getDependencyManagementPluginVersion());
|
||||||
for (Entry<String, String> property : this.scriptProperties.entrySet()) {
|
copyTransformedScript(this.script, new File(this.projectDir, "build" + this.dsl.getExtension()));
|
||||||
scriptContent = scriptContent.replace("{" + property.getKey() + "}", property.getValue());
|
|
||||||
}
|
|
||||||
FileCopyUtils.copy(scriptContent, new FileWriter(new File(this.projectDir, "build" + this.dsl.getExtension())));
|
|
||||||
if (this.settings != null) {
|
if (this.settings != null) {
|
||||||
FileCopyUtils.copy(new FileReader(this.settings),
|
copyTransformedScript(this.settings, new File(this.projectDir, "settings.gradle"));
|
||||||
new FileWriter(new File(this.projectDir, "settings.gradle")));
|
|
||||||
}
|
}
|
||||||
File repository = new File("src/test/resources/repository");
|
File repository = new File("src/test/resources/repository");
|
||||||
if (repository.exists()) {
|
if (repository.exists()) {
|
||||||
|
@ -223,6 +218,14 @@ public class GradleBuild {
|
||||||
return gradleRunner.withArguments(allArguments);
|
return gradleRunner.withArguments(allArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyTransformedScript(String script, File destination) throws IOException {
|
||||||
|
String scriptContent = FileCopyUtils.copyToString(new FileReader(script));
|
||||||
|
for (Entry<String, String> property : this.scriptProperties.entrySet()) {
|
||||||
|
scriptContent = scriptContent.replace("{" + property.getKey() + "}", property.getValue());
|
||||||
|
}
|
||||||
|
FileCopyUtils.copy(scriptContent, new FileWriter(destination));
|
||||||
|
}
|
||||||
|
|
||||||
private File getTestKitDir() {
|
private File getTestKitDir() {
|
||||||
File temp = new File(System.getProperty("java.io.tmpdir"));
|
File temp = new File(System.getProperty("java.io.tmpdir"));
|
||||||
String username = System.getProperty("user.name");
|
String username = System.getProperty("user.name");
|
||||||
|
|
|
@ -7,12 +7,19 @@ plugins {
|
||||||
description = "Spring Boot Image Building Tests"
|
description = "Spring Boot Image Building Tests"
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
app
|
||||||
providedRuntime {
|
providedRuntime {
|
||||||
extendsFrom dependencyManagement
|
extendsFrom dependencyManagement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task syncMavenRepository(type: Sync) {
|
||||||
|
from configurations.app
|
||||||
|
into "${buildDir}/system-test-maven-repository"
|
||||||
|
}
|
||||||
|
|
||||||
systemTest {
|
systemTest {
|
||||||
|
dependsOn syncMavenRepository
|
||||||
if (project.hasProperty("springBootVersion")) {
|
if (project.hasProperty("springBootVersion")) {
|
||||||
systemProperty "springBootVersion", project.properties["springBootVersion"]
|
systemProperty "springBootVersion", project.properties["springBootVersion"]
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,11 +28,15 @@ systemTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
app project(path: ":spring-boot-project:spring-boot-tools:spring-boot-gradle-plugin", configuration: "mavenRepository")
|
||||||
|
app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-web", configuration: "mavenRepository")
|
||||||
|
|
||||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) {
|
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) {
|
||||||
exclude group: "org.hibernate.validator"
|
exclude group: "org.hibernate.validator"
|
||||||
}
|
}
|
||||||
|
|
||||||
systemTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
systemTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||||
|
systemTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-gradle-plugin"))
|
||||||
systemTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-gradle-test-support"))
|
systemTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-gradle-test-support"))
|
||||||
systemTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-buildpack-platform"))
|
systemTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-buildpack-platform"))
|
||||||
systemTestImplementation(gradleTestKit())
|
systemTestImplementation(gradleTestKit())
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.github.dockerjava.api.model.ContainerConfig;
|
||||||
import org.assertj.core.api.Condition;
|
import org.assertj.core.api.Condition;
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
import org.gradle.testkit.runner.BuildResult;
|
||||||
import org.gradle.testkit.runner.TaskOutcome;
|
import org.gradle.testkit.runner.TaskOutcome;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
@ -61,6 +62,12 @@ class PaketoBuilderTests {
|
||||||
|
|
||||||
GradleBuild gradleBuild;
|
GradleBuild gradleBuild;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void configureGradleBuild() {
|
||||||
|
this.gradleBuild.scriptProperty("systemTestMavenRepository",
|
||||||
|
new File("build/system-test-maven-repository").getAbsoluteFile().toURI().toASCIIString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void executableJarApp() throws Exception {
|
void executableJarApp() throws Exception {
|
||||||
writeMainClass();
|
writeMainClass();
|
||||||
|
|
|
@ -6,6 +6,14 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
|
|
|
@ -6,6 +6,14 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
|
|
|
@ -6,6 +6,14 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
|
|
|
@ -6,6 +6,14 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
|
|
|
@ -5,6 +5,14 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven { url '{systemTestMavenRepository}' }
|
||||||
|
}
|
||||||
|
filter {
|
||||||
|
includeGroup "org.springframework.boot"
|
||||||
|
}
|
||||||
|
}
|
||||||
maven { url 'https://repo.spring.io/milestone' }
|
maven { url 'https://repo.spring.io/milestone' }
|
||||||
maven { url 'https://repo.spring.io/snapshot' }
|
maven { url 'https://repo.spring.io/snapshot' }
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.id == "org.springframework.boot") {
|
||||||
|
useModule "org.springframework.boot:spring-boot-gradle-plugin:${requested.version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue