jib icon indicating copy to clipboard operation
jib copied to clipboard

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

Open gabrieljones opened this issue 3 months ago • 0 comments

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

gabrieljones avatar Nov 19 '25 15:11 gabrieljones