Skip to content

Commit d8bacf7

Browse files
committed
Write signature files to uber wars for Oracle Java 17 verification
This commit extends 33c5e12 to uber War. Fixes gh-28837 Signed-off-by: Dmirtii Karagodin <4319788@gmail.com>
1 parent 42cc777 commit d8bacf7

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

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
@@ -240,4 +240,12 @@ void whenEntryIsExcludedItShouldNotBePresentInTheRepackagedWar(MavenBuild mavenB
240240
});
241241
}
242242

243+
@TestTemplate
244+
void whenSigned(MavenBuild mavenBuild) {
245+
mavenBuild.project("war-signed").execute((project) -> {
246+
File repackaged = new File(project, "target/war-signed-0.0.1.BUILD-SNAPSHOT.war");
247+
assertThat(jar(repackaged)).hasEntryWithName("META-INF/BOOT.SF");
248+
});
249+
}
250+
243251
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>@java.version@</maven.compiler.source>
11+
<maven.compiler.target>@java.version@</maven.compiler.target>
12+
</properties>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>@project.groupId@</groupId>
17+
<artifactId>@project.artifactId@</artifactId>
18+
<version>@project.version@</version>
19+
<executions>
20+
<execution>
21+
<goals>
22+
<goal>repackage</goal>
23+
</goals>
24+
</execution>
25+
</executions>
26+
</plugin>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-war-plugin</artifactId>
30+
<version>@maven-war-plugin.version@</version>
31+
<configuration>
32+
<archive>
33+
<manifest>
34+
<mainClass>some.random.Main</mainClass>
35+
</manifest>
36+
<manifestEntries>
37+
<Not-Used>Foo</Not-Used>
38+
</manifestEntries>
39+
</archive>
40+
</configuration>
41+
</plugin>
42+
</plugins>
43+
</build>
44+
<dependencies>
45+
<dependency>
46+
<groupId>org.springframework</groupId>
47+
<artifactId>spring-context</artifactId>
48+
<version>@spring-framework.version@</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>jakarta.servlet</groupId>
52+
<artifactId>jakarta.servlet-api</artifactId>
53+
<version>@jakarta-servlet.version@</version>
54+
<scope>provided</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.bouncycastle</groupId>
58+
<artifactId>bcprov-jdk18on</artifactId>
59+
<version>1.78.1</version>
60+
</dependency>
61+
</dependencies>
62+
</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+
}

loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public Repackager(File source) {
5353
@Override
5454
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
5555
throws IOException {
56-
if (getSource().getName().toLowerCase(Locale.ROOT).endsWith(".jar") && hasSignedLibrary(writtenLibraries)) {
56+
String sourceName = getSource().getName().toLowerCase(Locale.ROOT);
57+
if ((sourceName.endsWith(".jar") || sourceName.endsWith(".war")) && hasSignedLibrary(writtenLibraries)) {
5758
writer.writeEntry("META-INF/BOOT.SF", (entryWriter) -> {
5859
});
5960
}

0 commit comments

Comments
 (0)