Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

[0.10.0-RC1 + sbt 1.2.5+ regression] ignore cached resolution for the dedicated update report #184

Merged
merged 4 commits into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: scala
jdk: oraclejdk8
dist: trusty
script:
- sbt ";^test ;^scripted"

Expand All @@ -12,4 +13,4 @@ before_cache:
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt
- $HOME/.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions src/sbt-test/sbt-dependency-graph/cachedResolution/build.sbt
Original file line number Diff line number Diff line change
@@ -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)))
()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % sys.props("project.version"))
1 change: 1 addition & 0 deletions src/sbt-test/sbt-dependency-graph/cachedResolution/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> check