Missing buildplan on gradle plugin jib extension
Environment:
- Jib version: 3.4.0
- Build tool: Gradle 8.5 RC2 using kotlin script
- OS: Windows 11
Description of the issue:
When we are using the convention to utilize the setting on each module, we cannot set jib.container.format because unresolved reference of com.google.cloud.tools.jib.api.buildplan, causing ImageFormat.OCI or ImageFormat.Docker cannot be customized
Expected behavior:
can set the jib.container.format into enum values of ImageFormat.OCI
Steps to reproduce:
- Setup a multiple module project with gradle kts
- Create a build logic kotlin-dsl
- Use JibExtension
- set jib.container.format
jib-gradle-plugin Configuration:
import com.google.cloud.tools.jib.gradle.JibExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
fun Project.configureJib() {
jib {
to {
image = "my-image:version"
tags = setOf("foo", "bar")
}
container.format = com.google.cloud.tools.jib.api.buildplan.ImageFormat.OCI
}
}
internal fun Project.jib(action: JibExtension.() -> Unit) = extensions.configure(action)
Log output: Cannot access class 'com.google.cloud.tools.jib.api.buildplan.ImageFormat'. Check your module classpath for missing or conflicting dependencies
Additional Information:
The type of jib.container.format is String. Set either 'Docker' or 'OCI'. The BuildPlan is a separate concept, and the Jib plugin configuration is an abstraction on top of it.
https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#container-closure
| Property | Type | Default | Description |
|---|---|---|---|
format |
String |
Docker |
Use OCI to build an OCI container image. |
Environment: Jib version: 3.4.0 Build tool: Gradle 8.5 using kotlin script OS: MacOs Sonoma 4.2 / Ubuntu 22.04.3 IDE: IntelliJ IDEA 2023.3.2 (Ultimate Edition) Build #IU-233.13135.103, built on December 19, 2023
The type of
jib.container.formatisString. Set either'Docker'or'OCI'. The BuildPlan is a separate concept, and the Jib plugin configuration is an abstraction on top of it.
I have the same experience as @muhrifqii. I'm also trying to do this in a gradle convention plugin.
Attempting to set it as a string will result in a type mismatch.
And if I try doing the same in a convention plugin then I get an unresolved reference for buildplan.
Oddly enough, I don't run into the unresolved buildplan package if setting the format in a regular build.gradle.kts script (as opposed to a convention plugin). But then I'm only able to set the value directly using the enum of ImageFormat.Docker (or OCI). Trying to set it as a String results in a type mismatch either way.
Perhaps odder yet is that I'm able to get Jib to work if I leave the format unset (default configuration which is ImageFormat.Docker)
I wonder if it is just IntelliJ that incorrectly reports type mismatch inside the IDE. I would be surprised if running Gradle on the command-line actually fails.
In any case, you can try directly calling setFormat('Docker') inside container.
Closing this as it seems there is a viable workaround. Please reopen with more context if this is still an issue.