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
961a34a5
Commit
961a34a5
authored
Mar 04, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25497
parents
9fd6a1e5
52350473
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
166 additions
and
24 deletions
+166
-24
JavaConventions.java
.../java/org/springframework/boot/build/JavaConventions.java
+10
-20
ToolchainExtension.java
...ingframework/boot/build/toolchain/ToolchainExtension.java
+48
-0
ToolchainPlugin.java
...springframework/boot/build/toolchain/ToolchainPlugin.java
+93
-0
settings.gradle
settings.gradle
+2
-2
build.gradle
spring-boot-project/spring-boot-cli/build.gradle
+4
-0
JsonbTesterTests.java
.../org/springframework/boot/test/json/JsonbTesterTests.java
+1
-1
build.gradle
.../spring-boot-tools/spring-boot-gradle-plugin/build.gradle
+4
-0
build.gradle
...t/spring-boot-tools/spring-boot-loader-tools/build.gradle
+1
-1
JarIntegrationTests.java
...a/org/springframework/boot/maven/JarIntegrationTests.java
+3
-0
No files found.
buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java
View file @
961a34a5
...
@@ -16,14 +16,12 @@
...
@@ -16,14 +16,12 @@
package
org
.
springframework
.
boot
.
build
;
package
org
.
springframework
.
boot
.
build
;
import
java.io.File
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.function.Consumer
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
io.spring.javaformat.gradle.FormatTask
;
import
io.spring.javaformat.gradle.FormatTask
;
...
@@ -49,6 +47,7 @@ import org.gradle.testretry.TestRetryTaskExtension;
...
@@ -49,6 +47,7 @@ import org.gradle.testretry.TestRetryTaskExtension;
import
org.springframework.boot.build.optional.OptionalDependenciesPlugin
;
import
org.springframework.boot.build.optional.OptionalDependenciesPlugin
;
import
org.springframework.boot.build.testing.TestFailuresPlugin
;
import
org.springframework.boot.build.testing.TestFailuresPlugin
;
import
org.springframework.boot.build.toolchain.ToolchainPlugin
;
/**
/**
* Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the
* Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the
...
@@ -103,6 +102,7 @@ class JavaConventions {
...
@@ -103,6 +102,7 @@ class JavaConventions {
configureTestConventions
(
project
);
configureTestConventions
(
project
);
configureJarManifestConventions
(
project
);
configureJarManifestConventions
(
project
);
configureDependencyManagement
(
project
);
configureDependencyManagement
(
project
);
configureToolchain
(
project
);
});
});
}
}
...
@@ -145,7 +145,6 @@ class JavaConventions {
...
@@ -145,7 +145,6 @@ class JavaConventions {
private
void
configureTestConventions
(
Project
project
)
{
private
void
configureTestConventions
(
Project
project
)
{
project
.
getTasks
().
withType
(
Test
.
class
,
(
test
)
->
{
project
.
getTasks
().
withType
(
Test
.
class
,
(
test
)
->
{
withOptionalBuildJavaHome
(
project
,
(
javaHome
)
->
test
.
setExecutable
(
javaHome
+
"/bin/java"
));
test
.
useJUnitPlatform
();
test
.
useJUnitPlatform
();
test
.
setMaxHeapSize
(
"1024M"
);
test
.
setMaxHeapSize
(
"1024M"
);
});
});
...
@@ -165,38 +164,25 @@ class JavaConventions {
...
@@ -165,38 +164,25 @@ class JavaConventions {
}
}
private
void
configureJavadocConventions
(
Project
project
)
{
private
void
configureJavadocConventions
(
Project
project
)
{
project
.
getTasks
().
withType
(
Javadoc
.
class
,
(
javadoc
)
->
{
project
.
getTasks
().
withType
(
Javadoc
.
class
,
(
javadoc
)
->
javadoc
.
getOptions
().
source
(
"1.8"
).
encoding
(
"UTF-8"
));
javadoc
.
getOptions
().
source
(
"1.8"
).
encoding
(
"UTF-8"
);
withOptionalBuildJavaHome
(
project
,
(
javaHome
)
->
javadoc
.
setExecutable
(
javaHome
+
"/bin/javadoc"
));
});
}
}
private
void
configureJavaCompileConventions
(
Project
project
)
{
private
void
configureJavaCompileConventions
(
Project
project
)
{
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
compile
)
->
{
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
compile
)
->
{
compile
.
getOptions
().
setEncoding
(
"UTF-8"
);
compile
.
getOptions
().
setEncoding
(
"UTF-8"
);
withOptionalBuildJavaHome
(
project
,
(
javaHome
)
->
{
compile
.
setSourceCompatibility
(
"1.8"
);
compile
.
getOptions
().
setFork
(
true
);
compile
.
setTargetCompatibility
(
"1.8"
);
compile
.
getOptions
().
getForkOptions
().
setJavaHome
(
new
File
(
javaHome
));
compile
.
getOptions
().
getForkOptions
().
setExecutable
(
javaHome
+
"/bin/javac"
);
});
List
<
String
>
args
=
compile
.
getOptions
().
getCompilerArgs
();
List
<
String
>
args
=
compile
.
getOptions
().
getCompilerArgs
();
if
(!
args
.
contains
(
"-parameters"
))
{
if
(!
args
.
contains
(
"-parameters"
))
{
args
.
add
(
"-parameters"
);
args
.
add
(
"-parameters"
);
}
}
if
(
JavaVersion
.
current
()
==
JavaVersion
.
VERSION_1_8
)
{
if
(
!
project
.
hasProperty
(
"toolchainVersion"
)
&&
JavaVersion
.
current
()
==
JavaVersion
.
VERSION_1_8
)
{
args
.
addAll
(
Arrays
.
asList
(
"-Werror"
,
"-Xlint:unchecked"
,
"-Xlint:deprecation"
,
"-Xlint:rawtypes"
,
args
.
addAll
(
Arrays
.
asList
(
"-Werror"
,
"-Xlint:unchecked"
,
"-Xlint:deprecation"
,
"-Xlint:rawtypes"
,
"-Xlint:varargs"
));
"-Xlint:varargs"
));
}
}
});
});
}
}
private
void
withOptionalBuildJavaHome
(
Project
project
,
Consumer
<
String
>
consumer
)
{
String
buildJavaHome
=
(
String
)
project
.
findProperty
(
"buildJavaHome"
);
if
(
buildJavaHome
!=
null
&&
!
buildJavaHome
.
isEmpty
())
{
consumer
.
accept
(
buildJavaHome
);
}
}
private
void
configureSpringJavaFormat
(
Project
project
)
{
private
void
configureSpringJavaFormat
(
Project
project
)
{
project
.
getPlugins
().
apply
(
SpringJavaFormatPlugin
.
class
);
project
.
getPlugins
().
apply
(
SpringJavaFormatPlugin
.
class
);
project
.
getTasks
().
withType
(
FormatTask
.
class
,
(
formatTask
)
->
formatTask
.
setEncoding
(
"UTF-8"
));
project
.
getTasks
().
withType
(
FormatTask
.
class
,
(
formatTask
)
->
formatTask
.
setEncoding
(
"UTF-8"
));
...
@@ -228,4 +214,8 @@ class JavaConventions {
...
@@ -228,4 +214,8 @@ class JavaConventions {
.
getByName
(
OptionalDependenciesPlugin
.
OPTIONAL_CONFIGURATION_NAME
).
extendsFrom
(
dependencyManagement
));
.
getByName
(
OptionalDependenciesPlugin
.
OPTIONAL_CONFIGURATION_NAME
).
extendsFrom
(
dependencyManagement
));
}
}
private
void
configureToolchain
(
Project
project
)
{
project
.
getPlugins
().
apply
(
ToolchainPlugin
.
class
);
}
}
}
buildSrc/src/main/java/org/springframework/boot/build/toolchain/ToolchainExtension.java
0 → 100644
View file @
961a34a5
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
build
.
toolchain
;
import
org.gradle.api.Project
;
import
org.gradle.api.provider.Property
;
import
org.gradle.jvm.toolchain.JavaLanguageVersion
;
/**
* DSL extension for {@link ToolchainPlugin}.
*
* @author Christoph Dreis
*/
public
class
ToolchainExtension
{
private
final
Property
<
JavaLanguageVersion
>
maximumCompatibleJavaVersion
;
private
final
JavaLanguageVersion
javaVersion
;
public
ToolchainExtension
(
Project
project
)
{
this
.
maximumCompatibleJavaVersion
=
project
.
getObjects
().
property
(
JavaLanguageVersion
.
class
);
String
toolchainVersion
=
(
String
)
project
.
findProperty
(
"toolchainVersion"
);
this
.
javaVersion
=
(
toolchainVersion
!=
null
)
?
JavaLanguageVersion
.
of
(
toolchainVersion
)
:
null
;
}
public
Property
<
JavaLanguageVersion
>
getMaximumCompatibleJavaVersion
()
{
return
this
.
maximumCompatibleJavaVersion
;
}
JavaLanguageVersion
getJavaVersion
()
{
return
this
.
javaVersion
;
}
}
buildSrc/src/main/java/org/springframework/boot/build/toolchain/ToolchainPlugin.java
0 → 100644
View file @
961a34a5
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
build
.
toolchain
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.gradle.api.Plugin
;
import
org.gradle.api.Project
;
import
org.gradle.api.plugins.JavaPluginExtension
;
import
org.gradle.api.tasks.compile.JavaCompile
;
import
org.gradle.api.tasks.javadoc.Javadoc
;
import
org.gradle.api.tasks.testing.Test
;
import
org.gradle.jvm.toolchain.JavaLanguageVersion
;
import
org.gradle.jvm.toolchain.JavaToolchainSpec
;
/**
* {@link Plugin} for customizing Gradle's toolchain support.
*
* @author Christoph Dreis
*/
public
class
ToolchainPlugin
implements
Plugin
<
Project
>
{
@Override
public
void
apply
(
Project
project
)
{
configureToolchain
(
project
);
}
private
void
configureToolchain
(
Project
project
)
{
ToolchainExtension
toolchain
=
project
.
getExtensions
().
create
(
"toolchain"
,
ToolchainExtension
.
class
,
project
);
JavaLanguageVersion
toolchainVersion
=
toolchain
.
getJavaVersion
();
if
(
toolchainVersion
!=
null
)
{
project
.
afterEvaluate
((
evaluated
)
->
configure
(
evaluated
,
toolchain
));
}
}
private
void
configure
(
Project
project
,
ToolchainExtension
toolchain
)
{
if
(!
isJavaVersionSupported
(
toolchain
,
toolchain
.
getJavaVersion
()))
{
disableToolchainTasks
(
project
);
}
else
{
JavaToolchainSpec
toolchainSpec
=
project
.
getExtensions
().
getByType
(
JavaPluginExtension
.
class
)
.
getToolchain
();
toolchainSpec
.
getLanguageVersion
().
set
(
toolchain
.
getJavaVersion
());
configureJavaCompileToolchain
(
project
,
toolchain
);
configureTestToolchain
(
project
,
toolchain
);
}
}
public
boolean
isJavaVersionSupported
(
ToolchainExtension
toolchain
,
JavaLanguageVersion
toolchainVersion
)
{
return
toolchain
.
getMaximumCompatibleJavaVersion
().
map
((
version
)
->
version
.
canCompileOrRun
(
toolchainVersion
))
.
getOrElse
(
true
);
}
private
void
disableToolchainTasks
(
Project
project
)
{
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
task
)
->
task
.
setEnabled
(
false
));
project
.
getTasks
().
withType
(
Javadoc
.
class
,
(
task
)
->
task
.
setEnabled
(
false
));
project
.
getTasks
().
withType
(
Test
.
class
,
(
task
)
->
task
.
setEnabled
(
false
));
}
private
void
configureJavaCompileToolchain
(
Project
project
,
ToolchainExtension
toolchain
)
{
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
compile
)
->
{
compile
.
getOptions
().
setFork
(
true
);
// See https://github.com/gradle/gradle/issues/15538
List
<
String
>
forkArgs
=
Arrays
.
asList
(
"--add-opens"
,
"jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"
);
compile
.
getOptions
().
getForkOptions
().
getJvmArgs
().
addAll
(
forkArgs
);
});
}
private
void
configureTestToolchain
(
Project
project
,
ToolchainExtension
toolchain
)
{
project
.
getTasks
().
withType
(
Test
.
class
,
(
test
)
->
{
// See https://github.com/spring-projects/spring-ldap/issues/570
List
<
String
>
arguments
=
Arrays
.
asList
(
"--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED"
,
"--illegal-access=warn"
);
test
.
jvmArgs
(
arguments
);
});
}
}
settings.gradle
View file @
961a34a5
...
@@ -31,8 +31,8 @@ rootProject.name="spring-boot-build"
...
@@ -31,8 +31,8 @@ rootProject.name="spring-boot-build"
settings
.
gradle
.
projectsLoaded
{
settings
.
gradle
.
projectsLoaded
{
gradleEnterprise
{
gradleEnterprise
{
buildScan
{
buildScan
{
if
(
settings
.
gradle
.
rootProject
.
hasProperty
(
'
buildJavaHome
'
))
{
if
(
settings
.
gradle
.
rootProject
.
hasProperty
(
'
toolchainVersion
'
))
{
value
(
'
Build Java home'
,
settings
.
gradle
.
rootProject
.
getProperty
(
'buildJavaHome
'
))
value
(
'
Toolchain Version'
,
settings
.
gradle
.
rootProject
.
getProperty
(
'toolchainVersion
'
))
}
}
settings
.
gradle
.
rootProject
.
getBuildDir
().
mkdirs
()
settings
.
gradle
.
rootProject
.
getBuildDir
().
mkdirs
()
...
...
spring-boot-project/spring-boot-cli/build.gradle
View file @
961a34a5
...
@@ -7,6 +7,10 @@ plugins {
...
@@ -7,6 +7,10 @@ plugins {
description
=
"Spring Boot CLI"
description
=
"Spring Boot CLI"
toolchain
{
maximumCompatibleJavaVersion
=
JavaLanguageVersion
.
of
(
15
)
}
configurations
{
configurations
{
dependenciesBom
dependenciesBom
loader
loader
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonbTesterTests.java
View file @
961a34a5
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle
View file @
961a34a5
...
@@ -10,6 +10,10 @@ plugins {
...
@@ -10,6 +10,10 @@ plugins {
description
=
"Spring Boot Gradle Plugin"
description
=
"Spring Boot Gradle Plugin"
toolchain
{
maximumCompatibleJavaVersion
=
JavaLanguageVersion
.
of
(
15
)
}
configurations
{
configurations
{
asciidoctorExtensions
{
asciidoctorExtensions
{
extendsFrom
dependencyManagement
extendsFrom
dependencyManagement
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle
View file @
961a34a5
...
@@ -69,7 +69,7 @@ processResources {
...
@@ -69,7 +69,7 @@ processResources {
}
}
compileJava
{
compileJava
{
if
((!
project
.
hasProperty
(
"
buildJavaHome
"
))
&&
JavaVersion
.
current
()
==
JavaVersion
.
VERSION_1_8
)
{
if
((!
project
.
hasProperty
(
"
toolchainVersion
"
))
&&
JavaVersion
.
current
()
==
JavaVersion
.
VERSION_1_8
)
{
options
.
compilerArgs
+=
[
'-Xlint:-sunapi'
,
'-XDenableSunApiLintControl'
]
options
.
compilerArgs
+=
[
'-Xlint:-sunapi'
,
'-XDenableSunApiLintControl'
]
}
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java
View file @
961a34a5
...
@@ -25,6 +25,8 @@ import java.util.jar.JarFile;
...
@@ -25,6 +25,8 @@ import java.util.jar.JarFile;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.condition.DisabledForJreRange
;
import
org.junit.jupiter.api.condition.JRE
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.boot.loader.tools.FileUtils
;
import
org.springframework.boot.loader.tools.FileUtils
;
...
@@ -247,6 +249,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
...
@@ -247,6 +249,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
});
});
}
}
@DisabledForJreRange
(
min
=
JRE
.
JAVA_16
)
// Remove this once Kotlin supports Java 16
@TestTemplate
@TestTemplate
void
whenAProjectUsesKotlinItsModuleMetadataIsRepackagedIntoBootInfClasses
(
MavenBuild
mavenBuild
)
{
void
whenAProjectUsesKotlinItsModuleMetadataIsRepackagedIntoBootInfClasses
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"jar-with-kotlin-module"
).
execute
((
project
)
->
{
mavenBuild
.
project
(
"jar-with-kotlin-module"
).
execute
((
project
)
->
{
...
...
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