From 01b8f31dec0093b999b80a7643ef387668405749 Mon Sep 17 00:00:00 2001
From: Cedric Beust
Date: Sat, 7 Nov 2015 19:13:36 -0800
Subject: [PATCH] Links.
---
plug-in-development/index.html | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/plug-in-development/index.html b/plug-in-development/index.html
index 86c12f8..a258218 100644
--- a/plug-in-development/index.html
+++ b/plug-in-development/index.html
@@ -58,10 +58,10 @@
Kobalt plug-ins are usually made of several parts:
- - plugin.xml. A file that describes all the components of your plug-in, such as contributors.
- - Directives. Kotlin functions that users of your plug-in can invoke in their build file, such as
kotlinProject
or dependencies
. These functions typically configure some data that your plug-in will later use to perform its functions.
- - Tasks. These tasks are invoked from the command line and ask your plug-ins to perform certain actions.
- - Properties. Plug-ins can export properties and read properties from other plug-ins.
+ - plugin.xml. A file that describes all the components of your plug-in, such as contributors.
+ - Directives. Kotlin functions that users of your plug-in can invoke in their build file, such as
kotlinProject
or dependencies
. These functions typically configure some data that your plug-in will later use to perform its functions.
+ - Tasks. These tasks are invoked from the command line and ask your plug-ins to perform certain actions.
+ - Properties. Plug-ins can export properties and read properties from other plug-ins.
@@ -382,6 +382,32 @@ kobalt-line-count:clean
kobalt-line-count:compile
kobalt-line-count:exampleTask
+
+Properties
+
+ 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
+ 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)
+
+ // Read a property from another plug-in
+ val sourceDir = context.pluginProperties.get("somePlugin", "someProperty")
+}
+
+
+ Plug-ins that define properties should annotate them with the @ExportedProperty
annotation:
+
+
+ companion object {
+ @ExportedProperty
+ const val BUILD_DIR = "buildDir"
+
+