From e5289f0bace6e63df506401ba1eab2bb36c6476e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 29 Mar 2016 22:28:17 -0800 Subject: [PATCH] Document plug-in development. --- plug-in-development/index.html | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/plug-in-development/index.html b/plug-in-development/index.html index 1d502bb..acaf433 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -45,7 +45,52 @@ If you are curious to get a quick feel for what a Kobalt plug-in looks like, I s write and publish a plug-in in ten minutes and then you can come back here and keep reading.

+

Setting up IDEA

+

+ The simplest way to run your plug-in in your IDE is to create a main function in the main class of your + plug-in as follows: +

+
+fun main(argv: Array<String>) {
+    com.beust.kobalt.main(argv)
+}
+
+

+ In order for this code to compile, you will have to switch the dependency of your plug-in from + kobalt-plugin-api to just kobalt, which is the actual application (and which + therefore contains the main() entry point). +

+
+        // Normal dependency
+        compile("com.beust:kobalt-plugin-api:$KOBALT_VERSION")
 
+        // Development dependency
+        compile("com.beust:kobalt:$KOBALT_VERSION")
+
+

+ You might find it convenient to leverage Kobalt's ability to use regular Kotlin variables to make things easier: +

+
+val dev = false
+val kobaltDependency = if (dev) "kobalt" else "kobalt-plugin-api"
+
+val p = project {
+    // ...
+
+    compile("com.beust:$kobaltDependency:$KOBALT_VERSION")
+}
+
+

+ Then you can simply set the dev to true during development and back to false + when you are ready to publish your plug-in. + +

+

+ Then resync your build file in IDEA and your main() function should now build and be launchable. + You can right click on that class file and select "Debug <your class name>", which will launch Kobalt + with your plug-in. You can set a breakpoint in one of your tasks or anywhere that gets invoked. Don't forget + to invoke this launch configuration with the regular parameters passed to Kobalt (e.g. "assemble"). +

Plug-in architecture