diff --git a/.travis.yml b/.travis.yml index 6190c81..5a335d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ sudo: false language: scala jdk: oraclejdk8 +dist: trusty script: - sbt ";^test ;^scripted" @@ -12,4 +13,4 @@ before_cache: cache: directories: - $HOME/.ivy2/cache - - $HOME/.sbt \ No newline at end of file + - $HOME/.sbt diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd87eb..02eb5e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + * [#184](https://github.com/jrudolph/sbt-dependency-graph/pull/184): Fix regression in 0.10.0-RC1 for recent sbt versions when + `cachedResolution` (with coursier turned off). Thanks [@bjaglin](https://github.com/bjaglin) for the report and the fix. + ## Version 0.10.0-RC1 (2019-07-24) * [#136](https://github.com/jrudolph/sbt-dependency-graph/pull/136): Added `dependencyBrowseTree` to open a searchable dependency tree in the browser. Thanks, [@pcejrowski](https://github.com/pcejrowski) for contributing this feature. diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 2ea3b3c..bec65da 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -37,10 +37,27 @@ object DependencyGraphSettings { def baseSettings = Seq( ivyReportFunction := ivyReportFunctionTask.value, + + // disable the cached resolution engine (exposing a scoped `ivyModule` used directly by `updateTask`), as it + // generates artificial module descriptors which are internal to sbt, making it hard to reconstruct the + // dependency tree + updateOptions in ignoreMissingUpdate := updateOptions.value.withCachedResolution(false), + ivyConfiguration in ignoreMissingUpdate := + // inTask will make sure the new definition will pick up `updateOptions in ignoreMissingUpdate` + SbtAccess.inTask(ignoreMissingUpdate, Classpaths.mkIvyConfiguration).value, + ivyModule in ignoreMissingUpdate := { + // concatenating & inlining ivySbt & ivyModule default task implementations, as `SbtAccess.inTask` does + // NOT correctly force the scope when applied to `TaskKey.toTask` instances (as opposed to raw + // implementations like `Classpaths.mkIvyConfiguration` or `Classpaths.updateTask`) + val is = new IvySbt((ivyConfiguration in ignoreMissingUpdate).value) + new is.Module(moduleSettings.value) + }, + + // don't fail on missing dependencies updateConfiguration in ignoreMissingUpdate := updateConfiguration.value.withMissingOk(true), ignoreMissingUpdate := - // inTask will make sure the new definition will pick up `updateConfiguration in ignoreMissingUpdate` + // inTask will make sure the new definition will pick up `ivyModule/updateConfiguration in ignoreMissingUpdate` SbtAccess.inTask(ignoreMissingUpdate, Classpaths.updateTask).value, filterScalaLibrary in Global := true) diff --git a/src/sbt-test/sbt-dependency-graph/cachedResolution/build.sbt b/src/sbt-test/sbt-dependency-graph/cachedResolution/build.sbt new file mode 100644 index 0000000..e9aef9b --- /dev/null +++ b/src/sbt-test/sbt-dependency-graph/cachedResolution/build.sbt @@ -0,0 +1,17 @@ +scalaVersion := "2.12.9" + +libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.28" +updateOptions := updateOptions.value.withCachedResolution(true) + +TaskKey[Unit]("check") := { + val report = (ivyReport in Test).value + val graph = (asciiTree in Test).value + + def sanitize(str: String): String = str.split('\n').drop(1).mkString("\n") + val expectedGraph = + """default:cachedresolution_2.12:0.1.0-SNAPSHOT + | +-org.slf4j:slf4j-api:1.7.28 + | """.stripMargin + require(sanitize(graph) == sanitize(expectedGraph), "Graph for report %s was '\n%s' but should have been '\n%s'" format (report, sanitize(graph), sanitize(expectedGraph))) + () +} diff --git a/src/sbt-test/sbt-dependency-graph/cachedResolution/project/plugins.sbt b/src/sbt-test/sbt-dependency-graph/cachedResolution/project/plugins.sbt new file mode 100644 index 0000000..6fdebb6 --- /dev/null +++ b/src/sbt-test/sbt-dependency-graph/cachedResolution/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % sys.props("project.version")) diff --git a/src/sbt-test/sbt-dependency-graph/cachedResolution/test b/src/sbt-test/sbt-dependency-graph/cachedResolution/test new file mode 100644 index 0000000..a5912a3 --- /dev/null +++ b/src/sbt-test/sbt-dependency-graph/cachedResolution/test @@ -0,0 +1 @@ +> check \ No newline at end of file