{"record":{"id":"6f0c0bff942533d3","repo":"apache/iceberg","slug":"expected-a-spark-scala-version-combination-in-grad","errorCode":null,"errorMessage":"Expected a Spark/Scala version combination in Gradle project name ${it.name}","messagePattern":"Expected a Spark/Scala version combination in Gradle project name (.+?)","errorType":"console","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build.gradle","lineNumber":1270,"sourceCode":"project(':iceberg-bom') {\n  apply plugin: 'java-platform'\n\n  dependencies {\n    constraints {\n      // The Iceberg-Build builds for only one Scala version at a time, so the BOM would also\n      // only contain artifacts for that single Scala version. The following code ensures that\n      // the BOM references the artifacts for all Scala versions.\n      def sparkScalaPattern = ~\"(.*)-([0-9][.][0-9]+)_([0-9][.][0-9]+)\"\n      def sparkScalaVersions = [\n        \"3.5\": [\"2.12\", \"2.13\"],\n      ]\n      rootProject.allprojects.forEach {\n        // Do not include ':iceberg-spark', the bom itself and the root project.\n        if (it.name != 'iceberg-bom' && it != rootProject && it.childProjects.isEmpty()) {\n          if (it.name.startsWith(\"iceberg-spark-\")) {\n            def sparkScalaMatcher = sparkScalaPattern.matcher(it.name)\n            if (!sparkScalaMatcher.find()) {\n              throw new GradleException(\"Expected a Spark/Scala version combination in Gradle project name ${it.name}\")\n            }\n            def prjName = sparkScalaMatcher.group(1)\n            def sparkVer = sparkScalaMatcher.group(2)\n            for (def scalaVer in sparkScalaVersions[sparkVer]) {\n              add(\"api\", \"${it.group}:$prjName-${sparkVer}_$scalaVer:${it.version}\")\n            }\n          } else {\n            add(\"api\", project(it.path))\n          }\n        }\n      }\n    }\n  }\n\n  // Needed to get the \"faked\" Scala artifacts into the bom\n  javaPlatform { allowDependencies() }\n}\n","sourceCodeStart":1252,"sourceCodeEnd":1288,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/build.gradle#L1252-L1288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename the offending project so it matches 'iceberg-spark-<sparkVersion>_<scalaVersion>', e.g. 'iceberg-spark-3.5_2.12'.","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).","Check the sparkScalaPattern regex near the throw site to confirm which names are considered valid for your Spark version."],"exampleFix":"// before\nproject(':iceberg-spark-4.0')\n// after\nproject(':iceberg-spark-4.0_2.13')","handlingStrategy":"validation","validationCode":"def matcher = (project.name =~ /^iceberg-spark-(\\d+\\.\\d+)_(\\d+\\.\\d+)$/)  // verify before adding: matcher.matches() must be true for any 'iceberg-spark-*' project","typeGuard":"static boolean isVersionedSparkProject(String name) { return !name.startsWith('iceberg-spark-') || (name =~ /iceberg-spark-\\d+\\.\\d+_\\d+\\.\\d+/).matches() }","tryCatchPattern":null,"preventionTips":["Follow the existing iceberg-spark-<spark>_<scala> naming convention for all new Spark modules.","Never give non-versioned helper projects names starting with 'iceberg-spark-'.","Run ./gradlew build (BOM task included) after renaming any project."],"tags":["gradle","build-script","naming-convention","bom"],"backgroundTag":"invalid-identifier-format","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}