1
0
Fork 0
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:
Cedric Beust 2016-03-30 21:54:49 -08:00
parent 8d692d2b89
commit f66515efe6
4 changed files with 28 additions and 1 deletions

View file

@ -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)

View file

@ -12,6 +12,8 @@ abstract class BasePlugin : IPlugin {
this.context = context
}
override fun shutdown() {}
override lateinit var taskManager: TaskManager
lateinit var plugins: Plugins
}

View file

@ -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
}