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
c8285219
Commit
c8285219
authored
Oct 01, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow tests to provide properties that modify the build.gradle script
See gh-22922
parent
d136324b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
GradleBuild.java
.../org/springframework/boot/gradle/testkit/GradleBuild.java
+16
-3
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java
View file @
c8285219
...
@@ -24,7 +24,10 @@ import java.net.URL;
...
@@ -24,7 +24,10 @@ import java.net.URL;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.jar.JarFile
;
import
java.util.jar.JarFile
;
import
com.fasterxml.jackson.annotation.JsonView
;
import
com.fasterxml.jackson.annotation.JsonView
;
...
@@ -74,8 +77,12 @@ public class GradleBuild {
...
@@ -74,8 +77,12 @@ public class GradleBuild {
private
boolean
configurationCache
=
false
;
private
boolean
configurationCache
=
false
;
private
Map
<
String
,
String
>
scriptProperties
=
new
HashMap
<>();
public
GradleBuild
()
{
public
GradleBuild
()
{
this
(
Dsl
.
GROOVY
);
this
(
Dsl
.
GROOVY
);
this
.
scriptProperties
.
put
(
"bootVersion"
,
getBootVersion
());
this
.
scriptProperties
.
put
(
"dependencyManagementPluginVersion"
,
getDependencyManagementPluginVersion
());
}
}
public
GradleBuild
(
Dsl
dsl
)
{
public
GradleBuild
(
Dsl
dsl
)
{
...
@@ -131,6 +138,11 @@ public class GradleBuild {
...
@@ -131,6 +138,11 @@ public class GradleBuild {
return
this
;
return
this
;
}
}
public
GradleBuild
scriptProperty
(
String
key
,
String
value
)
{
this
.
scriptProperties
.
put
(
key
,
value
);
return
this
;
}
public
BuildResult
build
(
String
...
arguments
)
{
public
BuildResult
build
(
String
...
arguments
)
{
try
{
try
{
BuildResult
result
=
prepareRunner
(
arguments
).
build
();
BuildResult
result
=
prepareRunner
(
arguments
).
build
();
...
@@ -155,9 +167,10 @@ public class GradleBuild {
...
@@ -155,9 +167,10 @@ public class GradleBuild {
}
}
public
GradleRunner
prepareRunner
(
String
...
arguments
)
throws
IOException
{
public
GradleRunner
prepareRunner
(
String
...
arguments
)
throws
IOException
{
String
scriptContent
=
FileCopyUtils
.
copyToString
(
new
FileReader
(
this
.
script
))
String
scriptContent
=
FileCopyUtils
.
copyToString
(
new
FileReader
(
this
.
script
));
.
replace
(
"{version}"
,
getBootVersion
())
for
(
Entry
<
String
,
String
>
property
:
this
.
scriptProperties
.
entrySet
())
{
.
replace
(
"{dependency-management-plugin-version}"
,
getDependencyManagementPluginVersion
());
scriptContent
=
scriptContent
.
replace
(
"{"
+
property
.
getKey
()
+
"}"
,
property
.
getValue
());
}
FileCopyUtils
.
copy
(
scriptContent
,
new
FileWriter
(
new
File
(
this
.
projectDir
,
"build"
+
this
.
dsl
.
getExtension
())));
FileCopyUtils
.
copy
(
scriptContent
,
new
FileWriter
(
new
File
(
this
.
projectDir
,
"build"
+
this
.
dsl
.
getExtension
())));
FileSystemUtils
.
copyRecursively
(
new
File
(
"src/test/resources/repository"
),
FileSystemUtils
.
copyRecursively
(
new
File
(
"src/test/resources/repository"
),
new
File
(
this
.
projectDir
,
"repository"
));
new
File
(
this
.
projectDir
,
"repository"
));
...
...
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