mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Introduce IPlugin#shutdown.
This commit is contained in:
parent
8d692d2b89
commit
f66515efe6
4 changed files with 28 additions and 1 deletions
|
@ -47,6 +47,8 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
|
|||
fun findPlugin(name: String) : IPlugin? = pluginMap[name]
|
||||
}
|
||||
|
||||
fun shutdownPlugins() = plugins.forEach { it.shutdown() }
|
||||
|
||||
fun applyPlugins(context: KobaltContext, projects: List<Project>) {
|
||||
plugins.forEach { plugin ->
|
||||
addPluginInstance(plugin)
|
||||
|
|
|
@ -12,6 +12,8 @@ abstract class BasePlugin : IPlugin {
|
|||
this.context = context
|
||||
}
|
||||
|
||||
override fun shutdown() {}
|
||||
|
||||
override lateinit var taskManager: TaskManager
|
||||
lateinit var plugins: Plugins
|
||||
}
|
||||
|
|
|
@ -2,9 +2,29 @@ package com.beust.kobalt.api
|
|||
|
||||
import com.beust.kobalt.internal.TaskManager
|
||||
|
||||
public interface IPlugin : IPluginActor {
|
||||
interface IPlugin : IPluginActor {
|
||||
/**
|
||||
* The name of this plug-in.
|
||||
*/
|
||||
val name: String
|
||||
|
||||
/**
|
||||
* @return true if this plug-in decided it should be enabled for this project.
|
||||
*/
|
||||
fun accept(project: Project) : Boolean
|
||||
|
||||
/**
|
||||
* Invoked on all plug-ins before the Kobalt execution stops.
|
||||
*/
|
||||
fun shutdown()
|
||||
|
||||
/**
|
||||
* Main entry point for a plug-in to initialize itself based on a project and a context.
|
||||
*/
|
||||
fun apply(project: Project, context: KobaltContext) {}
|
||||
|
||||
/**
|
||||
* Injected by Kobalt to manage tasks.
|
||||
*/
|
||||
var taskManager : TaskManager
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue