Merge branch '3.5.x' into 4.0.x

Closes gh-50297
This commit is contained in:
Phillip Webb
2026-05-05 11:21:40 -07:00
9 changed files with 238 additions and 23 deletions
@@ -70,6 +70,19 @@ tasks.register("buildSignedJarApp", GradleBuild) {
tasks = ["build"]
}
tasks.register("syncSignedJarRsaAppSource", org.springframework.boot.build.SyncAppSource) {
sourceDirectory = file("spring-boot-loader-tests-signed-jar-rsa")
destinationDirectory = file(layout.buildDirectory.dir("spring-boot-loader-tests-signed-jar-rsa"))
}
tasks.register("buildSignedJarRsaApp", GradleBuild) {
dependsOn syncSignedJarRsaAppSource, syncMavenRepository
dir = layout.buildDirectory.dir("spring-boot-loader-tests-signed-jar-rsa")
startParameter.buildCacheEnabled = false
tasks = ["build"]
}
tasks.register("downloadJdk", Download) {
def destFolder = new File(project.gradle.gradleUserHomeDir, "caches/springboot/downloads/jdk/oracle")
destFolder.mkdirs()
@@ -92,5 +105,5 @@ tasks.named("processDockerTestResources").configure {
}
tasks.named("dockerTest").configure {
dependsOn buildApp, buildSignedJarApp
dependsOn buildApp, buildSignedJarApp, buildSignedJarRsaApp
}
@@ -0,0 +1,49 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
id "java"
id "org.springframework.boot"
}
java {
sourceCompatibility = '17'
targetCompatibility = '17'
}
repositories {
maven { url "file:${rootDir}/../docker-test-maven-repository"}
mavenCentral()
spring.mavenRepositories()
}
dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.bouncycastle:bcprov-jdk18on:1.84") // gh-50292
}
tasks.register("bootJarUnpack", BootJar.class) {
mainClass = "org.springframework.boot.loaderapp.LoaderSignedJarTestApplication"
classpath = bootJar.classpath
requiresUnpack '**/bcprov-jdk18on-*.jar'
archiveClassifier.set("unpack")
targetJavaVersion = targetCompatibility
}
build.dependsOn bootJarUnpack
@@ -0,0 +1,31 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pluginManagement {
evaluate(new File("${gradle.parent.rootProject.rootDir}/buildSrc/SpringRepositorySupport.groovy")).apply(this)
repositories {
maven { url "file:${rootDir}/../docker-test-maven-repository"}
mavenCentral()
spring.mavenRepositories()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.springframework.boot") {
useModule "org.springframework.boot:spring-boot-gradle-plugin:${requested.version}"
}
}
}
}
@@ -0,0 +1,36 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.loaderapp;
import java.security.Security;
import javax.crypto.Cipher;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LoaderSignedJarTestApplication {
public static void main(String[] args) throws Exception {
Security.addProvider(new BouncyCastleProvider());
Cipher.getInstance("AES/CBC/PKCS5Padding","BC");
System.out.println("Legion of the Bouncy Castle");
SpringApplication.run(LoaderSignedJarTestApplication.class, args);
}
}
@@ -85,6 +85,17 @@ class LoaderIntegrationTests {
}
}
@ParameterizedTest
@MethodSource("javaRuntimes")
void runSignedJarWhenRsa(JavaRuntime javaRuntime) {
try (GenericContainer<?> container = createContainer(javaRuntime, "spring-boot-loader-tests-signed-jar-rsa",
null)) {
container.start();
System.out.println(this.output.toUtf8String());
assertThat(this.output.toUtf8String()).contains("Legion of the Bouncy Castle");
}
}
private GenericContainer<?> createContainer(JavaRuntime javaRuntime, String name, String classifier) {
return javaRuntime.getContainer()
.withLogConsumer(this.output)