Slackbot
11/20/2023, 12:06 PMVampire
11/20/2023, 12:10 PMVampire
11/20/2023, 12:11 PMVampire
11/20/2023, 12:11 PMOleg Nenashev
11/20/2023, 12:18 PMbuildSrc etc. But anyway, I am happy if it works and supportedOleg Nenashev
11/20/2023, 12:20 PMOleg Nenashev
11/21/2023, 9:00 AMgradlePlugin does not get a group ID. Moreover, these additions are called after plugins.register() so I cannot just remove previous definition and re-define the plugin like this one
gradlePlugin {
website = "<https://github.com/wiremock/gradle-wiremock-extension-plugins>"
vcsUrl = "<https://github.com/wiremock/gradle-wiremock-extension-plugins>"
plugins {
removeIf { it.id.equals("wiremock-extension-convention") }
register("wiremock-extension-convention") {
id = "org.wiremock.tools.gradle.wiremock-extension-convention"
implementationClass = "WiremockExtensionConventionPlugin"
displayName = "Gradle convention plugin that bundles common packaging and release logic for WireMock extensions"
description = "Gradle convention plugin for WireMock Extensions"
tags = listOf("wiremock")
}
}
}Oleg Nenashev
11/21/2023, 9:02 AMafterEvaluate() hack actually worked...
plugins {
afterEvaluate {
removeIf { it.id.equals("wiremock-extension-convention") }
register("wiremock-extension-convention") {
id = "org.wiremock.tools.gradle.wiremock-extension-convention"
implementationClass = "WiremockExtensionConventionPlugin"
displayName = "Gradle convention plugin that bundles common packaging and release logic for WireMock extensions"
description = "Gradle convention plugin for WireMock Extensions"
tags = listOf("wiremock")
}
}
}Vampire
11/21/2023, 9:04 AMafterEvaluate.
And also don`t use plugins.register why should you? For precompiled script plugins everything is setup automatically.Oleg Nenashev
11/21/2023, 9:05 AMVampire
11/21/2023, 9:05 AMorg.wiremock.tools.gradle.wiremock-extension-convention just name the file org.wiremock.tools.gradle.wiremock-extension-convention.gradleVampire
11/21/2023, 9:05 AMVampire
11/21/2023, 9:06 AMOleg Nenashev
11/21/2023, 9:07 AMOleg Nenashev
11/21/2023, 9:08 AMOleg Nenashev
11/21/2023, 9:09 AMVampire
11/21/2023, 9:10 AMto make it more clearThis is not clear enough? :-)
To apply a precompiled script plugin, you need to know its ID which is derived from the plugin script’s filename (minus theextension) and its (optional) package declaration..gradle.kts
For example, the scriptwould have a plugin ID ofsrc/main/kotlin/java-library-convention.gradle.kts(assuming it has no package declaration). Likewise,java-library-conventionwould result in a plugin ID ofsrc/main/kotlin/my/java-library-convention.gradle.ktsas long as it has a package declaration ofmy.java-library-convention.my
It is helpful to have tags & coJust configure the plugin that is registered for you.
Oleg Nenashev
11/21/2023, 9:13 AMThis is not clear enough? 🙂Whell that's only for Kotlin 🙂
Oleg Nenashev
11/21/2023, 9:17 AMafterEvaluate
Execution failed for task ':publishPlugins'.
> Plugin 'org.wiremock.tools.gradle.wiremock-extension-convention' has no 'displayName' property setVampire
11/21/2023, 9:40 AMWhell that's only for Kotlin 🙂Just because Kotlin is the default DSL and I have the docs in Kotlin mode, sorry. Switch it to Groovy mode in any of the example blocks and you have
To apply a precompiled script plugin, you need to know its ID which is derived from the plugin script’s filename (minus theextension)..gradle
For example, the script🙂would have a plugin ID ofsrc/main/groovy/java-library-convention.gradle. Likewise,java-library-conventionwould result in a plugin ID ofsrc/main/groovy/my.java-library-convention.gradle.my.java-library-convention
Oleg Nenashev
11/21/2023, 9:42 AMOleg Nenashev
11/21/2023, 9:43 AMVampire
11/21/2023, 9:52 AMAnyway it doesn't work with the current version of Gradle Plugin that actually requires display name & Co to be set. It is an easy fix on the plug-in side I guess, but for now I just want to keep work around until later work everything to kotlin anywayLet me ask again, why don't you just configure the plugin the was registered for you without using
afterEvaluate?
The main thing afterEvaluate does is adding timing problems, ordering problems, race conditions, and clutter, and it should be avoided wherever possible.Vampire
11/21/2023, 9:54 AMgradlePlugin {
plugins.matching { it.id == "org.wiremock.tools.gradle.wiremock-extension-convention" }.configureEach {
displayName = "If you're happy and you know it clap your hands"
}
}Vampire
11/21/2023, 9:54 AMWould it be possible to approve the plugin hosting with such a workaround for testing purposes? The plug-in metadata is correct from what I see in the build results, so I think it would be okayI'm not sure what you mean
Vampire
11/21/2023, 9:55 AMafterEvaluate in the build building it, I highly doubt that this would have any influence. You are just shooting yourself in the foot. But I have no idea, I'm not affiliated to Gradle in any way.Oleg Nenashev
11/21/2023, 10:00 AMYou are just shooting yourself in the foot. But I have no idea, I'm not affiliated to Gradle in any wayTemporary for prototyping. The plugin will be moved to Kotlin and then reworked to classes
```gradlePlugin {
plugins.matching { it.id == "org.wiremock.tools.gradle.wiremock-extension-convention" }.configureEach {
displayName = "If you're happy and you know it clap your hands"
}
}```I tried that, but the plugins container is empty at that point. I guess script hooks are called later, so it would need some additional tampering with task dependencies
Vampire
11/21/2023, 10:07 AMplugins.matching { ... }.configureEach { ... } also configures things added in the future like for any other named domain object container.Oleg Nenashev
11/21/2023, 10:10 AMOleg Nenashev
11/22/2023, 11:52 AMgradlePlugin {
website = "<https://github.com/wiremock/gradle-wiremock-extension-plugins>"
vcsUrl = "<https://github.com/wiremock/gradle-wiremock-extension-plugins>"
plugins.matching { it.id == "org.wiremock.tools.gradle.wiremock-extension-convention" }.configureEach {
displayName = "Gradle convention plugin that bundles common packaging and release logic for WireMock extensions"
description = "Gradle convention plugin for WireMock Extensions"
tags = listOf("wiremock")
}
}Oleg Nenashev
11/22/2023, 11:52 AM> Task :publishPlugins FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishPlugins'.
> Plugin 'org.wiremock.tools.gradle.wiremock-extension-convention' has no 'displayName' property setVampire
11/22/2023, 12:30 PMit.id, but on it.name.
For those generated plugin declarations the plugin id is also used as name and the matching is done as soon as the object is added to the plugins container and before the precompiled Groovy script plugin plugin had the chance to set the id field.
But the name is already present.
So with it.name == "org.wiremock.tools.gradle.wiremock-extension-convention" it should work as expected.