diff --git a/plug-in-development/index.html b/plug-in-development/index.html index a814660..c48bfbf 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -275,35 +275,35 @@ interface IProjectAffinity { */ fun affinity(project: Project, context: KobaltContext) : Int } -
- For example, the JavaPlugin implements the ICompilerContributor
interface and then overrides
- the affinity()
method to make sure it gets run for Java projects but ignored for others:
-
+For example, the JavaPlugin implements the ICompilerContributor
interface and then overrides
+the affinity()
method to make sure it gets run for Java projects but ignored for others:
+
override fun affinity(project: Project, context: KobaltContext) = if (project.sourceSuffix == ".java") 1 else 0-
- Directives are functions that users of your plug-in can use in their build file in order to configure your plug-in. These can be any kind of Kotlin function but in the interest of preserving a clean syntax in the build file, it's recommended to use the type safe builder pattern, as described here. -
-
- Imagine that you want to offer a boolean parameter publish
to users of your plug-in, you start by creating a class to hold that parameter:
-
+Directives are functions that users of your plug-in can use in their build file in order to configure your plug-in. These can be any kind of Kotlin function but in the interest of preserving a clean syntax in the build file, it's recommended to use the type safe builder pattern, as described here. +
+
+Imagine that you want to offer a boolean parameter publish
to users of your plug-in, you start by creating a class to hold that parameter:
+
class Info(val publish: Boolean)-
- Next, you create a directive that returns such a class and which also allows to configure it via the type safe builder pattern: -
++Next, you create a directive that returns such a class and which also allows to configure it via the type safe builder pattern: +
@Directive public fun myConfig(init: Info.() -> Unit) = Info().apply { init() }-
- The @Directive
annotation is not enforced but you should always use it in order to help future tools (e.g. an IDEA plug-in) identify Kobalt directives so they can be treated differently from regular Kotlin functions. The code above defines a myConfig
function that accepts a closure as an argument. It creates an Info
- object, calls the init()
function on it (which runs all the code inside that closure) and then return that Info
object.
-
- Users can now specify the following in their build file: +
+The @Directive
annotation is not enforced but you should always use it in order to help future tools (e.g. an IDEA plug-in) identify Kobalt directives so they can be treated differently from regular Kotlin functions. The code above defines a myConfig
function that accepts a closure as an argument. It creates an Info
+object, calls the init()
function on it (which runs all the code inside that closure) and then return that Info
object.
+
+Users can now specify the following in their build file:
// Build.kt