Skip to content

Commit debbec8

Browse files
committed
Merge branch '3.5.x'
Closes gh-47772
2 parents 770c946 + 59aba4e commit debbec8

File tree

11 files changed

+152
-30
lines changed

11 files changed

+152
-30
lines changed

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ private String determineSpringBootVersion() {
113113
return (version != null) ? version : "unknown";
114114
}
115115

116-
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile) {
117-
return createCopyAction(jar, resolvedDependencies, supportsSignatureFile, null, null);
116+
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies) {
117+
return createCopyAction(jar, resolvedDependencies, null, null);
118118
}
119119

120-
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile,
120+
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
121121
@Nullable LayerResolver layerResolver, @Nullable String jarmodeToolsLocation) {
122122
File output = jar.getArchiveFile().get().getAsFile();
123123
Manifest manifest = jar.getManifest();
@@ -132,7 +132,7 @@ CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
132132
String encoding = jar.getMetadataCharset();
133133
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirPermissions,
134134
filePermissions, includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, librarySpec,
135-
compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver);
135+
compressionResolver, encoding, resolvedDependencies, layerResolver);
136136
return action;
137137
}
138138

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ protected CopyAction createCopyAction() {
148148
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
149149
}
150150
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
151-
return this.support.createCopyAction(this, this.resolvedDependencies, true, layerResolver,
152-
jarmodeToolsLocation);
151+
return this.support.createCopyAction(this, this.resolvedDependencies, layerResolver, jarmodeToolsLocation);
153152
}
154153

155154
private boolean isIncludeJarmodeTools() {

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ protected CopyAction createCopyAction() {
122122
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
123123
}
124124
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
125-
return this.support.createCopyAction(this, this.resolvedDependencies, false, layerResolver,
126-
jarmodeToolsLocation);
125+
return this.support.createCopyAction(this, this.resolvedDependencies, layerResolver, jarmodeToolsLocation);
127126
}
128127

