mirror of
https://github.com/ethauvin/kobalt-doc.git
synced 2025-04-25 03:57:11 -07:00
Document plug-in development.
This commit is contained in:
parent
8f452d950b
commit
e5289f0bac
1 changed files with 45 additions and 0 deletions
|
@ -45,7 +45,52 @@ If you are curious to get a quick feel for what a Kobalt plug-in looks like, I s
|
|||
<a href="../ten-minutes/index.html">write and publish a plug-in in ten minutes</a> and then you can come back here
|
||||
and keep reading.
|
||||
</p>
|
||||
<h2 class="section" id="idea-set-up">Setting up IDEA</h2>
|
||||
<p>
|
||||
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:
|
||||
</p>
|
||||
<pre class="brush:java">
|
||||
fun main(argv: Array<String>) {
|
||||
com.beust.kobalt.main(argv)
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
In order for this code to compile, you will have to switch the dependency of your plug-in from
|
||||
<code>kobalt-plugin-api</code> to just <code>kobalt</code>, which is the actual application (and which
|
||||
therefore contains the <code>main()</code> entry point).
|
||||
</p>
|
||||
<pre class="brush:java">
|
||||
// Normal dependency
|
||||
compile("com.beust:kobalt-plugin-api:$KOBALT_VERSION")
|
||||
|
||||
// Development dependency
|
||||
compile("com.beust:kobalt:$KOBALT_VERSION")
|
||||
</pre>
|
||||
<p>
|
||||
You might find it convenient to leverage Kobalt's ability to use regular Kotlin variables to make things easier:
|
||||
</p>
|
||||
<pre class="brush:java">
|
||||
val dev = false
|
||||
val kobaltDependency = if (dev) "kobalt" else "kobalt-plugin-api"
|
||||
|
||||
val p = project {
|
||||
// ...
|
||||
|
||||
compile("com.beust:$kobaltDependency:$KOBALT_VERSION")
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
Then you can simply set the <code>dev</code> to <code>true</code> during development and back to <code>false
|
||||
</code> when you are ready to publish your plug-in.
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
Then resync your build file in IDEA and your <code>main()</code> 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. <code>"assemble"</code>).
|
||||
</p>
|
||||
<h2 class="section" id="philosophy">Plug-in architecture</h3>
|
||||
<p>
|
||||
<p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue