Skip to content

Commit 35d6d76

Browse files
committed
Merge branch '3.2.x' into 3.3.x
Closes gh-42935
2 parents c8b0e7f + bb29625 commit 35d6d76

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildInfoIntegrationTests.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.io.FileReader;
2121
import java.io.IOException;
22+
import java.time.Instant;
2223
import java.util.Properties;
2324
import java.util.function.Consumer;
2425

@@ -83,6 +84,16 @@ void generatedBuildInfoReproducible(MavenBuild mavenBuild) {
8384
.hasBuildTime("2021-04-21T11:22:33Z")));
8485
}
8586

87+
@TestTemplate
88+
void generatedBuildInfoReproducibleEpochSeconds(MavenBuild mavenBuild) {
89+
mavenBuild.project("build-info-reproducible-epoch-seconds")
90+
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
91+
.hasBuildArtifact("build-reproducible-epoch-seconds")
92+
.hasBuildName("Generate build info with build time from project.build.outputTimestamp")
93+
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
94+
.hasBuildTime(Instant.ofEpochSecond(1619004153).toString())));
95+
}
96+
8697
@TestTemplate
8798
void buildInfoPropertiesAreGeneratedToCustomOutputLocation(MavenBuild mavenBuild) {
8899
mavenBuild.project("build-info-custom-file")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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>build-reproducible-epoch-seconds</artifactId>
7+
<version>0.0.1.BUILD-SNAPSHOT</version>
8+
<name>Generate build info with build time from project.build.outputTimestamp</name>
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+
<project.build.outputTimestamp>1619004153</project.build.outputTimestamp>
14+
</properties>
15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>@project.groupId@</groupId>
19+
<artifactId>@project.artifactId@</artifactId>
20+
<version>@project.version@</version>
21+
<executions>
22+
<execution>
23+
<goals>
24+
<goal>build-info</goal>
25+
</goals>
26+
</execution>
27+
</executions>
28+
</plugin>
29+
</plugins>
30+
</build>
31+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2012-2024 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+
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ private Instant getBuildTime() {
154154
if ("off".equalsIgnoreCase(this.time)) {
155155
return null;
156156
}
157-
return Instant.parse(this.time);
157+
return new MavenBuildOutputTimestamp(this.time).toInstant();
158158
}
159159

160160
}

0 commit comments

Comments
 (0)