blubb
08/05/2025, 2:02 PMblubb
08/05/2025, 2:04 PMplugins {
java
id("my-convention")
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation("com.example.tools:my-gradle-convention-plugins:0-SNAPSHOT")
}
Vampire
08/05/2025, 2:05 PMmavenLocal()
is almost always a bad idea as it is broken by design in Maven already and you should at most use it as last in the list of repositories and optimally with a repository content filter if you need it at all.
To just the current state of a plugin in a local project, it is usually better to use a composite build instead of publishing the plugin to a local maven repository.Vampire
08/05/2025, 2:06 PMDoes that look right?No, besides the problems with
mavenLocal()
I just mentioned, you add the plugin as production dependency for your project, that might be correct if that project is building another Gradle plugin that uses that plugin, but not if you want to apply that plugin.Vampire
08/05/2025, 2:07 PMVampire
08/05/2025, 2:07 PMblubb
08/05/2025, 2:08 PMblubb
08/05/2025, 2:09 PMVampire
08/05/2025, 2:11 PMVampire
08/05/2025, 2:11 PMblubb
08/05/2025, 2:16 PMVampire
08/05/2025, 2:18 PM<plugin id>:<plugin id>.gradle.plugin:<plugin version>
blubb
08/05/2025, 2:26 PMblubb
08/05/2025, 2:28 PMplugins {
`kotlin-dsl`
`maven-publish`
}
group = "com.example.tools"
version = "0-SNAPSHOT"
src/main/kotin/com.exampl.tools.my-convention.kts
tasks.register("hello") {
println("Hello from convention plugin")
}
Vampire
08/05/2025, 2:29 PMI though I could do the same with the conventional plugin and use it in the other projects like my other artifacts.Yes, you can do that, no problem. Just for testing it is much more convenient to use a composite build instead of
mavenLocal()
.blubb
08/05/2025, 2:44 PMVampire
08/05/2025, 2:45 PMblubb
08/05/2025, 2:46 PMVampire
08/05/2025, 2:48 PMmavenLocal()
as plugin repository and because your plugin ID does not match.Vampire
08/05/2025, 2:48 PMblubb
08/05/2025, 2:50 PMVampire
08/05/2025, 2:55 PMpublishToMavenLocal
and add mavenLocal()
as plugin repository in the consumer, having more effort from then on,
or whether you add an includeBuild
call to the setting script of the consumer and everything just works more conveniently.blubb
08/05/2025, 2:56 PMbuildSrc
folderVampire
08/05/2025, 2:56 PM--include-build
there, but it is better for IDE support to do it in the settings scriptVampire
08/05/2025, 2:56 PMbuildSrc
is not an included build at allVampire
08/05/2025, 2:57 PMblubb
08/05/2025, 2:58 PMinclude("app", "../my-gradle-convention-plugins")
like thisVampire
08/05/2025, 2:59 PMVampire
08/05/2025, 2:59 PMìncludeBuild
as I mentioned.
And as it is about a Gradle plugin, within pluginManagement { ... }
Vampire
08/05/2025, 3:00 PMblubb
08/05/2025, 3:01 PMincludeBuild
😛Vampire
08/05/2025, 3:01 PMVampire
08/05/2025, 3:01 PMVampire
08/05/2025, 3:03 PMblubb
08/05/2025, 3:04 PMblubb
08/05/2025, 3:05 PMVampire
08/05/2025, 3:06 PMblubb
08/05/2025, 3:07 PMVampire
08/05/2025, 3:07 PMVampire
08/05/2025, 3:08 PMblubb
08/05/2025, 3:23 PMblubb
08/05/2025, 3:25 PMVampire
08/05/2025, 3:25 PMmavenLocal()
or getting it running with composite build?
The latter is actually much easier then the former.Vampire
08/05/2025, 3:26 PMI cannot figure out how that id is definedThe ID is the file-name minus the
.gradle.kts
so from what you showed, the plugin ID is com.exampl.tools.my-convention
Vampire
08/05/2025, 3:26 PMVampire
08/05/2025, 3:27 PMVampire
08/05/2025, 3:27 PM.gradle
in front of the .kts
Vampire
08/05/2025, 3:28 PMblubb
08/05/2025, 3:29 PMblubb
08/05/2025, 3:30 PMcom.example.tools.my-convention.gradle.kts
Vampire
08/05/2025, 3:30 PMAnd I need to use plugin java-gradle-plugin I guess?No, the
kotlin-dsl
plugin already applies that for youblubb
08/05/2025, 3:32 PM.m2/repository/com/example/tools/my-convention/com.example.tools.my-convention.gradle.plugin
Vampire
08/05/2025, 3:33 PMblubb
08/05/2025, 3:38 PMblubb
08/05/2025, 3:38 PMVampire
08/05/2025, 3:38 PMblubb
08/05/2025, 3:38 PM