heremaps / here-sbt-bom

SBT BOM is the plugin for SBT for dealing with Maven BOM in SBT projects
Other
19 stars 6 forks source link

Failed to resolve NormalizedArtifact when `-Dsbt.ivy.home` sets in `.sbtops` #27

Open geny200 opened 1 month ago

geny200 commented 1 month ago

Hi, I found a problem that when you add -Dsbt.ivy.home=<your absolute path> to the .sbtopts of the project, you get the error Failed to resolve NormalizedArtifact

[info] Resolving NormalizedArtifact(com.fasterxml.jackson,jackson-bom,2.16.0)
java.lang.RuntimeException: Failed to resolve NormalizedArtifact(com.fasterxml.jackson,jackson-bom,2.16.0)
        at scala.sys.package$.error(package.scala:30)
        at com.here.bom.internal.BomReader.$anonfun$readPom$1(BomReader.scala:69)
        at scala.Option.getOrElse(Option.scala:189)
        at com.here.bom.internal.BomReader.readPom(BomReader.scala:69)
        at com.here.bom.internal.BomReader.go$1(BomReader.scala:225)
        at com.here.bom.internal.BomReader.buildParentsChain(BomReader.scala:251)
        at com.here.bom.internal.BomReader.readPomAndParents(BomReader.scala:175)
        at com.here.bom.internal.BomReader.extractRecursively$1(BomReader.scala:89)
        at com.here.bom.internal.BomReader.makeBom(BomReader.scala:113)
        at com.here.bom.Bom$.$anonfun$read$1(Bom.scala:56)
        at scala.Function1.$anonfun$compose$1(Function1.scala:49)
        at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:229)
        at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:171)
        at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:88)
        at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:100)
        at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:95)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
[error] Failed to resolve NormalizedArtifact(com.fasterxml.jackson,jackson-bom,2.16.0)

project:

// project/Dependencies.scala
import com.here.bom.Bom

object Dependencies {
  case class JacksonDependencies(bom: Bom)
}

// project/plugins.sbt
addSbtPlugin("com.here.platform" % "sbt-bom" % "1.0.16")

// build.sbt
import com.here.bom.Bom
import Dependencies.JacksonDependencies

ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.15"

lazy val jacksonBom = Bom.read("com.fasterxml.jackson" % "jackson-bom" % "2.16.0")(bom => JacksonDependencies(bom))

lazy val root = (project in file("."))
  .settings(jacksonBom)
  .settings(
    name := "untitled"
  )

// .sbtops
-Dsbt.ivy.home=<your absolute path>
molekyla commented 1 month ago

Hi @geny200. Thanks for the reporting. Indeed we have a bug there. To mitigate the issue you can set both variables sbt.ivy.home and ivy.home in the .sbtopts file: -Dsbt.ivy.home=/tmp -Divy.home=/tmp