mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-20 06:29:16 +00:00
Merge branch '3.4.x' into 3.5.x
Closes gh-47771
This commit is contained in:
+4
-6
@@ -122,13 +122,12 @@ class BootArchiveSupport {
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
|
||||
LoaderImplementation loaderImplementation, boolean supportsSignatureFile) {
|
||||
return createCopyAction(jar, resolvedDependencies, loaderImplementation, supportsSignatureFile, null, null);
|
||||
LoaderImplementation loaderImplementation) {
|
||||
return createCopyAction(jar, resolvedDependencies, loaderImplementation, null, null);
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
|
||||
LoaderImplementation loaderImplementation, boolean supportsSignatureFile, LayerResolver layerResolver,
|
||||
String jarmodeToolsLocation) {
|
||||
LoaderImplementation loaderImplementation, LayerResolver layerResolver, String jarmodeToolsLocation) {
|
||||
File output = jar.getArchiveFile().get().getAsFile();
|
||||
Manifest manifest = jar.getManifest();
|
||||
boolean preserveFileTimestamps = jar.isPreserveFileTimestamps();
|
||||
@@ -143,8 +142,7 @@ class BootArchiveSupport {
|
||||
String encoding = jar.getMetadataCharset();
|
||||
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirPermissions,
|
||||
filePermissions, includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, launchScript,
|
||||
librarySpec, compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver,
|
||||
loaderImplementation);
|
||||
librarySpec, compressionResolver, encoding, resolvedDependencies, layerResolver, loaderImplementation);
|
||||
return jar.isReproducibleFileOrder() ? new ReproducibleOrderingCopyAction(action) : action;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public abstract class BootJar extends Jar implements BootArchive {
|
||||
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
|
||||
}
|
||||
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, true, layerResolver,
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, layerResolver,
|
||||
jarmodeToolsLocation);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -124,8 +124,8 @@ public abstract class BootWar extends War implements BootArchive {
|
||||
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
|
||||
}
|
||||
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, false,
|
||||
layerResolver, jarmodeToolsLocation);
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, layerResolver,
|
||||
jarmodeToolsLocation);
|
||||
}
|
||||
|
||||
private boolean isIncludeJarmodeTools() {
|
||||
|
||||
+2
-5
@@ -114,8 +114,6 @@ class BootZipCopyAction implements CopyAction {
|
||||
|
||||
private final ResolvedDependencies resolvedDependencies;
|
||||
|
||||
private final boolean supportsSignatureFile;
|
||||
|
||||
private final LayerResolver layerResolver;
|
||||
|
||||
private final LoaderImplementation loaderImplementation;
|
||||
@@ -124,7 +122,7 @@ class BootZipCopyAction implements CopyAction {
|
||||
boolean includeDefaultLoader, String jarmodeToolsLocation, Spec<FileTreeElement> requiresUnpack,
|
||||
Spec<FileTreeElement> exclusions, LaunchScriptConfiguration launchScript, Spec<FileCopyDetails> librarySpec,
|
||||
Function<FileCopyDetails, ZipCompression> compressionResolver, String encoding,
|
||||
ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile, LayerResolver layerResolver,
|
||||
ResolvedDependencies resolvedDependencies, LayerResolver layerResolver,
|
||||
LoaderImplementation loaderImplementation) {
|
||||
this.output = output;
|
||||
this.manifest = manifest;
|
||||
@@ -140,7 +138,6 @@ class BootZipCopyAction implements CopyAction {
|
||||
this.compressionResolver = compressionResolver;
|
||||
this.encoding = encoding;
|
||||
this.resolvedDependencies = resolvedDependencies;
|
||||
this.supportsSignatureFile = supportsSignatureFile;
|
||||
this.layerResolver = layerResolver;
|
||||
this.loaderImplementation = loaderImplementation;
|
||||
}
|
||||
@@ -363,7 +360,7 @@ class BootZipCopyAction implements CopyAction {
|
||||
}
|
||||
|
||||
private void writeSignatureFileIfNecessary() throws IOException {
|
||||
if (BootZipCopyAction.this.supportsSignatureFile && hasSignedLibrary()) {
|
||||
if (hasSignedLibrary()) {
|
||||
writeEntry("META-INF/BOOT.SF", (out) -> {
|
||||
}, false);
|
||||
}
|
||||
|
||||
+12
@@ -49,6 +49,7 @@ import org.apache.commons.compress.archivers.zip.UnixStat;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -647,6 +648,17 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void signed() throws IOException {
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
|
||||
try (JarFile jarFile = new JarFile(jar)) {
|
||||
assertThat(jarFile.getEntry("META-INF/BOOT.SF")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
private void copyMainClassApplication() throws IOException {
|
||||
copyApplication("main");
|
||||
}
|
||||
|
||||
-12
@@ -16,15 +16,12 @@
|
||||
|
||||
package org.springframework.boot.gradle.tasks.bundling;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -46,15 +43,6 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
|
||||
super("bootJar", "BOOT-INF/lib/", "BOOT-INF/classes/", "BOOT-INF/");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void signed() throws Exception {
|
||||
assertThat(this.gradleBuild.build("bootJar").task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
|
||||
try (JarFile jarFile = new JarFile(jar)) {
|
||||
assertThat(jarFile.getEntry("META-INF/BOOT.SF")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenAResolvableCopyOfAnUnresolvableConfigurationIsResolvedThenResolutionSucceeds() {
|
||||
Assumptions.assumeTrue(this.gradleBuild.gradleVersionIsLessThan("9.0-milestone-1"));
|
||||
|
||||
+36
@@ -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.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = 'repository'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")
|
||||
}
|
||||
+2
-1
@@ -51,7 +51,8 @@ public class Repackager extends Packager {
|
||||
@Override
|
||||
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
|
||||
throws IOException {
|
||||
if (getSource().getName().toLowerCase(Locale.ROOT).endsWith(".jar") && hasSignedLibrary(writtenLibraries)) {
|
||||
String sourceName = getSource().getName().toLowerCase(Locale.ROOT);
|
||||
if ((sourceName.endsWith(".jar") || sourceName.endsWith(".war")) && hasSignedLibrary(writtenLibraries)) {
|
||||
writer.writeEntry("META-INF/BOOT.SF", (entryWriter) -> {
|
||||
});
|
||||
}
|
||||
|
||||
+8
@@ -240,4 +240,12 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenSigned(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("war-signed").execute((project) -> {
|
||||
File repackaged = new File(project, "target/war-signed-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).hasEntryWithName("META-INF/BOOT.SF");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.boot.maven.it</groupId>
|
||||
<artifactId>war-signed</artifactId>
|
||||
<version>0.0.1.BUILD-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>@java.version@</maven.compiler.source>
|
||||
<maven.compiler.target>@java.version@</maven.compiler.target>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>@project.groupId@</groupId>
|
||||
<artifactId>@project.artifactId@</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>@maven-war-plugin.version@</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>some.random.Main</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Not-Used>Foo</Not-Used>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>@spring-framework.version@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<version>@jakarta-servlet.version@</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk18on</artifactId>
|
||||
<version>1.78.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
public class SampleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user