129128
private boolean isIncludeJarmodeTools() {

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,13 @@ class BootZipCopyAction implements CopyAction {
109109

110110
private final ResolvedDependencies resolvedDependencies;
111111

112-
private final boolean supportsSignatureFile;
113-
114112
private final @Nullable LayerResolver layerResolver;
115113

116114
BootZipCopyAction(File output, Manifest manifest, boolean preserveFileTimestamps, @Nullable Integer dirMode,
117115
@Nullable Integer fileMode, boolean includeDefaultLoader, @Nullable String jarmodeToolsLocation,
118116
Spec<FileTreeElement> requiresUnpack, Spec<FileTreeElement> exclusions, Spec<FileCopyDetails> librarySpec,
119117
Function<FileCopyDetails, ZipCompression> compressionResolver, @Nullable String encoding,
120-
ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile,
121-
@Nullable LayerResolver layerResolver) {
118+
ResolvedDependencies resolvedDependencies, @Nullable LayerResolver layerResolver) {
122119
this.output = output;
123120
this.manifest = manifest;
124121
this.preserveFileTimestamps = preserveFileTimestamps;
@@ -132,7 +129,6 @@ class BootZipCopyAction implements CopyAction {
132129
this.compressionResolver = compressionResolver;
133130
this.encoding = encoding;
134131
this.resolvedDependencies = resolvedDependencies;
135-
this.supportsSignatureFile = supportsSignatureFile;
136132
this.layerResolver = layerResolver;
137133
}
138134

@@ -341,7 +337,7 @@ private void writeJarModeLibrary(String location, JarModeLibrary library) throws
341337
}
342338

343339
private void writeSignatureFileIfNecessary() throws IOException {
344-
if (BootZipCopyAction.this.supportsSignatureFile && hasSignedLibrary()) {
340+
if (hasSignedLibrary()) {
345341
writeEntry("META-INF/BOOT.SF", (out) -> {
346342
}, false);
347343
}

build-plugin/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,17 @@ void dirModeAndFileModeAreApplied() throws IOException {
641641
}
642642
}
643643

644+
@TestTemplate
645+
void signed() throws IOException {
646+
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
647+
assertThat(task).isNotNull();
648+
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
649+
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
650+
try (JarFile jarFile = new JarFile(jar)) {
651+
assertThat(jarFile.getEntry("META-INF/BOOT.SF")).isNotNull();
652+
}
653+
}
654+
644655
private void copyMainClassApplication() throws IOException {
645656
copyApplication("main");
646657
}

build-plugin/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarIntegrationTests.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@
1616

1717
package org.springframework.boot.gradle.tasks.bundling;
1818

19-
import java.io.File;
2019
import java.io.IOException;
2120
import java.util.Arrays;
2221
import java.util.Set;
2322
import java.util.TreeSet;
24-
import java.util.jar.JarFile;
2523

2624
import org.gradle.testkit.runner.BuildResult;
27-
import org.gradle.testkit.runner.BuildTask;
28-
import org.gradle.testkit.runner.TaskOutcome;
2925
import org.junit.jupiter.api.Assumptions;
3026
import org.junit.jupiter.api.TestTemplate;
3127

@@ -47,17 +43,6 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
4743
super("bootJar", "BOOT-INF/lib/", "BOOT-INF/classes/", "BOOT-INF/");
4844
}
4945

50-
@TestTemplate
51-
void signed() throws Exception {
52-
BuildTask task = this.gradleBuild.build("bootJar").task(":bootJar");
53-
assertThat(task).isNotNull();
54-
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
55-
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
56-
try (JarFile jarFile = new JarFile(jar)) {
57-
assertThat(jarFile.getEntry("META-INF/BOOT.SF")).isNotNull();
58-
}
59-
}
60-
6146
@TestTemplate
6247
void whenAResolvableCopyOfAnUnresolvableConfigurationIsResolvedThenResolutionSucceeds() {
6348
Assumptions.assumeTrue(this.gradleBuild.gradleVersionIsLessThan("9.0-milestone-1"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the License);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'war'
19+
id 'java'
20+
id 'org.springframework.boot' version '{version}'
21+
}
22+
23+
bootWar {
24+
mainClass = 'com.example.Application'
25+
}
26+
27+
repositories {
28+
mavenCentral()
29+
maven {
30+
url = 'repository'
31+
}
32+
}
33+
34+
dependencies {
35+
implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")
36+
}

build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,12 @@ void whenEntryIsExcludedItShouldNotBePresentInTheRepackagedWar(MavenBuild mavenB
250250
});
251251
}
252252

253+
@TestTemplate
254+
void whenSigned(MavenBuild mavenBuild) {
255+
mavenBuild.project("war-signed").execute((project) -> {
256+
File repackaged = new File(project, "target/war-signed-0.0.1.BUILD-SNAPSHOT.war");
257+
assertThat(jar(repackaged)).hasEntryWithName("META-INF/BOOT.SF");
258+
});
259+
}
260+
253261
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.springframework.boot.maven.it</groupId>
6+
<artifactId>war-signed</artifactId>
7+
<version>0.0.1.BUILD-SNAPSHOT</version>
8+
<packaging>war</packaging>
9+
<properties>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
<maven.compiler.source>@java.version@</maven.compiler.source>
12+
<maven.compiler.target>@java.version@</maven.compiler.target>
13+
</properties>
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<groupId>@project.groupId@</groupId>
18+
<artifactId>@project.artifactId@</artifactId>
19+
<version>@project.version@</version>
20+
<executions>
21+
<execution>
22+
<goals>
23+
<goal>repackage</goal>
24+
</goals>
25+
</execution>
26+
</executions>
27+
</plugin>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-war-plugin</artifactId>
31+
<version>@maven-war-plugin.version@</version>
32+
<configuration>
33+
<archive>
34+
<manifest>
35+
<mainClass>some.random.Main</mainClass>
36+
</manifest>
37+
<manifestEntries>
38+
<Not-Used>Foo</Not-Used>
39+
</manifestEntries>
40+
</archive>
41+
</configuration>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
<dependencies>
46+
<dependency>
47+
<groupId>org.springframework</groupId>
48+
<artifactId>spring-context</artifactId>
49+
<version>@spring-framework.version@</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>jakarta.servlet</groupId>
53+
<artifactId>jakarta.servlet-api</artifactId>
54+
<version>@jakarta-servlet.version@</version>
55+
<scope>provided</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.bouncycastle</groupId>
59+
<artifactId>bcprov-jdk18on</artifactId>
60+
<version>1.78.1</version>
61+
</dependency>
62+
</dependencies>
63+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.test;
18+
19+
public class SampleApplication {
20+
21+
public static void main(String[] args) {
22+
}
23+
24+
}

0 commit comments

Comments
 (0)