Skip to content

Commit

Permalink
Support for crossScalaVersions
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimush committed Aug 12, 2016
1 parent fbd5b3f commit 382ff2e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions notes/0.2.0.markdown
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions src/main/scala/com/timushev/sbt/updates/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
24 changes: 24 additions & 0 deletions src/sbt-test/updates/cross/build.sbt
Original file line number Diff line number Diff line change
@@ -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")
()
}
1 change: 1 addition & 0 deletions src/sbt-test/updates/cross/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "latest.integration")
1 change: 1 addition & 0 deletions src/sbt-test/updates/cross/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> check

0 comments on commit 382ff2e

Please sign in to comment.