diff --git a/plug-in-development/index.html b/plug-in-development/index.html index 9c25295..bb88785 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -395,25 +395,49 @@ kobalt-line-count:exampleTask
Properties are the mechanism that plug-ins can use to export values and also read values that other
- plug-ins have exported. The PluginProperties
instance can be found on the KobaltContext
+ plug-ins have exported. There are two kinds of properties that plug-ins can manipulate:
+
+ Project
instances have a property called projectProperties
that is an
+ instance of the ProjectProperties
class. Plugins can put and get values on this
+ object in order to store project specific properties.
+
+fun taskAssemble(project: Project) : TaskResult { + project.projectProperties.put(PACKAGES, packages) ++
+ The PluginProperties
instance can be found on the KobaltContext
object that your plug-in receives in its apply()
method. Once you have an instance of this
class, you can read or write variables into it:
override fun apply(project: Project, context: KobaltContext) { // Export a property for other plug-ins to use - context.pluginProperties.put(name, BUILD_DIR, project.buildDirectory) + context.pluginProperties.put(PLUGIN_NAME, "somePluginProperty", "someValue") // Read a property from another plug-in - val sourceDir = context.pluginProperties.get("somePlugin", "someProperty") + val sourceDir = context.pluginProperties.get("pluginName", "somePluginProperty") }-
- Plug-ins that define properties should annotate them with the @ExportedProperty
annotation:
+
+
+ Plug-ins that define properties should annotate them with the @ExportedPluginProperty
or
+ @ExportedProjectProperty
annotation:
companion object { - @ExportedProperty + @ExportedProjectProperty const val BUILD_DIR = "buildDir"