diff --git a/build.sbt b/build.sbt index 815e1a480..77f0ea089 100644 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ inThisBuild(List( ) ), semanticdbEnabled := true, - semanticdbVersion := "4.8.14", + semanticdbVersion := "4.9.8", scalafixDependencies += "net.hamnaberg" %% "dataclass-scalafix" % dataclassScalafixV, version := "2.0.0-alpha8-SNAPSHOT", scalaVersion := scala3, @@ -43,7 +43,7 @@ ThisBuild / assemblyMergeStrategy := { oldStrategy(x) } -val coursierVersion0 = "2.1.9" +val coursierVersion0 = "2.1.13" val lmVersion = "1.3.4" val lm2_13Version = "1.5.0-M3" val lm3Version = "2.0.0-M1" @@ -143,7 +143,7 @@ lazy val `lm-coursier` = project // IvySbt#Module (seems DependencyResolutionInterface.moduleDescriptor // is ignored). lmIvy.value, - "org.scalatest" %% "scalatest" % "3.2.18" % Test, + "org.scalatest" %% "scalatest" % "3.2.19" % Test ), excludeDependencies ++= excludedDependencies, Test / exportedProducts := { @@ -222,7 +222,7 @@ lazy val `lm-coursier-shaded` = project "io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion, "net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided, lmIvy.value % Provided, - "org.scalatest" %% "scalatest" % "3.2.18" % Test, + "org.scalatest" %% "scalatest" % "3.2.19" % Test, ), excludeDependencies ++= excludedDependencies, conflictWarning := ConflictWarning.disable, @@ -236,7 +236,7 @@ lazy val `sbt-coursier-shared` = project .settings( plugin, generatePropertyFile, - libraryDependencies += "com.lihaoyi" %% "utest" % "0.8.3" % Test, + libraryDependencies += "com.lihaoyi" %% "utest" % "0.8.4" % Test, testFrameworks += new TestFramework("utest.runner.Framework") ) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/internal/SbtUpdateReport.scala b/modules/lm-coursier/src/main/scala/lmcoursier/internal/SbtUpdateReport.scala index 15a22ba92..215f485bd 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/internal/SbtUpdateReport.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/internal/SbtUpdateReport.scala @@ -4,15 +4,16 @@ import java.io.File import java.net.URL import java.util.GregorianCalendar import java.util.concurrent.ConcurrentHashMap - import coursier.cache.CacheUrl import coursier.{Attributes, Dependency, Module, Project, Resolution} -import coursier.core.{Classifier, Configuration, Extension, Publication, Type} +import coursier.core.{Classifier, Configuration, Extension, Info, Publication, Type} import coursier.maven.MavenAttributes import coursier.util.Artifact import sbt.librarymanagement.{Artifact => _, Configuration => _, _} import sbt.util.Logger +import scala.annotation.tailrec + private[internal] object SbtUpdateReport { private def caching[K, V](f: K => V): K => V = { @@ -226,6 +227,26 @@ private[internal] object SbtUpdateReport { ) } + /** + * Assemble the project info, resolving inherited fields. Only implements resolving + * the fields that are relevant for moduleReport + * + * @see https://maven.apache.org/pom.html#Inheritance + * @see https://maven.apache.org/ref/3-LATEST/maven-model-builder/index.html#Inheritance_Assembly + */ + def assemble(project: Project): Project = { + @tailrec + def licenseInfo(project: Project): Seq[Info.License] = { + if (project.info.licenseInfo.nonEmpty || project.parent.isEmpty) + project.info.licenseInfo + else + licenseInfo(lookupProject(project.parent.get).get) + } + project.withInfo( + project.info.withLicenseInfo(licenseInfo(project)) + ) + } + val m = Dependency(thisModule._1, "") val directReverseDependencies = res.rootDependencies.toSet.map(clean).map(_.withVersion("")) .map( @@ -252,6 +273,7 @@ private[internal] object SbtUpdateReport { groupedDepArtifacts.toVector.map { case (dep, artifacts) => val proj = lookupProject(dep.moduleVersion).get + val assembledProject = assemble(proj) // FIXME Likely flaky... val dependees = reverseDependencies @@ -280,7 +302,7 @@ private[internal] object SbtUpdateReport { moduleReport(( dep, dependees, - proj, + assembledProject, filesOpt, classLoaders, )) diff --git a/modules/lm-coursier/src/test/scala/lmcoursier/ResolutionSpec.scala b/modules/lm-coursier/src/test/scala/lmcoursier/ResolutionSpec.scala index 331d3aa78..bad447013 100644 --- a/modules/lm-coursier/src/test/scala/lmcoursier/ResolutionSpec.scala +++ b/modules/lm-coursier/src/test/scala/lmcoursier/ResolutionSpec.scala @@ -235,4 +235,17 @@ final class ResolutionSpec extends AnyPropSpec with Matchers { assert(resolution.isRight) } + + property("resolve licenses from parent poms") { + val dependencies = + Vector(("org.apache.commons" % "commons-compress" % "1.26.2")) + val coursierModule = module(lmEngine, stubModule, dependencies, Some("2.12.4")) + val resolution = + lmEngine.update(coursierModule, UpdateConfiguration(), UnresolvedWarningConfiguration(), log) + + assert(resolution.isRight) + val componentConfig = resolution.right.get.configurations.find(_.configuration == Compile.toConfigRef).get + val compress = componentConfig.modules.find(_.module.name == "commons-compress").get + compress.licenses should have size 1 + } } diff --git a/project/Settings.scala b/project/Settings.scala index 2ef52b265..09661eb01 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -9,9 +9,9 @@ import com.jsuereth.sbtpgp._ object Settings { - def scala212 = "2.12.17" - def scala213 = "2.13.10" - def scala3 = "3.3.1" + def scala212 = "2.12.20" + def scala213 = "2.13.15" + def scala3 = "3.3.4" def targetSbtVersion = "1.2.8" diff --git a/project/build.properties b/project/build.properties index e8a1e246e..0b699c305 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.7 +sbt.version=1.10.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 6552bcc5a..b1ea76fb6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,9 @@ semanticdbEnabled := false -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.1") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") // addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.5") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.0.0-RC1") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0") libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value