From 28682f4e4b086f2a62c64a9b991f1f37fbc7db7d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 8 Oct 2015 18:34:18 -0700 Subject: [PATCH] Plug-in development. --- .idea/.name | 1 + .idea/compiler.xml | 22 ++ .idea/dictionaries/cbeust.xml | 3 + .idea/inspectionProfiles/Project_Default.xml | 10 + .../inspectionProfiles/profiles_settings.xml | 7 + .idea/kobalt-doc.iml | 9 + .idea/misc.xml | 56 +++ .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 333 ++++++++++++++++++ js/kobalt.js | 8 +- .../index.html | 52 ++- plug-ins/index.html | 2 +- write-plug-in/index.html | 122 ------- 14 files changed, 505 insertions(+), 134 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/dictionaries/cbeust.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/kobalt-doc.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml rename {write-plug-in-10mn => plug-in-development}/index.html (81%) delete mode 100644 write-plug-in/index.html diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..59bb54e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +kobalt-doc \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/cbeust.xml b/.idea/dictionaries/cbeust.xml new file mode 100644 index 0000000..0970b0b --- /dev/null +++ b/.idea/dictionaries/cbeust.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..146ab09 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/kobalt-doc.iml b/.idea/kobalt-doc.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/kobalt-doc.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5f89c25 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..79d86a7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..1b9b853 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + Class structureJava + + + Java + + + + + Android + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/kobalt.js b/js/kobalt.js index f967e9d..94673d2 100644 --- a/js/kobalt.js +++ b/js/kobalt.js @@ -16,12 +16,8 @@ var content = [ title: "Plug-ins" }, { - url: "../write-plug-in-10mn/index.html", - title: "A plug-in in 10mn" - }, - { - url: "../write-plug-in/index.html", - title: "Plug-in development" + url: "../plug-in-development/index.html", + title: "Writing a Kobalt plug-in" } ]; diff --git a/write-plug-in-10mn/index.html b/plug-in-development/index.html similarity index 81% rename from write-plug-in-10mn/index.html rename to plug-in-development/index.html index 06d2f90..a71335a 100644 --- a/write-plug-in-10mn/index.html +++ b/plug-in-development/index.html @@ -45,16 +45,18 @@
-

A Kobalt plug-in in ten minutes

-

This article demonstrates how to wrote a Kobalt plug-in from scratch and have it published on JCenter in less than ten minutes.

+

Plug-in development

+

How to set up your environment to write a Kobalt plug-in.

+

Writing and publishing a plug-in in ten minutes

-In tnis example, we'll write a Kobalt plug-in that simply counts the number of source files and lines in your project. Starting from scratch, we'll have this plug-in published to JCenter and ready to use in ten minutes. +In this example, we'll write a Kobalt plug-in that simply counts the number of source files and lines in your project. + Starting from scratch, we'll have this plug-in published to JCenter and ready to use in ten minutes.

@@ -233,8 +235,47 @@ Found 4972 lines in 65 files And that's it! You can now iterate on your plug-in and upload it with additional ./kobaltw uploadJcenter. This plug-in is available on github.

- +

Debugging a Kobalt plug-in

+

+ 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)
+}
+
+public class Main : BasePlugin(), KobaltLogger {
+// ...
+
+ +

+ Now you can simply create a launch configuration for your main class, which will invoke Kobalt. +

+ +

+ The next step is to have Kobalt invoke your plug-in, so you will have to modify your build file + to call it. As long as you haven't deployed your plug-in to JCenter, you might want to use the + file() directive to declare your dependency, so that Kobalt will use the jar file + on your file system: +

+ +
+val p = plugins(
+    file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.8.jar"))
+)
+
+ +

+ You can now set a breakpoint in your plug-in and launch the configuration you created above. +

+
+ +
+
+ + @@ -249,4 +290,5 @@ And that's it! You can now iterate on your plug-in and upload it with additional --> + diff --git a/plug-ins/index.html b/plug-ins/index.html index c75cdc8..a2e3f1e 100644 --- a/plug-ins/index.html +++ b/plug-ins/index.html @@ -53,7 +53,7 @@
-

Java and Kotlin

+

Java and Kotlin

The Java and Kotlin plug-ins are extremely similar, the only difference is that you configure a Java project with the javaProject directive and a Kotlin project with kotlinProject: diff --git a/write-plug-in/index.html b/write-plug-in/index.html deleted file mode 100644 index 44c12c7..0000000 --- a/write-plug-in/index.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - Kobalt, by Cedric Beust - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - -
-

Plug-in development

-

How to set up your environment to write a Kobalt plug-in.

- -
- - -
- -

Reference project

- -

- As a start up point, you can clone the kobalt-line-count - project and use it as a guide line to write your own plug-in. -

- -

Build file

- -

- You can start with a simple build file: -

- -
-import com.beust.kobalt.*
-import com.beust.kobalt.plugin.packaging.*
-import com.beust.kobalt.plugin.kotlin.*
-import com.beust.kobalt.plugin.publish.*
-
-
-val project = kotlinProject {
-    name = "kobalt-line-count"
-    group = "com.beust.kobalt"
-    artifactId = name
-    version = "0.1"
-
-    dependencies {
-        compile("com.beust:kobalt:0.154")
-    }
-}
-
-val packProject = assemble(project) {
-    mavenJars {
-        manifest {
-            attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.Main")
-        }
-    }
-}
-
-val jc = jcenter(project) {
-    publish = true
-}
-          
- -
- - -
-
- - - - - - - - - - - - -