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
5fdb2ae2
Commit
5fdb2ae2
authored
Dec 16, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect PluginApplicationActions against absent plugin classes
Closes gh-24526
parent
38e4c2a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
KotlinPluginAction.java
...pringframework/boot/gradle/plugin/KotlinPluginAction.java
+2
-9
PluginApplicationAction.java
...framework/boot/gradle/plugin/PluginApplicationAction.java
+6
-4
SpringBootPlugin.java
.../springframework/boot/gradle/plugin/SpringBootPlugin.java
+13
-4
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java
View file @
5fdb2ae2
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -47,15 +47,8 @@ class KotlinPluginAction implements PluginApplicationAction {
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
Class
<?
extends
Plugin
<?
extends
Project
>>
getPluginClass
()
{
try
{
return
(
Class
<?
extends
Plugin
<?
extends
Project
>>)
Class
.
forName
(
"org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper"
);
}
catch
(
Throwable
ex
)
{
return
null
;
}
return
KotlinPluginWrapper
.
class
;
}
}
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/PluginApplicationAction.java
View file @
5fdb2ae2
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -30,9 +30,11 @@ interface PluginApplicationAction extends Action<Project> {
/**
* The class of the {@code Plugin} that, when applied, will trigger the execution of
* this action. May return {@code null} if the plugin class is not on the classpath.
* @return the plugin class or {@code null}
* this action.
* @return the plugin class
* @throws ClassNotFoundException if the plugin class cannot be found
* @throws NoClassDefFoundError if an error occurs when defining the plugin class
*/
Class
<?
extends
Plugin
<?
extends
Project
>>
getPluginClass
();
Class
<?
extends
Plugin
<?
extends
Project
>>
getPluginClass
()
throws
ClassNotFoundException
,
NoClassDefFoundError
;
}
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java
View file @
5fdb2ae2
...
...
@@ -18,6 +18,7 @@ package org.springframework.boot.gradle.plugin;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
org.gradle.api.GradleException
;
import
org.gradle.api.Plugin
;
...
...
@@ -119,10 +120,18 @@ public class SpringBootPlugin implements Plugin<Project> {
new
WarPluginAction
(
singlePublishedArtifact
),
new
MavenPluginAction
(
bootArchives
.
getUploadTaskName
()),
new
DependencyManagementPluginAction
(),
new
ApplicationPluginAction
(),
new
KotlinPluginAction
());
for
(
PluginApplicationAction
action
:
actions
)
{
Class
<?
extends
Plugin
<?
extends
Project
>>
pluginClass
=
action
.
getPluginClass
();
if
(
pluginClass
!=
null
)
{
project
.
getPlugins
().
withType
(
pluginClass
,
(
plugin
)
->
action
.
execute
(
project
));
}
withPluginClassOfAction
(
action
,
(
pluginClass
)
->
project
.
getPlugins
().
withType
(
pluginClass
,
(
plugin
)
->
action
.
execute
(
project
)));
}
}
private
void
withPluginClassOfAction
(
PluginApplicationAction
action
,
Consumer
<
Class
<?
extends
Plugin
<?
extends
Project
>>>
consumer
)
{
try
{
consumer
.
accept
(
action
.
getPluginClass
());
}
catch
(
Throwable
ex
)
{
// Plugin class unavailable. Continue.
}
}
...
...
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