This message was deleted.
# community-support
s
This message was deleted.
z
my use case is to create a function like:
Copy code
/**
 * Throws if [this] is the root project
 */
internal fun Project.checkNotRootProject(pluginId: String) { .. }
to avoid accidentally applying a plugin to the root project
t
maybe you could get the plugin meta information from the resources in the jar it was compiled from
not entirely sure how precompiled script plugins are compiled
z
I’m writing the script myself
j
Why do you need the id?
z
to throw a clear error message of which plugin is being applied to the wrong project
c
not aware of how to get the current plugin id; however, the resulting stacktrace will show the offending plugin.
e
kotlin's main-kts script environment injects a
__FILE__
property (or another name if overridden with
@file:ScriptFileLocation("...")
) but gradle doesn't
(that wouldn't really make much sense for a precompiled script plugin that could be executing on a totally different machine anyway)
this is pretty dumb but seems to work from within a precompiled script plugin, when applied:
Copy code
val pluginIdsInThisJar = zipTree(this::class.java.protectionDomain.codeSource.location)
    .matching { include("META-INF/gradle-plugins/*.properties") }
    .getFiles()
    .map { it.nameWithoutExtension }