Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions project/SparkBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ object SparkBuild extends PomBuild {
lazy val sharedSettings = checkJavaVersionSettings ++
sparkGenjavadocSettings ++
compilerWarningSettings ++
DependencyVersions.settings ++
(if (noLintOnCompile) Nil else enableScalaStyle) ++ Seq(
(Compile / exportJars) := true,
(Test / exportJars) := false,
Expand Down Expand Up @@ -1177,12 +1178,33 @@ object KubernetesIntegrationTests {
)
}

object DependencyVersions {
Copy link
Member

@pan3793 pan3793 Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code refactoring suggestions were almost ignored, I'd like to see the technical explanation when doing that.

here are my thoughts behind the suggestions:

  • rename var jacksonModuleID => jacksonBom, the ModuleID(...) already indicates the var type, what is important here is bom
  • merge getVersion and getVersionFromPom to getProperty - it's overengineering, also disturbs IDE search functionality, when something goes wrong, or users want to understand where fasterxml.jackson.version is used, it's likely to do a global search

Copy link
Member Author

@vrozov vrozov Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code refactoring suggestions were almost ignored, I'd like to see the technical explanation when doing that.

There were too many changes in the code refactoring suggestion, and not every intention was clear. It would be much easier to explain what you wanted to change instead of providing a single code suggestion.

rename var jacksonModuleID => jacksonBom

It is not BOM, it is moduleID. BOM is the content of the file: "a BOM is a special type of POM file that lists a curated set of dependencies and their compatible versions. It's designed to simplify dependency management in projects that use multiple modules from the same ecosystem". ModuleID is a way to refer to pom, bom, and other artifacts using groupId, artifactId, and version. The best I can do is rename jacksonModuleID => jacksonBomModuleID (similar to pomProperties naming).

merge getVersion and getVersionFromPom to getProperty - it's overengineering, also disturbs IDE search functionality, when something goes wrong, or users want to understand where fasterxml.jackson.version is used, it's likely to do a global search

I tried your suggestion, and it does not work. IDE (IntelliJ) does not understand that pom property is used in SBT build anyway. The expectation that a string is always used "as is" is not a valid expectation. The goal here is to make DependencyVersions object to support other artifacts in the following PRs, and the current approach allows to avoid repeating ".version" over and over again.

Copy link
Member

@pan3793 pan3793 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best I can do is rename jacksonModuleID => jacksonBomModuleID

this makes sense.

IDE (IntelliJ) does not understand that pom property is used in SBT build anyway.

what I mean "search" is text search, something like grep.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I mean "search" is text search, something like grep.

The expectation that a string is always used "as is" is not a valid expectation. It may be used with macros, regular expressions, concatenated with another string and etc. What is expected in maven pom.xml for tags, does not apply to SBT.

import java.util.Properties

private lazy val pomProperties = settingKey[Properties]("Effective POM properties")
lazy val jacksonVersion = settingKey[String]("Jackson version")
lazy val jacksonBomModuleID = settingKey[ModuleID]("Jackson BOM Module ID")
lazy val settings = Seq(
pomProperties := SbtPomKeys.effectivePom.value.getProperties,
jacksonVersion := getVersion(pomProperties.value, "fasterxml.jackson"),
jacksonBomModuleID := ModuleID("com.fasterxml.jackson", "jackson-bom", jacksonVersion.value),
)

private def getVersionFromPom(pomProperties: Properties, property: String) : String = {
pomProperties.get(property).asInstanceOf[String]
}

private def getVersion(pomProperties: Properties, property: String) : String = {
val version = property + ".version"
sys.props.get(version).getOrElse(getVersionFromPom(pomProperties, version))
}
}

/**
* Overrides to work around sbt's dependency resolution being different from Maven's.
*/
object DependencyOverrides {
lazy val jacksonVersion = sys.props.get("fasterxml.jackson.version").getOrElse("2.20.1")
lazy val jacksonDeps = Bom.dependencies("com.fasterxml.jackson" % "jackson-bom" % jacksonVersion)
lazy val jacksonDeps = Bom.dependencies(DependencyVersions.jacksonBomModuleID)
lazy val settings = jacksonDeps ++ Seq(
dependencyOverrides ++= {
val guavaVersion = sys.props.get("guava.version").getOrElse(
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.17.0")

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")

addSbtPlugin("com.here.platform" % "sbt-bom" % "1.0.29")
addSbtPlugin("com.here.platform" % "sbt-bom" % "1.0.31")