From 382ff2ef5279fb7cd9b41e51ce4ebe7eb6482251 Mon Sep 17 00:00:00 2001 From: Roman Timushev Date: Fri, 12 Aug 2016 21:22:29 +0300 Subject: [PATCH] Support for crossScalaVersions --- README.md | 7 +++++- notes/0.2.0.markdown | 11 +++++++++ .../com/timushev/sbt/updates/Reporter.scala | 14 +++++++---- .../sbt/updates/UpdatesPluginTasks.scala | 4 ++-- src/sbt-test/updates/cross/build.sbt | 24 +++++++++++++++++++ .../updates/cross/project/plugins.sbt | 1 + src/sbt-test/updates/cross/test | 1 + 7 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 notes/0.2.0.markdown create mode 100644 src/sbt-test/updates/cross/build.sbt create mode 100644 src/sbt-test/updates/cross/project/plugins.sbt create mode 100644 src/sbt-test/updates/cross/test diff --git a/README.md b/README.md index 696b5626..f6997ef1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ sbt-updates [![Build Status](https://travis-ci.org/rtimush/sbt-updates.svg?branc ================== Display your SBT project's dependency updates. +Update information is obtained from the maven metadata, so no updates for dependencies in Ivy repositories +will be found. + +If your project uses `crossScalaVersions` you will be presented only with updates available for all scala versions. + Requirements ============== SBT 0.13.5 and later @@ -16,7 +21,7 @@ Add the following line to one of these files: - Your global file at `~/.sbt/0.13/plugins/sbt-updates.sbt` ``` -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.2.0") ``` ### Snapshot version diff --git a/notes/0.2.0.markdown b/notes/0.2.0.markdown new file mode 100644 index 00000000..eb5adefb --- /dev/null +++ b/notes/0.2.0.markdown @@ -0,0 +1,11 @@ +sbt-updates 0.2.0 has been released: + + * If your project uses `crossScalaVersions` you will be presented only with updates available for all scala versions. + * Unsupported protocols such as `ftp://` or `s3://` do not cause errors anymore. + +Updates report example: + + > dependencyUpdates + [info] Found 3 dependency updates for test-project + [info] ch.qos.logback:logback-classic : 0.8 -> 0.8.1 -> 0.9.30 -> 1.0.13 + [info] org.slf4j:slf4j-api : 1.6.4 -> 1.6.6 -> 1.7.5 diff --git a/src/main/scala/com/timushev/sbt/updates/Reporter.scala b/src/main/scala/com/timushev/sbt/updates/Reporter.scala index b3fcf883..04c400fb 100644 --- a/src/main/scala/com/timushev/sbt/updates/Reporter.scala +++ b/src/main/scala/com/timushev/sbt/updates/Reporter.scala @@ -17,14 +17,20 @@ object Reporter { dependencies: Seq[ModuleID], resolvers: Seq[Resolver], credentials: Seq[Credentials], - scalaFullVersion: String, - scalaBinaryVersion: String, + scalaVersions: Seq[String], excluded: ModuleFilter, allowPreRelease: Boolean, out: TaskStreams[_]): Map[ModuleID, SortedSet[Version]] = { - val crossDependencies = dependencies.map(CrossVersion(scalaFullVersion, scalaBinaryVersion)) val loaders = resolvers collect MetadataLoaderFactory.loader(out.log, credentials) - val updatesFuture = Future.sequence(crossDependencies map findUpdates(loaders, allowPreRelease)) + val updatesFuture = Future.sequence(scalaVersions map { scalaVersion => + val crossVersion = CrossVersion(scalaVersion, CrossVersion.binaryScalaVersion(scalaVersion)) + val crossDependencies = dependencies map crossVersion + Future.sequence(crossDependencies map findUpdates(loaders, allowPreRelease)) + }) map { crossUpdates => + crossUpdates.transpose map { updates => + updates reduce (_ intersect _) + } + } val updates = Await.result(updatesFuture, 1.hour) (dependencies zip updates) .toMap diff --git a/src/main/scala/com/timushev/sbt/updates/UpdatesPluginTasks.scala b/src/main/scala/com/timushev/sbt/updates/UpdatesPluginTasks.scala index 7ccd1787..499207a6 100644 --- a/src/main/scala/com/timushev/sbt/updates/UpdatesPluginTasks.scala +++ b/src/main/scala/com/timushev/sbt/updates/UpdatesPluginTasks.scala @@ -1,12 +1,12 @@ package com.timushev.sbt.updates -import sbt.Keys._ import com.timushev.sbt.updates.UpdatesKeys._ +import sbt.Keys._ trait UpdatesPluginTasks { def dependencyUpdatesDataTask = - (projectID, libraryDependencies, externalResolvers, credentials, scalaVersion, scalaBinaryVersion, dependencyUpdatesExclusions, dependencyAllowPreRelease, streams) + (projectID, libraryDependencies, externalResolvers, credentials, crossScalaVersions, dependencyUpdatesExclusions, dependencyAllowPreRelease, streams) .map(Reporter.dependencyUpdatesData) def dependencyUpdatesTask = diff --git a/src/sbt-test/updates/cross/build.sbt b/src/sbt-test/updates/cross/build.sbt new file mode 100644 index 00000000..c261b3c2 --- /dev/null +++ b/src/sbt-test/updates/cross/build.sbt @@ -0,0 +1,24 @@ +import com.timushev.sbt.updates.versions.Version + +scalaVersion := "2.10.4" +crossScalaVersions := Seq("2.10.4", "2.11.5") + +libraryDependencies += "org.specs2" %% "specs2" % "3.1" + +TaskKey[Unit]("check") := { + val updates = dependencyUpdatesData.value + val found = updates.keys exists { + case m if m.organization == "org.scala-lang" => false + case m if m.organization == "org.specs2" => + val versions = updates(m) + if (versions.contains(Version("3.7"))) + sys.error(s"Wrong update versions: $versions") + true + case other => + sys.error(s"Wrong update key: $other") + false + } + if (!found) + sys.error("No updates for specs2 found") + () +} diff --git a/src/sbt-test/updates/cross/project/plugins.sbt b/src/sbt-test/updates/cross/project/plugins.sbt new file mode 100644 index 00000000..4552729a --- /dev/null +++ b/src/sbt-test/updates/cross/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "latest.integration") diff --git a/src/sbt-test/updates/cross/test b/src/sbt-test/updates/cross/test new file mode 100644 index 00000000..15675b16 --- /dev/null +++ b/src/sbt-test/updates/cross/test @@ -0,0 +1 @@ +> check