Skip to content

Commit b0b3adb

Browse files
committed
Merge branch '3.1.x'
Closes spring-projectsgh-37741
2 parents 3321d15 + 2a35667 commit b0b3adb

File tree

10 files changed

+91
-76
lines changed

10 files changed

+91
-76
lines changed

buildSrc/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929
implementation("com.fasterxml.jackson.core:jackson-databind:2.11.4")
3030
implementation("com.gradle:gradle-enterprise-gradle-plugin:3.12.1")
3131
implementation("com.tngtech.archunit:archunit:1.0.0")
32+
implementation("de.undercouch.download:de.undercouch.download.gradle.plugin:5.5.0")
3233
implementation("commons-codec:commons-codec:1.13")
3334
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
3435
implementation("org.apache.maven:maven-embedder:3.6.3")

ci/tasks/build-project.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ outputs:
77
- name: git-repo
88
caches:
99
- path: gradle
10+
- path: build/downloads
1011
- path: embedmongo
1112
params:
1213
BRANCH:

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/build.gradle

+24
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ plugins {
22
id "java"
33
id "org.springframework.boot.conventions"
44
id "org.springframework.boot.integration-test"
5+
id "de.undercouch.download"
56
}
67

78
description = "Spring Boot Launch Script Integration Tests"
89

10+
def jdkVersion = "17.0.8.1+1"
11+
def jdkArch = "aarch64".equalsIgnoreCase(System.getProperty("os.arch")) ? "aarch64" : "amd64"
12+
913
configurations {
1014
app
1115
}
@@ -38,6 +42,26 @@ task buildApp(type: GradleBuild) {
3842
tasks = ["build"]
3943
}
4044

45+
task downloadJdk(type: Download) {
46+
def destFolder = new File(rootProject.buildDir, "downloads/jdk/bellsoft")
47+
destFolder.mkdirs()
48+
src "https://download.bell-sw.com/java/${jdkVersion}/bellsoft-jdk${jdkVersion}-linux-${jdkArch}.tar.gz"
49+
dest destFolder
50+
tempAndMove true
51+
overwrite false
52+
}
53+
54+
task syncJdkDownloads(type: Sync) {
55+
dependsOn downloadJdk
56+
from "${rootProject.buildDir}/downloads/jdk/bellsoft/"
57+
include "bellsoft-jdk${jdkVersion}-linux-${jdkArch}.tar.gz"
58+
into "${project.buildDir}/downloads/jdk/bellsoft/"
59+
}
60+
61+
processIntTestResources {
62+
dependsOn syncJdkDownloads
63+
}
64+
4165
intTest {
4266
dependsOn buildApp
4367
}

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/AbstractLaunchScriptIntegrationTests.java

+10-45
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
package org.springframework.boot.launchscript;
1818

1919
import java.io.File;
20-
import java.net.URI;
21-
import java.nio.file.Paths;
2220
import java.time.Duration;
2321
import java.util.ArrayList;
2422
import java.util.List;
25-
import java.util.Map;
2623
import java.util.function.Predicate;
2724

2825
import org.assertj.core.api.Condition;
@@ -50,11 +47,6 @@
5047
*/
5148
abstract class AbstractLaunchScriptIntegrationTests {
5249

53-
private static final Map<Architecture, URI> JAVA_DOWNLOAD_URLS = Map.of(Architecture.AMD64,
54-
URI.create("https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz"),
55-
Architecture.AARCH64,
56-
URI.create("https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-aarch64.tar.gz"));
57-
5850
protected static final char ESC = 27;
5951

6052
private final String scriptsDir;
@@ -108,9 +100,7 @@ protected String doTest(String os, String version, String script) throws Excepti
108100
private static final class LaunchScriptTestContainer extends GenericContainer<LaunchScriptTestContainer> {
109101

110102
private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) {
111-
super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version)
112-
.withDockerfile(Paths.get("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"))
113-
.withBuildArg("JAVA_DOWNLOAD_URL", getJavaDownloadUrl()));
103+
super(createImage(os, version));
114104
withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar");
115105
withCopyFileToContainer(
116106
MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"),
@@ -123,14 +113,15 @@ private LaunchScriptTestContainer(String os, String version, String scriptsDir,
123113
withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5)));
124114
}
125115

