GoogleContainerTools/jib · error · IllegalStateException

unknown containerizing mode: ${containerizingMode}

Error message

unknown containerizing mode: ${containerizingMode}

What it means

GradleProjectProperties.createJibContainerBuilder switches on the configured containerizingMode and hits the default branch, throwing IllegalStateException('unknown containerizing mode: ...'). Jib only supports the modes exposed by ContainerizingMode (currently 'exploded' and 'packaged'); any other value fails here.

Source

Thrown at jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java:279

          // Adds class files
          for (File classesOutputDirectory : classesOutputDirectories) {
            javaContainerBuilder.addClasses(classesOutputDirectory.toPath());
          }
          if (classesOutputDirectories.isEmpty()) {
            log(LogEvent.warn("No classes files were found - did you compile your project?"));
          }
          break;

        case PACKAGED:
          // Add a JAR
          Jar jarTask = (Jar) project.getTasks().findByName("jar");
          Path jarPath = jarTask.getArchiveFile().get().getAsFile().toPath();
          log(LogEvent.debug("Using JAR: " + jarPath));
          javaContainerBuilder.addToClasspath(jarPath);
          break;

        default:
          throw new IllegalStateException("unknown containerizing mode: " + containerizingMode);
      }

      return javaContainerBuilder.toContainerBuilder();

    } catch (IOException ex) {
      throw new GradleException("Obtaining project build output files failed", ex);
    }
  }

  @Override
  public List<Path> getClassFiles() throws IOException {
    // TODO: Consolidate with createJibContainerBuilder
    FileCollection classesOutputDirectories =
        getMainSourceSet().getOutput().getClassesDirs().filter(File::exists);
    List<Path> classFiles = new ArrayList<>();
    for (File classesOutputDirectory : classesOutputDirectories) {
      classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk());
    }

View on GitHub (pinned to fb949e2676)

Solutions

  1. Set containerizingMode to exactly 'exploded' or 'packaged'
  2. Check the value with ./gradlew -Pjib.containerizingMode=... for typos; prefer the DSL: jib { containerizingMode = 'packaged' }
  3. Upgrade jib-gradle-plugin if a newer documented mode is needed

Example fix

// before
jib { containerizingMode = 'explode' }
// after
jib { containerizingMode = 'exploded' }
Defensive patterns

Strategy: validation

Validate before calling

def mode = jib.containerizingMode.getOrElse('exploded')
assert mode in ['exploded', 'packaged'] : "unsupported containerizingMode: $mode"

Prevention

When it happens

Trigger: Setting jib.containerizingMode (or the project property jib.containerizingMode) to a typo or unsupported value such as 'packaed', 'explode', or 'war' in a Gradle project, then invoking a task that builds the container builder.

Common situations: Typo in build.gradle or -Pjib.containerizingMode on the command line; copying a Maven-only mode value; older Jib plugin version that predates a mode value used in docs.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/55a0124d35adbaca. Report an issue: GitHub.