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
e599ed01
Commit
e599ed01
authored
Feb 14, 2020
by
dreis2211
Committed by
Andy Wilkinson
Feb 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Gradle tasks to be executed with a custom Java home
See gh-20179
parent
ea66940b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
ConventionsPlugin.java
...ava/org/springframework/boot/build/ConventionsPlugin.java
+23
-2
No files found.
buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java
View file @
e599ed01
...
@@ -127,14 +127,27 @@ public class ConventionsPlugin implements Plugin<Project> {
...
@@ -127,14 +127,27 @@ public class ConventionsPlugin implements Plugin<Project> {
project
.
setProperty
(
"sourceCompatibility"
,
"1.8"
);
project
.
setProperty
(
"sourceCompatibility"
,
"1.8"
);
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
compile
)
->
{
project
.
getTasks
().
withType
(
JavaCompile
.
class
,
(
compile
)
->
{
compile
.
getOptions
().
setEncoding
(
"UTF-8"
);
compile
.
getOptions
().
setEncoding
(
"UTF-8"
);
if
(
hasCustomBuildJavaHome
(
project
))
{
String
javaExecutable
=
getCustomBuildJavaExecutable
(
project
,
"/bin/java"
);
compile
.
getOptions
().
getForkOptions
().
setJavaHome
(
new
File
(
javaExecutable
));
}
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"
);
}
}
});
});
project
.
getTasks
().
withType
(
Javadoc
.
class
,
project
.
getTasks
().
withType
(
Javadoc
.
class
,
(
javadoc
)
->
{
(
javadoc
)
->
javadoc
.
getOptions
().
source
(
"1.8"
).
encoding
(
"UTF-8"
));
javadoc
.
getOptions
().
source
(
"1.8"
).
encoding
(
"UTF-8"
);
if
(
hasCustomBuildJavaHome
(
project
))
{
String
javaExecutable
=
getCustomBuildJavaExecutable
(
project
,
"/bin/javadoc"
);
javadoc
.
setExecutable
(
javaExecutable
);
}
});
project
.
getTasks
().
withType
(
Test
.
class
,
(
test
)
->
{
project
.
getTasks
().
withType
(
Test
.
class
,
(
test
)
->
{
if
(
hasCustomBuildJavaHome
(
project
))
{
String
javaExecutable
=
getCustomBuildJavaExecutable
(
project
,
"/bin/java"
);
test
.
setExecutable
(
javaExecutable
);
}
test
.
useJUnitPlatform
();
test
.
useJUnitPlatform
();
test
.
setMaxHeapSize
(
"1024M"
);
test
.
setMaxHeapSize
(
"1024M"
);
});
});
...
@@ -192,6 +205,14 @@ public class ConventionsPlugin implements Plugin<Project> {
...
@@ -192,6 +205,14 @@ public class ConventionsPlugin implements Plugin<Project> {
return
legalFile
;
return
legalFile
;
}
}
private
boolean
hasCustomBuildJavaHome
(
Project
project
)
{
return
project
.
hasProperty
(
"buildJavaHome"
)
&&
!((
String
)
project
.
property
(
"buildJavaHome"
)).
isEmpty
();
}
private
String
getCustomBuildJavaExecutable
(
Project
project
,
String
executable
)
{
return
project
.
property
(
"buildJavaHome"
)
+
executable
;
}
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"
));
...
...
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