mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-24 03:03:44 +00:00
Fix Gradle Plugin
Fix IncludeCheckRemotePlugin to add the default tasks even without defining the extension properties Issue gh-9846
This commit is contained in:
parent
d5c953b106
commit
87687bf03f
@ -33,8 +33,8 @@ class IncludeCheckRemotePlugin implements Plugin<Project> {
|
|||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
IncludeCheckRemoteExtension extension = project.extensions.create('includeCheckRemote', IncludeCheckRemoteExtension)
|
IncludeCheckRemoteExtension extension = project.extensions.create('includeCheckRemote', IncludeCheckRemoteExtension)
|
||||||
TaskProvider<IncludeRepoTask> includeRepoTask = project.tasks.register('includeRepo', IncludeRepoTask) { IncludeRepoTask it ->
|
TaskProvider<IncludeRepoTask> includeRepoTask = project.tasks.register('includeRepo', IncludeRepoTask) { IncludeRepoTask it ->
|
||||||
it.repository = extension.repository.get()
|
it.repository = extension.repository
|
||||||
it.ref = extension.ref.get()
|
it.ref = extension.ref
|
||||||
}
|
}
|
||||||
project.tasks.register('checkRemote', GradleBuild) {
|
project.tasks.register('checkRemote', GradleBuild) {
|
||||||
it.dependsOn 'includeRepo'
|
it.dependsOn 'includeRepo'
|
||||||
@ -44,22 +44,22 @@ class IncludeCheckRemotePlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract static class IncludeCheckRemoteExtension {
|
abstract static class IncludeCheckRemoteExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git repository to clone
|
* Git repository to clone
|
||||||
*/
|
*/
|
||||||
abstract Property<String> getRepository();
|
String repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git ref to checkout
|
* Git ref to checkout
|
||||||
*/
|
*/
|
||||||
abstract Property<String> getRef();
|
String ref
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task to run in the repository
|
* Task to run in the repository
|
||||||
*/
|
*/
|
||||||
List<String> tasks = ['check']
|
List<String> tasks = ['check']
|
||||||
|
|
||||||
void setTask(List<String> tasks) {
|
|
||||||
this.tasks = tasks
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,4 +97,15 @@ class IncludeCheckRemotePluginTest {
|
|||||||
GradleBuild checkRemote = (GradleBuild) this.rootProject.getTasks().named("checkRemote").get();
|
GradleBuild checkRemote = (GradleBuild) this.rootProject.getTasks().named("checkRemote").get();
|
||||||
assertThat(checkRemote.getDir()).isEqualTo(includeRepo.getOutputDirectory());
|
assertThat(checkRemote.getDir()).isEqualTo(includeRepo.getOutputDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void applyWhenNoExtensionPropertiesThenRegisterTasks() {
|
||||||
|
this.rootProject = ProjectBuilder.builder().build();
|
||||||
|
this.rootProject.getPluginManager().apply(IncludeCheckRemotePlugin.class);
|
||||||
|
IncludeRepoTask includeRepo = (IncludeRepoTask) this.rootProject.getTasks().named("includeRepo").get();
|
||||||
|
GradleBuild checkRemote = (GradleBuild) this.rootProject.getTasks().named("checkRemote").get();
|
||||||
|
assertThat(includeRepo).isNotNull();
|
||||||
|
assertThat(checkRemote).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user