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
e763627e
Commit
e763627e
authored
Feb 12, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-25257
parents
12c3c807
63402a29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
UpgradeApplicator.java
...pringframework/boot/build/bom/bomr/UpgradeApplicator.java
+8
-3
UpgradeApplicatorTests.java
...framework/boot/build/bom/bomr/UpgradeApplicatorTests.java
+8
-6
No files found.
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeApplicator.java
View file @
e763627e
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -65,14 +65,19 @@ class UpgradeApplicator {
String
gradlePropertiesContents
=
new
String
(
Files
.
readAllBytes
(
this
.
gradleProperties
),
StandardCharsets
.
UTF_8
);
String
modified
=
gradlePropertiesContents
.
replace
(
property
+
"="
+
upgrade
.
getLibrary
().
getVersion
(),
property
+
"="
+
upgrade
.
getVersion
());
Files
.
write
(
this
.
gradleProperties
,
modified
.
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
overwrite
(
this
.
gradleProperties
,
modified
);
}
private
void
updateBuildFile
(
Upgrade
upgrade
,
String
buildFileContents
)
throws
IOException
{
String
modified
=
buildFileContents
.
replace
(
"library(\""
+
upgrade
.
getLibrary
().
getName
()
+
"\", \""
+
upgrade
.
getLibrary
().
getVersion
()
+
"\")"
,
"library(\""
+
upgrade
.
getLibrary
().
getName
()
+
"\", \""
+
upgrade
.
getVersion
()
+
"\")"
);
Files
.
write
(
this
.
buildFile
,
modified
.
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
overwrite
(
this
.
buildFile
,
modified
);
}
private
void
overwrite
(
Path
target
,
String
content
)
throws
IOException
{
Files
.
write
(
target
,
content
.
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
WRITE
,
StandardOpenOption
.
TRUNCATE_EXISTING
);
}
}
buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java
View file @
e763627e
/*
* Copyright 20
20-2020
the original author or authors.
* Copyright 20
12-2021
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.
...
...
@@ -32,6 +32,7 @@ import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
entry
;
/**
* Tests for {@link UpgradeApplicator}.
...
...
@@ -47,13 +48,14 @@ class UpgradeApplicatorTests {
void
whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated
()
throws
IOException
{
File
bom
=
new
File
(
this
.
temp
,
"bom.gradle"
);
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/bom.gradle"
),
bom
);
String
originalContents
=
new
String
(
Files
.
readAllBytes
(
bom
.
toPath
()),
StandardCharsets
.
UTF_8
);
File
gradleProperties
=
new
File
(
this
.
temp
,
"gradle.properties"
);
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/gradle.properties"
),
gradleProperties
);
new
UpgradeApplicator
(
bom
.
toPath
(),
gradleProperties
.
toPath
())
.
apply
(
new
Upgrade
(
new
Library
(
"ActiveMQ"
,
DependencyVersion
.
parse
(
"5.15.11"
),
null
,
null
),
DependencyVersion
.
parse
(
"5.16"
)));
String
bomContents
=
new
String
(
Files
.
readAllBytes
(
bom
.
toPath
()),
StandardCharsets
.
UTF_8
);
assertThat
(
bomContents
).
contains
(
"library(\"ActiveMQ\", \"5.16\")"
);
assertThat
(
bomContents
.
length
()).
isEqualTo
(
originalContents
.
length
()
-
3
);
}
@Test
...
...
@@ -62,14 +64,14 @@ class UpgradeApplicatorTests {
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/bom.gradle"
),
bom
);
File
gradleProperties
=
new
File
(
this
.
temp
,
"gradle.properties"
);
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/gradle.properties"
),
gradleProperties
);
new
UpgradeApplicator
(
bom
.
toPath
(),
gradleProperties
.
toPath
())
.
apply
(
new
Upgrade
(
new
Library
(
"Kotlin"
,
DependencyVersion
.
parse
(
"1.3.70"
),
null
,
null
),
DependencyVersion
.
parse
(
"1.3.71"
)));
new
UpgradeApplicator
(
bom
.
toPath
(),
gradleProperties
.
toPath
()).
apply
(
new
Upgrade
(
new
Library
(
"Kotlin"
,
DependencyVersion
.
parse
(
"1.3.70"
),
null
,
null
),
DependencyVersion
.
parse
(
"1.4"
)));
Properties
properties
=
new
Properties
();
try
(
InputStream
in
=
new
FileInputStream
(
gradleProperties
))
{
properties
.
load
(
in
);
}
assertThat
(
properties
).
containsEntry
(
"kotlinVersion"
,
"1.3.71"
);
assertThat
(
properties
).
containsOnly
(
entry
(
"a"
,
"alpha"
),
entry
(
"b"
,
"bravo"
),
entry
(
"kotlinVersion"
,
"1.4"
),
entry
(
"t"
,
"tango"
));
}
}
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