This message was deleted.
# community-support
s
This message was deleted.
v
No, of course not. You are talking about hens and eggs. The build script defines how to build that plugin project that has the plugin code as production code. You cannot have the plugin code in its build script.
1
f
Actually, you can, but only with the
kotlin-dsl
. You define your plugin as script plugin instead and then you apply it in your own build script. It will be compiled twice and everything needs to be defined inside the script (with all the downsides), but now you can.
v
I don't get what you mean. If you define it in a script plugin that you apply in the build script, then it is not defined in the build script which was the question.
f
It depends on what the goal of the OP is. If the goal really is to just define in the build script, then, yes, that's simply impossible (and makes little sense). However, if the goal is to build a plugin that is also applied to the current build (common desire) then this is possible in the way I explained. Hacky, but it works.
build.gradle.kts
Copy code
plugins {
    `kotlin-dsl`
}

apply(from = "src/main/kotlin/my-plugin.gradle.kts")
src/main/kotlin/my-plugin.gradle.kts
Copy code
// do something
1
v
Yes my goal was to define it within build script for a very tiny task so it could be visible outside. So, the answer is a NO. @Fleshgrinder I could probably use this hacky way for manual testing I do see that if the plugin is defined inside
buildSrc/src/main/kotlin/myplugin.kt
then it can be applied within the build script of the same project. Ref: https://docs.gradle.org/current/userguide/custom_plugins.html#sec:packaging_a_plugin