Hi, I’ve got a question regarding task / extension configuration. We’re using jib in our multi-module build and in order to avoid duplicating the configuration in every module (majority of the configuration is the same, but there are some differences so we can’t reuse them without overwriting these differences), I am attempting to move the configuration to buildSrc
and then either configuring or overwriting parts of the configuration in build.gradle.kts
files of specific modules.
So, let’s say my jib configuration is the same for all modules, except for the image
option, where I have to pass a different service name for each module
- The “common” convention configuration in
buildSrc
folder:
// buildSrc/src/main/kotlin/com.acme.jib-configuration.gradle.kts
plugins {
id("com.google.cloud.tools.jib")
}
jib {
val serviceName = // how do I pass the service name variable from a submodule here?
to {
image = "europe-west1-docker-pkg.dev/something/$serviceName
}
...
}
- A
build.gradle.kts
of one of my modules
// someModule/build.gradle.kts
plugins {
id("com.acme.jib-configuration")
}
dependencies {
....
}
jib {
// I imagine I would have to pass the serviceName value here somehow
}
I’ve been exploring how to do this with extra
, but I haven’t managed to get it to work. Looking at this, I have a feeling I’m approaching this with an incorrect approach, because it feels like something that should be easily done.
My question is, where am I going wrong in my approach? Should I instead define a task inside buildSrc
that configures the jib
extension and then I call it in each submodule with the parameters that I need for that module? Should I define a custom plugin for this? I imagine that if we want to make the configuration for jib
common among all our projects, making it a custom plugin is a prerequisite?
Any pointer into the right direction would be helpful, I feel like I’m just around the corner from the correct solution but I’m approaching it from the wrong perspective.
Kind regards