126-
private static String getJavaDownloadUrl() {
127-
Architecture architecture = Architecture.current();
128-
Assert.notNull(architecture,
129-
() -> String.format("Failed to find current architecture. Value of os.arch is: '%s'",
130-
System.getProperty("os.arch")));
131-
URI uri = JAVA_DOWNLOAD_URLS.get(architecture);
132-
Assert.notNull(uri, () -> String.format("No JDK download URL for architecture %s found", architecture));
133-
return uri.toString();
116+
private static ImageFromDockerfile createImage(String os, String version) {
117+
ImageFromDockerfile image = new ImageFromDockerfile(
118+
"spring-boot-launch-script/" + os.toLowerCase() + "-" + version);
119+
image.withFileFromFile("Dockerfile",
120+
new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"));
121+
for (File file : new File("build/downloads/jdk/bellsoft").listFiles()) {
122+
image.withFileFromFile("downloads/" + file.getName(), file);
123+
}
124+
return image;
134125
}
135126

136127
private static File findApplication() {
@@ -142,30 +133,4 @@ private static File findApplication() {
142133

143134
}
144135

145-
private enum Architecture {
146-
147-
AMD64, AARCH64;
148-
149-
/**
150-
* Returns the current architecture.
151-
* @return the current architecture or {@code null}
152-
*/
153-
static Architecture current() {
154-
String arch = System.getProperty("os.arch");
155-
if (arch == null) {
156-
return null;
157-
}
158-
switch (arch) {
159-
case "amd64":
160-
case "x86_64":
161-
return AMD64;
162-
case "aarch64":
163-
return AARCH64;
164-
default:
165-
return null;
166-
}
167-
}
168-
169-
}
170-
171136
}

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/RedHat/ubi9-9.2-722/Dockerfile

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
FROM redhat/ubi9:9.2-722 as prepare
2+
COPY downloads/* /opt/download/
3+
RUN mkdir -p /opt/jdk && \
4+
cd /opt/jdk && \
5+
tar xzf /opt/download/* --strip-components=1
6+
17
FROM redhat/ubi9:9.2-722
2-
ARG JAVA_DOWNLOAD_URL=https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz
3-
ENV JAVA_HOME /opt/openjdk
8+
COPY --from=prepare /opt/jdk /opt/jdk
9+
ENV JAVA_HOME /opt/jdk
410
ENV PATH $JAVA_HOME/bin:$PATH
5-
RUN mkdir -p /opt/openjdk && \
6-
cd /opt/openjdk && \
7-
curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/Ubuntu/jammy-20230624/Dockerfile

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
FROM ubuntu:jammy-20230624 as prepare
2+
COPY downloads/* /opt/download/
3+
RUN mkdir -p /opt/jdk && \
4+
cd /opt/jdk && \
5+
tar xzf /opt/download/* --strip-components=1
6+
17
FROM ubuntu:jammy-20230624
2-
RUN apt-get update && \
3-
apt-get install -y software-properties-common curl && \
4-
mkdir -p /opt/openjdk
5-
ARG JAVA_DOWNLOAD_URL=https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz
6-
ENV JAVA_HOME /opt/openjdk
8+
RUN apt-get update && apt-get install -y software-properties-common curl
9+
COPY --from=prepare /opt/jdk /opt/jdk
10+
ENV JAVA_HOME /opt/jdk
711
ENV PATH $JAVA_HOME/bin:$PATH
8-
RUN cd /opt/openjdk && \
9-
curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1

spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ plugins {
22
id "java"
33
id "org.springframework.boot.conventions"
44
id "org.springframework.boot.integration-test"
5+
id "de.undercouch.download"
56
}
67

78
description = "Spring Boot Loader Integration Tests"
89

10+
def oracleJdkVersion = "17.0.8"
11+
def oracleJdkArch = "aarch64".equalsIgnoreCase(System.getProperty("os.arch")) ? "aarch64" : "x86"
12+
913
configurations {
1014
app
1115
}
@@ -39,6 +43,26 @@ task buildApp(type: GradleBuild) {
3943
tasks = ["build"]
4044
}
4145

46+
task downloadJdk(type: Download) {
47+
def destFolder = new File(rootProject.buildDir, "downloads/jdk/oracle")
48+
destFolder.mkdirs()
49+
src "https://download.oracle.com/java/17/archive/jdk-${oracleJdkVersion}_linux-${oracleJdkArch}_bin.tar.gz"
50+
dest destFolder
51+
tempAndMove true
52+
overwrite false
53+
}
54+
55+
task syncJdkDownloads(type: Sync) {
56+
dependsOn downloadJdk
57+
from "${rootProject.buildDir}/downloads/jdk/oracle/"
58+
include "jdk-${oracleJdkVersion}_linux-${oracleJdkArch}_bin.tar.gz"
59+
into "${project.buildDir}/downloads/jdk/oracle/"
60+
}
61+
62+
processIntTestResources {
63+
dependsOn syncJdkDownloads
64+
}
65+
4266
intTest {
4367
dependsOn buildApp
44-
}
68+
}

spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/java/org/springframework/boot/loader/LoaderIntegrationTests.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ static JavaRuntime openJdk(JavaVersion version) {
127127
}
128128

129129
static JavaRuntime oracleJdk17() {
130-
String arch = System.getProperty("os.arch");
131-
String dockerFile = ("aarch64".equals(arch)) ? "Dockerfile-aarch64" : "Dockerfile";
132-
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk-17")
133-
.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/" + dockerFile));
130+
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk");
131+
image.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/Dockerfile"));
132+
for (File file : new File("build/downloads/jdk/oracle").listFiles()) {
133+
image.withFileFromFile("downloads/" + file.getName(), file);
134+
}
134135
return new JavaRuntime("Oracle JDK 17", JavaVersion.SEVENTEEN, () -> new GenericContainer<>(image));
135136
}
136137

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
FROM ubuntu:jammy-20230624 as prepare
2+
COPY downloads/* /opt/download/
3+
RUN mkdir -p /opt/jdk && \
4+
cd /opt/jdk && \
5+
tar xzf /opt/download/* --strip-components=1
6+
17
FROM ubuntu:jammy-20230624
2-
RUN apt-get update && \
3-
apt-get install -y software-properties-common curl && \
4-
mkdir -p /opt/oraclejdk && \
5-
cd /opt/oraclejdk && \
6-
curl -L https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz | tar zx --strip-components=1
7-
ENV JAVA_HOME /opt/oraclejdk
8+
COPY --from=prepare /opt/jdk /opt/jdk
9+
ENV JAVA_HOME /opt/jdk
810
ENV PATH $JAVA_HOME/bin:$PATH

spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/resources/conf/oracle-jdk-17/Dockerfile-aarch64

-8
This file was deleted.

0 commit comments

Comments
 (0)