mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-23 01:39:02 +00:00
Merge branch '3.5.x'
Closes gh-47772
This commit is contained in:
+4
-4
@@ -113,11 +113,11 @@ class BootArchiveSupport {
|
||||
return (version != null) ? version : "unknown";
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile) {
|
||||
return createCopyAction(jar, resolvedDependencies, supportsSignatureFile, null, null);
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies) {
|
||||
return createCopyAction(jar, resolvedDependencies, null, null);
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile,
|
||||
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
|
||||
@Nullable LayerResolver layerResolver, @Nullable String jarmodeToolsLocation) {
|
||||
File output = jar.getArchiveFile().get().getAsFile();
|
||||
Manifest manifest = jar.getManifest();
|
||||
@@ -132,7 +132,7 @@ class BootArchiveSupport {
|
||||
String encoding = jar.getMetadataCharset();
|
||||
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirPermissions,
|
||||
filePermissions, includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, librarySpec,
|
||||
compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver);
|
||||
compressionResolver, encoding, resolvedDependencies, layerResolver);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -148,8 +148,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, true, layerResolver,
|
||||
jarmodeToolsLocation);
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, layerResolver, jarmodeToolsLocation);
|
||||
}
|
||||
|
||||
private boolean isIncludeJarmodeTools() {
|
||||
|
||||
+1
-2
@@ -122,8 +122,7 @@ 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, false, layerResolver,
|
||||
jarmodeToolsLocation);
|
||||
return this.support.createCopyAction(this, this.resolvedDependencies, layerResolver, jarmodeToolsLocation);
|
||||
}
|
||||
|
||||
private boolean isIncludeJarmodeTools() {
|
||||
|
||||
+2
-6
@@ -109,16 +109,13 @@ class BootZipCopyAction implements CopyAction {
|
||||
|
||||
private final ResolvedDependencies resolvedDependencies;
|
||||
|
||||
private final boolean supportsSignatureFile;
|
||||
|
||||
private final @Nullable LayerResolver layerResolver;
|
||||
|
||||
BootZipCopyAction(File output, Manifest manifest, boolean preserveFileTimestamps, @Nullable Integer dirMode,
|
||||
@Nullable Integer fileMode, boolean includeDefaultLoader, @Nullable String jarmodeToolsLocation,
|
||||
Spec<FileTreeElement> requiresUnpack, Spec<FileTreeElement> exclusions, Spec<FileCopyDetails> librarySpec,
|
||||
Function<FileCopyDetails, ZipCompression> compressionResolver, @Nullable String encoding,
|
||||
ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile,
|
||||
@Nullable LayerResolver layerResolver) {
|
||||
ResolvedDependencies resolvedDependencies, @Nullable LayerResolver layerResolver) {
|
||||
this.output = output;
|
||||
this.manifest = manifest;
|
||||
this.preserveFileTimestamps = preserveFileTimestamps;
|
||||
@@ -132,7 +129,6 @@ class BootZipCopyAction implements CopyAction {
|
||||
this.compressionResolver = compressionResolver;
|
||||
this.encoding = encoding;
|
||||
this.resolvedDependencies = resolvedDependencies;
|
||||
this.supportsSignatureFile = supportsSignatureFile;
|
||||
this.layerResolver = layerResolver;
|
||||
}
|
||||
|
||||
@@ -341,7 +337,7 @@ class BootZipCopyAction implements CopyAction {
|
||||
}
|
||||
|
||||
private void writeSignatureFileIfNecessary() throws IOException {
|
||||
if (BootZipCopyAction.this.supportsSignatureFile && hasSignedLibrary()) {
|
||||
if (hasSignedLibrary()) {
|
||||
writeEntry("META-INF/BOOT.SF", (out) -> {
|
||||
}, false);
|
||||
}
|
||||
|
||||
+11
@@ -641,6 +641,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");
|
||||
}
|
||||
|
||||
-15
@@ -16,16 +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.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -47,17 +43,6 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
|
||||
super("bootJar", "BOOT-INF/lib/", "BOOT-INF/classes/", "BOOT-INF/");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void signed() throws Exception {
|
||||
BuildTask task = this.gradleBuild.build("bootJar").task(":bootJar");
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@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")
|
||||
}
|
||||
+8
@@ -250,4 +250,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");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -53,7 +53,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) -> {
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user