#4316·jib

Gradle: Allow setting custom sourceset

Author: stashymaneCreated Sep 26, 2024Updated Jun 26, 2026
Labelspriority:p3type: feature request

Environment:

  • Jib version: 3.4.3
  • Build tool: Gradle 8.7

Description of the issue: Currently, the main sourceset is hardcoded into the gradle plugin. With the default Java plugin this works well, however running anything else makes using Jib difficult. My use-case is Kotlin Multiplatform - it does generate a JVM target, however it does not create a main sourceset. This results in Jib throwing an exception:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':server'.
Caused by: org.gradle.api.UnknownDomainObjectException: SourceSet with name 'main' not found.
	at com.google.cloud.tools.jib.gradle.JibPlugin.lambda$apply$9(JibPlugin.java:189)

Having to manually set up the main sourceset as a "mirror" is error-prone and cumbersome. A very simple choice of sourceset in the Jib configuration would solve most issues.

This exact issue was already mentioned in https://github.com/GoogleContainerTools/jib/issues/1778, and even though the issue was closed, only the configuration was allowed to be configurable. The sourceset still isn't.

Source: GoogleContainerTools/jib