Laurence Gonsalves
04/22/2024, 6:56 AMLaurence Gonsalves
04/22/2024, 6:57 AM├── buildSrc
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
│ ├── src
│ │ ├── main
│ │ │ └── kotlin
│ │ │ ├── myproject.java-conventions.gradle.kts
│ │ │ └── myproject.library-conventions.gradle.kts
I have another build in a separate repo where I also need to use one of these convention plugins, let's say myproject.java-conventions
. I've found that I can publish all of buildSrc as a single artifact by applying maven-publish in buildSrc/build.gradle.kts
, and then in the consuming build doing this:
// settings.gradle.kts
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "myproject") {
val version = checkNotNull(requested.version) { "No version specified for plugin $requested"}
useModule("com.mygroup:buildSrc:$version")
}
}
}
}
# version catalog
[plugins]
myproject-java-conventions = { id = "myproject.java-convention", version.ref = "myproject" }
// build.gradle.kts
plugins {
alias(libs.plugins.myproject.java.conventions)
}
Is this the cleanest/simplest way to do this? Or is there some way to remove the need for the custom resolutionStrategy
without adding equal or greater complexity elsewhere?Vampire
04/22/2024, 8:05 AMLaurence Gonsalves
04/24/2024, 5:28 AM:buildSrc:publishPluginMavenPublicationToMyRepository
would omit the plugin marker artifacts. I switched to :buildSrc:publishAllPublicationsToMyRepository
.