Skip to content

Scala2 JDK25 MainClassFinder finds the singleton implementation class name(Main$) along with the correct class name(Main)Β #4461

@gabrieljones

Description

@gabrieljones

Environment:

  • Jib version: 3.5.1
  • Build tool: Gradle: 9.2.1
  • OS: MacOS 15.7.1

Description of the issue:
Projects compiling with Scala 2.13 and Java 25 fail main class inference by discovering both the
Main$ class and the Main class

Expected behavior:
jib discovers single Main class just like scala 3 or scala 2.13 with JDK 21 or JDK 17

Steps to reproduce:

  1. Gradle Project with Scala 2.13 and JDK 25
  2. ./gradlew jibDockerBuild

jib-gradle-plugin Configuration:

plugins {
  scala
  id("com.google.cloud.tools.jib")
}

java {
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(25))
  }
}

scala {
  scalaVersion = "2.13.17"
}

Log output:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':example-scala2-jdk25-container:jibDockerBuild'.
> com.google.cloud.tools.jib.plugins.common.MainClassInferenceException: Multiple valid main classes were found: example.Main$, example.Main, perhaps you should add a `mainClass` configuration to jib

Additional Information:
Relevant Code:
https://github.com/GoogleContainerTools/jib/blob/v3.5.1-gradle/jib-core/src/main/java/com/google/cloud/tools/jib/api/MainClassFinder.java#L179-L192

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions