apache/iceberg · error · GradleException

Expected a Spark/Scala version combination in Gradle project

Error message

Expected a Spark/Scala version combination in Gradle project name ${it.name}

What it means

The BOM generator in build.gradle iterates over all leaf projects and expects every project under the 'iceberg-spark-' prefix to encode both a Spark and Scala version in its name (matched by sparkScalaPattern). When a project name starts with 'iceberg-spark-' but does not match the expected pattern (e.g. 'iceberg-spark' helper projects or a misnamed module), the build script throws this GradleException while generating the BOM's api dependencies.

Source

Thrown at build.gradle:1270

project(':iceberg-bom') {
  apply plugin: 'java-platform'

  dependencies {
    constraints {
      // The Iceberg-Build builds for only one Scala version at a time, so the BOM would also
      // only contain artifacts for that single Scala version. The following code ensures that
      // the BOM references the artifacts for all Scala versions.
      def sparkScalaPattern = ~"(.*)-([0-9][.][0-9]+)_([0-9][.][0-9]+)"
      def sparkScalaVersions = [
        "3.5": ["2.12", "2.13"],
      ]
      rootProject.allprojects.forEach {
        // Do not include ':iceberg-spark', the bom itself and the root project.
        if (it.name != 'iceberg-bom' && it != rootProject && it.childProjects.isEmpty()) {
          if (it.name.startsWith("iceberg-spark-")) {
            def sparkScalaMatcher = sparkScalaPattern.matcher(it.name)
            if (!sparkScalaMatcher.find()) {
              throw new GradleException("Expected a Spark/Scala version combination in Gradle project name ${it.name}")
            }
            def prjName = sparkScalaMatcher.group(1)
            def sparkVer = sparkScalaMatcher.group(2)
            for (def scalaVer in sparkScalaVersions[sparkVer]) {
              add("api", "${it.group}:$prjName-${sparkVer}_$scalaVer:${it.version}")
            }
          } else {
            add("api", project(it.path))
          }
        }
      }
    }
  }

  // Needed to get the "faked" Scala artifacts into the bom
  javaPlatform { allowDependencies() }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Rename the offending project so it matches 'iceberg-spark-<sparkVersion>_<scalaVersion>', e.g. 'iceberg-spark-3.5_2.12'.
  2. If the project should not appear in the BOM, remove the 'iceberg-spark-' prefix from its name (or exclude it like iceberg-bom/root are excluded).
  3. Check the sparkScalaPattern regex near the throw site to confirm which names are considered valid for your Spark version.

Example fix

// before
project(':iceberg-spark-4.0')
// after
project(':iceberg-spark-4.0_2.13')
Defensive patterns

Strategy: validation

Validate before calling

def matcher = (project.name =~ /^iceberg-spark-(\d+\.\d+)_(\d+\.\d+)$/)  // verify before adding: matcher.matches() must be true for any 'iceberg-spark-*' project

Type guard

static boolean isVersionedSparkProject(String name) { return !name.startsWith('iceberg-spark-') || (name =~ /iceberg-spark-\d+\.\d+_\d+\.\d+/).matches() }

Prevention

When it happens

Trigger: Adding or renaming a project so its name starts with 'iceberg-spark-' but does not match the pattern 'iceberg-spark-<sparkVersion>_<scalaVersion>' (e.g. 'iceberg-spark-runtime' or 'iceberg-spark-4.1' without the Scala suffix), which breaks the sparkScalaMatcher.find() call during BOM generation.

Common situations: Renaming Spark modules without updating build scripts; introducing a new non-versioned Spark subproject; copy-pasting a module definition with a name that accidentally carries the 'iceberg-spark-' prefix.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/6f0c0bff942533d3. Report an issue: GitHub.