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
d136324b
Commit
d136324b
authored
Oct 01, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for testing the Gradle plugin with --configuration-cache
See gh-22922
parent
fa220ace
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
8 deletions
+44
-8
GradleCompatibility.java
...pringframework/boot/gradle/junit/GradleCompatibility.java
+7
-0
GradleCompatibilityExtension.java
...ework/boot/gradle/junit/GradleCompatibilityExtension.java
+27
-8
GradleBuild.java
.../org/springframework/boot/gradle/testkit/GradleBuild.java
+10
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java
View file @
d136324b
...
...
@@ -41,4 +41,11 @@ import org.springframework.boot.gradle.testkit.GradleBuild;
@ExtendWith
(
GradleCompatibilityExtension
.
class
)
public
@interface
GradleCompatibility
{
/**
* Whether to include running Gradle with {@code --cache-configuration} cache in the
* compatibility matrix.
* @return {@code true} to enable the configuration cache, {@code false} otherwise
*/
boolean
configurationCache
()
default
false
;
}
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java
View file @
d136324b
...
...
@@ -16,16 +16,19 @@
package
org
.
springframework
.
boot
.
gradle
.
junit
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Stream
;
import
org.gradle.api.JavaVersion
;
import
org.gradle.util.GradleVersion
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.extension.Extension
;
import
org.junit.jupiter.api.extension.ExtensionContext
;
import
org.junit.jupiter.api.extension.TestTemplateInvocationContext
;
import
org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
;
import
org.junit.platform.commons.util.AnnotationUtils
;
import
org.springframework.boot.gradle.testkit.GradleBuild
;
import
org.springframework.boot.gradle.testkit.GradleBuildExtension
;
...
...
@@ -45,16 +48,29 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
JavaVersion
javaVersion
=
JavaVersion
.
current
();
if
(
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_14
)
||
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_13
))
{
GRADLE_VERSIONS
=
Arrays
.
asList
(
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"6.6.1"
,
"
defaul
t"
);
GRADLE_VERSIONS
=
Arrays
.
asList
(
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"6.6.1"
,
"
curren
t"
);
}
else
{
GRADLE_VERSIONS
=
Arrays
.
asList
(
"5.6.4"
,
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"6.6.1"
,
"
defaul
t"
);
GRADLE_VERSIONS
=
Arrays
.
asList
(
"5.6.4"
,
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"6.6.1"
,
"
curren
t"
);
}
}
@Override
public
Stream
<
TestTemplateInvocationContext
>
provideTestTemplateInvocationContexts
(
ExtensionContext
context
)
{
return
GRADLE_VERSIONS
.
stream
().
map
(
GradleVersionTestTemplateInvocationContext:
:
new
);
return
GRADLE_VERSIONS
.
stream
().
flatMap
((
version
)
->
{
if
(
version
.
equals
(
"current"
))
{
version
=
GradleVersion
.
current
().
getVersion
();
}
List
<
TestTemplateInvocationContext
>
invocationContexts
=
new
ArrayList
<>();
invocationContexts
.
add
(
new
GradleVersionTestTemplateInvocationContext
(
version
,
false
));
boolean
configurationCache
=
AnnotationUtils
.
findAnnotation
(
context
.
getRequiredTestClass
(),
GradleCompatibility
.
class
).
get
()
.
configurationCache
();
if
(
configurationCache
&&
GradleVersion
.
version
(
version
).
compareTo
(
GradleVersion
.
version
(
"6.6"
))
>=
0
)
{
invocationContexts
.
add
(
new
GradleVersionTestTemplateInvocationContext
(
version
,
true
));
}
return
invocationContexts
.
stream
();
});
}
@Override
...
...
@@ -66,20 +82,23 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
private
final
String
gradleVersion
;
GradleVersionTestTemplateInvocationContext
(
String
gradleVersion
)
{
private
final
boolean
configurationCache
;
GradleVersionTestTemplateInvocationContext
(
String
gradleVersion
,
boolean
configurationCache
)
{
this
.
gradleVersion
=
gradleVersion
;
this
.
configurationCache
=
configurationCache
;
}
@Override
public
String
getDisplayName
(
int
invocationIndex
)
{
return
"Gradle "
+
this
.
gradleVersion
;
return
"Gradle "
+
this
.
gradleVersion
+
((
this
.
configurationCache
)
?
" --configuration-cache"
:
""
)
;
}
@Override
public
List
<
Extension
>
getAdditionalExtensions
()
{
GradleBuild
gradleBuild
=
new
GradleBuild
();
if
(
!
this
.
gradleVersion
.
equals
(
"default"
)
)
{
gradleBuild
.
gradleVersion
(
this
.
gradleVersion
);
GradleBuild
gradleBuild
=
new
GradleBuild
()
.
gradleVersion
(
this
.
gradleVersion
)
;
if
(
this
.
configurationCache
)
{
gradleBuild
.
configurationCache
(
);
}
return
Arrays
.
asList
(
new
GradleBuildFieldSetter
(
gradleBuild
),
new
GradleBuildExtension
());
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java
View file @
d136324b
...
...
@@ -72,6 +72,8 @@ public class GradleBuild {
private
GradleVersion
expectDeprecationWarnings
;
private
boolean
configurationCache
=
false
;
public
GradleBuild
()
{
this
(
Dsl
.
GROOVY
);
}
...
...
@@ -124,6 +126,11 @@ public class GradleBuild {
return
this
;
}
public
GradleBuild
configurationCache
()
{
this
.
configurationCache
=
true
;
return
this
;
}
public
BuildResult
build
(
String
...
arguments
)
{
try
{
BuildResult
result
=
prepareRunner
(
arguments
).
build
();
...
...
@@ -169,6 +176,9 @@ public class GradleBuild {
allArguments
.
addAll
(
Arrays
.
asList
(
arguments
));
allArguments
.
add
(
"--warning-mode"
);
allArguments
.
add
(
"all"
);
if
(
this
.
configurationCache
)
{
allArguments
.
add
(
"--configuration-cache"
);
}
return
gradleRunner
.
withArguments
(
allArguments
);
}
...
...
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