Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c8021806
Commit
c8021806
authored
May 28, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use sorted properties to make build info output repeatable
Closes gh-14494
parent
6de14f71
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
BuildInfoIntegrationTests.java
...oot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java
+19
-0
BuildPropertiesWriter.java
...ingframework/boot/loader/tools/BuildPropertiesWriter.java
+4
-2
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java
View file @
c8021806
...
...
@@ -22,12 +22,15 @@ import java.io.IOException;
import
java.util.Properties
;
import
org.gradle.testkit.runner.BuildResult
;
import
org.gradle.testkit.runner.InvalidRunnerConfigurationException
;
import
org.gradle.testkit.runner.TaskOutcome
;
import
org.gradle.testkit.runner.UnexpectedBuildFailure
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.boot.gradle.junit.GradleCompatibilityExtension
;
import
org.springframework.boot.gradle.testkit.GradleBuild
;
import
org.springframework.boot.loader.tools.FileUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -92,6 +95,22 @@ public class BuildInfoIntegrationTests {
assertThat
(
result
.
task
(
":buildInfo"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
}
@TestTemplate
public
void
reproducibleOutputWithFixedTime
()
throws
InvalidRunnerConfigurationException
,
UnexpectedBuildFailure
,
IOException
,
InterruptedException
{
assertThat
(
this
.
gradleBuild
.
build
(
"buildInfo"
,
"-PnullTime"
).
task
(
":buildInfo"
)
.
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
File
buildInfoProperties
=
new
File
(
this
.
gradleBuild
.
getProjectDir
(),
"build/build-info.properties"
);
String
firstHash
=
FileUtils
.
sha1Hash
(
buildInfoProperties
);
assertThat
(
buildInfoProperties
.
delete
()).
isTrue
();
Thread
.
sleep
(
1500
);
assertThat
(
this
.
gradleBuild
.
build
(
"buildInfo"
,
"-PnullTime"
)
.
task
(
":buildInfo"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
String
secondHash
=
FileUtils
.
sha1Hash
(
buildInfoProperties
);
assertThat
(
firstHash
).
isEqualTo
(
secondHash
);
}
private
Properties
buildInfoProperties
()
{
File
file
=
new
File
(
this
.
gradleBuild
.
getProjectDir
(),
"build/build-info.properties"
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java
View file @
c8021806
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
...
@@ -24,6 +24,8 @@ import java.time.format.DateTimeFormatter;
import
java.util.Map
;
import
java.util.Properties
;
import
org.springframework.core.CollectionFactory
;
/**
* A {@code BuildPropertiesWriter} writes the {@code build-info.properties} for
* consumption by the Actuator.
...
...
@@ -68,7 +70,7 @@ public final class BuildPropertiesWriter {
}
protected
Properties
createBuildInfo
(
ProjectDetails
project
)
{
Properties
properties
=
new
Properties
(
);
Properties
properties
=
CollectionFactory
.
createSortedProperties
(
true
);
properties
.
put
(
"build.group"
,
project
.
getGroup
());
properties
.
put
(
"build.artifact"
,
project
.
getArtifact
());
properties
.
put
(
"build.name"
,
project
.
getName
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment