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
8667e9de
Commit
8667e9de
authored
Sep 21, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x' into 2.3.x
Closes gh-23426
parents
d06af28c
581190d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
6 deletions
+33
-6
MainClassConvention.java
...ringframework/boot/gradle/plugin/MainClassConvention.java
+31
-4
GradleCompatibilityExtension.java
...ework/boot/gradle/junit/GradleCompatibilityExtension.java
+2
-2
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/MainClassConvention.java
View file @
8667e9de
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
@@ -18,6 +18,7 @@ package org.springframework.boot.gradle.plugin;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.gradle.plugin;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Callable
;
import
java.util.function.Supplier
;
import
java.util.function.Supplier
;
...
@@ -26,6 +27,7 @@ import org.gradle.api.InvalidUserDataException;
...
@@ -26,6 +27,7 @@ import org.gradle.api.InvalidUserDataException;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
import
org.gradle.api.file.FileCollection
;
import
org.gradle.api.file.FileCollection
;
import
org.gradle.api.plugins.JavaApplication
;
import
org.gradle.api.plugins.JavaApplication
;
import
org.gradle.api.provider.Property
;
import
org.springframework.boot.gradle.dsl.SpringBootExtension
;
import
org.springframework.boot.gradle.dsl.SpringBootExtension
;
import
org.springframework.boot.loader.tools.MainClassFinder
;
import
org.springframework.boot.loader.tools.MainClassFinder
;
...
@@ -54,11 +56,36 @@ final class MainClassConvention implements Callable<Object> {
...
@@ -54,11 +56,36 @@ final class MainClassConvention implements Callable<Object> {
if
(
springBootExtension
!=
null
&&
springBootExtension
.
getMainClassName
()
!=
null
)
{
if
(
springBootExtension
!=
null
&&
springBootExtension
.
getMainClassName
()
!=
null
)
{
return
springBootExtension
.
getMainClassName
();
return
springBootExtension
.
getMainClassName
();
}
}
String
javaApplicationMainClass
=
getJavaApplicationMainClass
();
return
(
javaApplicationMainClass
!=
null
)
?
javaApplicationMainClass
:
resolveMainClass
();
}
@SuppressWarnings
(
"unchecked"
)
private
String
getJavaApplicationMainClass
()
{
JavaApplication
javaApplication
=
this
.
project
.
getConvention
().
findByType
(
JavaApplication
.
class
);
JavaApplication
javaApplication
=
this
.
project
.
getConvention
().
findByType
(
JavaApplication
.
class
);
if
(
javaApplication
!=
null
&&
javaApplication
.
getMainClassName
()
!=
null
)
{
if
(
javaApplication
==
null
)
{
return
null
;
}
Method
getMainClass
=
findMethod
(
JavaApplication
.
class
,
"getMainClass"
);
if
(
getMainClass
!=
null
)
{
try
{
Property
<
String
>
mainClass
=
(
Property
<
String
>)
getMainClass
.
invoke
(
javaApplication
);
return
mainClass
.
getOrElse
(
null
);
}
catch
(
Exception
ex
)
{
// Continue
}
}
return
javaApplication
.
getMainClassName
();
return
javaApplication
.
getMainClassName
();
}
}
return
resolveMainClass
();
private
static
Method
findMethod
(
Class
<?>
type
,
String
name
)
{
for
(
Method
candidate
:
type
.
getMethods
())
{
if
(
candidate
.
getName
().
equals
(
name
))
{
return
candidate
;
}
}
return
null
;
}
}
private
String
resolveMainClass
()
{
private
String
resolveMainClass
()
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java
View file @
8667e9de
...
@@ -45,10 +45,10 @@ public final class GradleCompatibilityExtension implements TestTemplateInvocatio
...
@@ -45,10 +45,10 @@ public final class GradleCompatibilityExtension implements TestTemplateInvocatio
JavaVersion
javaVersion
=
JavaVersion
.
current
();
JavaVersion
javaVersion
=
JavaVersion
.
current
();
if
(
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_14
)
if
(
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_14
)
||
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_13
))
{
||
javaVersion
.
isCompatibleWith
(
JavaVersion
.
VERSION_13
))
{
GRADLE_VERSIONS
=
Arrays
.
asList
(
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"default"
);
GRADLE_VERSIONS
=
Arrays
.
asList
(
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"default"
,
"6.7-rc-1"
);
}
}
else
{
else
{
GRADLE_VERSIONS
=
Arrays
.
asList
(
"5.6.4"
,
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"default"
);
GRADLE_VERSIONS
=
Arrays
.
asList
(
"5.6.4"
,
"6.3"
,
"6.4.1"
,
"6.5.1"
,
"default"
,
"6.7-rc-1"
);
}
}
}
}
...
...
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