From 25069139bec63ba69169e129df4b41dc3bc3023b Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Fri, 30 Jan 2015 19:55:29 +0000 Subject: [PATCH 01/38] Added Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 91320112e..ff83beeaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ sbt-dependency-graph ==================== +[![Join the chat at https://gitter.im/jrudolph/sbt-dependency-graph](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jrudolph/sbt-dependency-graph?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + Visualize your project's dependencies. How To Use From d38a00598f2a17d80e6ebabc6f6076f5c3916d5a Mon Sep 17 00:00:00 2001 From: David McNelis Date: Mon, 9 Jan 2017 14:38:46 -0500 Subject: [PATCH 02/38] Adding a clarifying remark to the whatDependsOn command, to make it clear how to run the command from outside an sbt shell --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 285e418e8..e667d9987 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This plugin is an auto-plugin which will be automatically enabled starting from * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console * `dependencyList`: Shows a flat list of all transitive dependencies on the sbt console (sorted by organization and name) * `whatDependsOn `: Find out what depends on an artifact. Shows a reverse dependency - tree for the selected module. + tree for the selected module. Enclose the command in quotes (i.e. `sbt "whatDependsOn "` when not using within an sbt shell). * `dependencyLicenseInfo`: show dependencies grouped by declared license * `dependencyStats`: Shows a table with each module a row with (transitive) Jar sizes and number of dependencies * `dependencyGraphMl`: Generates a `.graphml` file with the project's dependencies to `target/dependencies-.graphml`. From d81aaf0f9ccfd7c9b486aa067c1e87719da1f558 Mon Sep 17 00:00:00 2001 From: Alex Bezhan Date: Mon, 5 Jun 2017 14:35:23 +0300 Subject: [PATCH 03/38] Fix readme markdown --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 285e418e8..1e86e5f96 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,10 @@ dependencyDotFile := file("dependencies.dot") //render dot file to `./dependenci * sbt < 0.13.6: The plugin will fall back on the old ivy report XML backend which suffers from [#39]. * sbt < 0.13.5: Old versions of sbt have no `AutoPlugin` support, you need to add - ```scala +```scala net.virtualvoid.sbt.graph.DependencyGraphSettings.graphSettings - ``` +``` + to your `build.sbt` or (`~/.sbt/0.13/user.sbt` for global configuration) to enable the plugin. * sbt <= 0.12.x: Old versions of sbt are not actively supported any more. Please use the old version from the [0.7 branch](https://github.com/jrudolph/sbt-dependency-graph/tree/0.7). From 77b0e5a550983d7a7f6caa689de76b9b98dfcc2d Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 5 Jun 2017 22:58:44 +0900 Subject: [PATCH 04/38] remove ls json --- src/main/ls/0.5.1.json | 18 ------------------ src/main/ls/0.5.2.json | 18 ------------------ src/main/ls/0.6.0.json | 17 ----------------- src/main/ls/0.7.0.json | 29 ----------------------------- src/main/ls/0.7.1.json | 29 ----------------------------- src/main/ls/0.7.2.json | 29 ----------------------------- src/main/ls/0.7.3.json | 29 ----------------------------- src/main/ls/0.7.4.json | 29 ----------------------------- 8 files changed, 198 deletions(-) delete mode 100644 src/main/ls/0.5.1.json delete mode 100644 src/main/ls/0.5.2.json delete mode 100644 src/main/ls/0.6.0.json delete mode 100644 src/main/ls/0.7.0.json delete mode 100644 src/main/ls/0.7.1.json delete mode 100644 src/main/ls/0.7.2.json delete mode 100644 src/main/ls/0.7.3.json delete mode 100644 src/main/ls/0.7.4.json diff --git a/src/main/ls/0.5.1.json b/src/main/ls/0.5.1.json deleted file mode 100644 index 80a39a08d..000000000 --- a/src/main/ls/0.5.1.json +++ /dev/null @@ -1,18 +0,0 @@ - -{ - "organization":"net.virtualvoid", - "name":"sbt-dependency-graph", - "version":"0.5.1", - "description":"An sbt plugin which allows to create a graphml file from the dependencies of the project.", - "site":"http://github.com/jrudolph/sbt-dependency-graph", - "tags":["dependency","graph","sbt-plugin","sbt"], - "docs":"http://github.com/jrudolph/sbt-dependency-graph", - "licenses": [{ - "name": "Apache License 2.0", - "url": "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - }], - "resolvers": ["http://scala-tools.org/repo-releases"], - "dependencies": [], - "scalas": ["2.9.1"], - "sbt": true -} \ No newline at end of file diff --git a/src/main/ls/0.5.2.json b/src/main/ls/0.5.2.json deleted file mode 100644 index 53582b5a0..000000000 --- a/src/main/ls/0.5.2.json +++ /dev/null @@ -1,18 +0,0 @@ - -{ - "organization":"net.virtual-void", - "name":"sbt-dependency-graph", - "version":"0.5.2", - "description":"An sbt plugin which allows to create a graphml file from the dependencies of the project.", - "site":"http://github.com/jrudolph/sbt-dependency-graph", - "tags":["dependency","graph","sbt-plugin","sbt"], - "docs":"http://github.com/jrudolph/sbt-dependency-graph", - "licenses": [{ - "name": "Apache License 2.0", - "url": "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - }], - "resolvers": ["http://scala-tools.org/repo-releases"], - "dependencies": [], - "scalas": ["2.9.1"], - "sbt": true -} \ No newline at end of file diff --git a/src/main/ls/0.6.0.json b/src/main/ls/0.6.0.json deleted file mode 100644 index 89d9a2c6c..000000000 --- a/src/main/ls/0.6.0.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "organization":"net.virtual-void", - "name":"sbt-dependency-graph", - "version":"0.6.0", - "description":"An sbt plugin to visualize dependencies of your build.", - "site":"http://github.com/jrudolph/sbt-dependency-graph", - "tags":["dependency","graph","sbt-plugin","sbt"], - "docs":"http://github.com/jrudolph/sbt-dependency-graph", - "licenses": [{ - "name": "Apache License 2.0", - "url": "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - }], - "resolvers": ["https://oss.sonatype.org/content/repositories/releases"], - "dependencies": [], - "scalas": ["2.9.1"], - "sbt": true -} \ No newline at end of file diff --git a/src/main/ls/0.7.0.json b/src/main/ls/0.7.0.json deleted file mode 100644 index c28c87bcd..000000000 --- a/src/main/ls/0.7.0.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organization" : "net.virtual-void", - "name" : "sbt-dependency-graph", - "version" : "0.7.0", - "description" : "An sbt plugin to visualize dependencies of your build.", - "site" : "http://github.com/jrudolph/sbt-dependency-graph", - "tags" : [ "dependency", "graph", "sbt-plugin", "sbt" ], - "docs" : "http://github.com/jrudolph/sbt-dependency-graph", - "resolvers" : [ "https://oss.sonatype.org/content/repositories/releases" ], - "dependencies" : [ { - "organization" : "org.scala-sbt", - "name" : "scripted-sbt", - "version" : "0.12.0" - }, { - "organization" : "org.scala-sbt", - "name" : "sbt-launch", - "version" : "0.12.0" - }, { - "organization" : "com.github.mdr", - "name" : "ascii-graphs", - "version" : "0.0.2" - } ], - "scalas" : [ "2.9.2" ], - "licenses" : [ { - "name" : "Apache License 2.0", - "url" : "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - } ], - "sbt" : true -} \ No newline at end of file diff --git a/src/main/ls/0.7.1.json b/src/main/ls/0.7.1.json deleted file mode 100644 index 846054dd4..000000000 --- a/src/main/ls/0.7.1.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organization" : "net.virtual-void", - "name" : "sbt-dependency-graph", - "version" : "0.7.1", - "description" : "An sbt plugin to visualize dependencies of your build.", - "site" : "http://github.com/jrudolph/sbt-dependency-graph", - "tags" : [ "dependency", "graph", "sbt-plugin", "sbt" ], - "docs" : "http://github.com/jrudolph/sbt-dependency-graph", - "resolvers" : [ "https://oss.sonatype.org/content/repositories/releases" ], - "dependencies" : [ { - "organization" : "org.scala-sbt", - "name" : "scripted-sbt", - "version" : "0.12.0" - }, { - "organization" : "org.scala-sbt", - "name" : "sbt-launch", - "version" : "0.12.0" - }, { - "organization" : "com.github.mdr", - "name" : "ascii-graphs", - "version" : "0.0.2" - } ], - "scalas" : [ "2.9.2" ], - "licenses" : [ { - "name" : "Apache License 2.0", - "url" : "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - } ], - "sbt" : true -} diff --git a/src/main/ls/0.7.2.json b/src/main/ls/0.7.2.json deleted file mode 100644 index f004d3e82..000000000 --- a/src/main/ls/0.7.2.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organization" : "net.virtual-void", - "name" : "sbt-dependency-graph", - "version" : "0.7.2", - "description" : "An sbt plugin to visualize dependencies of your build.", - "site" : "http://github.com/jrudolph/sbt-dependency-graph", - "tags" : [ "dependency", "graph", "sbt-plugin", "sbt" ], - "docs" : "http://github.com/jrudolph/sbt-dependency-graph", - "resolvers" : [ "https://oss.sonatype.org/content/repositories/releases" ], - "dependencies" : [ { - "organization" : "org.scala-sbt", - "name" : "scripted-sbt", - "version" : "0.12.1" - }, { - "organization" : "org.scala-sbt", - "name" : "sbt-launch", - "version" : "0.12.1" - }, { - "organization" : "com.github.mdr", - "name" : "ascii-graphs", - "version" : "0.0.2" - } ], - "scalas" : [ "2.9.2" ], - "licenses" : [ { - "name" : "Apache License 2.0", - "url" : "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - } ], - "sbt" : true -} \ No newline at end of file diff --git a/src/main/ls/0.7.3.json b/src/main/ls/0.7.3.json deleted file mode 100644 index dcc5f5fb5..000000000 --- a/src/main/ls/0.7.3.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organization" : "net.virtual-void", - "name" : "sbt-dependency-graph", - "version" : "0.7.3", - "description" : "An sbt plugin to visualize dependencies of your build.", - "site" : "http://github.com/jrudolph/sbt-dependency-graph", - "tags" : [ "dependency", "graph", "sbt-plugin", "sbt" ], - "docs" : "http://github.com/jrudolph/sbt-dependency-graph", - "resolvers" : [ "https://oss.sonatype.org/content/repositories/releases" ], - "dependencies" : [ { - "organization" : "org.scala-sbt", - "name" : "scripted-sbt", - "version" : "0.12.1" - }, { - "organization" : "org.scala-sbt", - "name" : "sbt-launch", - "version" : "0.12.1" - }, { - "organization" : "com.github.mdr", - "name" : "ascii-graphs", - "version" : "0.0.2" - } ], - "scalas" : [ "2.9.2" ], - "licenses" : [ { - "name" : "Apache License 2.0", - "url" : "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - } ], - "sbt" : true -} \ No newline at end of file diff --git a/src/main/ls/0.7.4.json b/src/main/ls/0.7.4.json deleted file mode 100644 index 00fecdd84..000000000 --- a/src/main/ls/0.7.4.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organization" : "net.virtual-void", - "name" : "sbt-dependency-graph", - "version" : "0.7.4", - "description" : "An sbt plugin to visualize dependencies of your build.", - "site" : "http://github.com/jrudolph/sbt-dependency-graph", - "tags" : [ "dependency", "graph", "sbt-plugin", "sbt" ], - "docs" : "http://github.com/jrudolph/sbt-dependency-graph", - "resolvers" : [ "https://oss.sonatype.org/content/repositories/releases" ], - "dependencies" : [ { - "organization" : "org.scala-sbt", - "name" : "scripted-sbt", - "version" : "0.12.1" - }, { - "organization" : "org.scala-sbt", - "name" : "sbt-launch", - "version" : "0.12.1" - }, { - "organization" : "com.github.mdr", - "name" : "ascii-graphs", - "version" : "0.0.2" - } ], - "scalas" : [ "2.9.2" ], - "licenses" : [ { - "name" : "Apache License 2.0", - "url" : "https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE" - } ], - "sbt" : true -} \ No newline at end of file From 775cad68fe15bb8a63a13d392c73633129d22492 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 5 Jun 2017 23:05:55 +0900 Subject: [PATCH 05/38] remove sbt-cross-building --- build.sbt | 25 +++---------------------- project/plugins.sbt | 4 ++-- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/build.sbt b/build.sbt index 59deabbe9..6b4943943 100644 --- a/build.sbt +++ b/build.sbt @@ -1,28 +1,9 @@ -crossBuildingSettings - -CrossBuilding.crossSbtVersions := Seq("0.13") - -CrossBuilding.scriptedSettings +ScriptedPlugin.scriptedSettings libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.3" -libraryDependencies <++= scalaVersion { version => - if (version startsWith "2.1") Seq("org.scala-lang" % "scala-reflect" % version % "provided") - else Nil -} - -libraryDependencies <+= scalaVersion { version => - if (version startsWith "2.9") "org.specs2" % "specs2_2.9.3" % "1.12.4.1" % "test" - else "org.specs2" %% "specs2" % "2.3.11" % "test" -} +libraryDependencies += "org.specs2" %% "specs2" % "2.3.11" % "test" scalacOptions ++= Seq("-deprecation", "-unchecked") -sbt.CrossBuilding.latestCompatibleVersionMapper ~= { - original => { - case "0.13" => "0.13.6" - case x => original(x) - } -} - -ScalariformSupport.formatSettings \ No newline at end of file +ScalariformSupport.formatSettings diff --git a/project/plugins.sbt b/project/plugins.sbt index df57f0cef..0a919c7d8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("net.virtual-void" % "sbt-cross-building" % "0.8.1") +libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value -addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") \ No newline at end of file +addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") From 78092eb193e4ac2845738038bfd71c2b5937a87c Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 5 Jun 2017 23:09:23 +0900 Subject: [PATCH 06/38] add .travis.yml --- .travis.yml | 5 +++++ .../sbt-dependency-graph/intervalRangedVersions/build.sbt | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..30f872264 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +sudo: false +language: scala +jdk: oraclejdk7 +script: +- sbt test scripted diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt index b73285b94..2cec07ae8 100644 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt @@ -1,5 +1,7 @@ scalaVersion := "2.9.1" +resolvers += "typesafe maven" at "http://repo.typesafe.com/typesafe/maven-releases/" + libraryDependencies ++= Seq( "com.codahale" % "jerkson_2.9.1" % "0.5.0" ) From f8eace182db715fe89bcf64299d9de965c5ec9ba Mon Sep 17 00:00:00 2001 From: Ben McCann Date: Tue, 6 Jun 2017 10:11:36 -0700 Subject: [PATCH 07/38] Use https for resolver See http://www.ontoillogical.com/blog/2014/07/28/how-to-take-over-any-java-developer/ --- .../sbt-dependency-graph/intervalRangedVersions/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt index 2cec07ae8..d2bf36622 100644 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt @@ -1,6 +1,6 @@ scalaVersion := "2.9.1" -resolvers += "typesafe maven" at "http://repo.typesafe.com/typesafe/maven-releases/" +resolvers += "typesafe maven" at "https://repo.typesafe.com/typesafe/maven-releases/" libraryDependencies ++= Seq( "com.codahale" % "jerkson_2.9.1" % "0.5.0" From c5700e9d74266b384df0182f7309856449e40b9c Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 14 Aug 2017 15:26:26 +0200 Subject: [PATCH 08/38] update to sbt 0.13.16 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index a6e117b61..c091b86ca 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.8 +sbt.version=0.13.16 From dd6c1c42068c89dc4062b2238b525642a447f021 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 14 Aug 2017 15:27:00 +0200 Subject: [PATCH 09/38] move to sbt-pgp 1.1.0-M1 --- project/pgp.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/pgp.sbt b/project/pgp.sbt index 4ce4d9ed4..cefa8ec57 100644 --- a/project/pgp.sbt +++ b/project/pgp.sbt @@ -1 +1 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1") From 279dea35147d286724aaf0365a18c98e60395521 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 14 Aug 2017 15:36:50 +0200 Subject: [PATCH 10/38] only provide `dependencyGraph` / `asciiGraph` in sbt 0.13 --- build.sbt | 9 +++++-- .../sbt/graph/rendering/AsciiGraph.scala | 22 ++++++++++++++++ .../sbt/graph/rendering/AsciiGraph.scala | 22 ++++++++++++++++ .../sbt/graph/DependencyGraphSettings.scala | 25 ++----------------- 4 files changed, 53 insertions(+), 25 deletions(-) rename src/main/{scala => scala-sbt-0.13}/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala (62%) create mode 100644 src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala diff --git a/build.sbt b/build.sbt index 6b4943943..ab195ffae 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,13 @@ ScriptedPlugin.scriptedSettings -libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.3" +libraryDependencies ++= { + if (sbtVersion.value startsWith "0.13") + Seq("com.github.mdr" %% "ascii-graphs" % "0.0.3") + else + Nil +} -libraryDependencies += "org.specs2" %% "specs2" % "2.3.11" % "test" +libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test" scalacOptions ++= Seq("-deprecation", "-unchecked") diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala similarity index 62% rename from src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala rename to src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala index 8da025149..701fdce7d 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala +++ b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala @@ -18,6 +18,8 @@ package net.virtualvoid.sbt.graph package rendering import com.github.mdr.ascii.layout._ +import net.virtualvoid.sbt.graph.DependencyGraphKeys._ +import sbt.Keys._ object AsciiGraph { def asciiGraph(graph: ModuleGraph): String = @@ -35,4 +37,24 @@ object AsciiGraph { val edges = moduleGraph.edges.toList.map { case (from, to) ⇒ (renderVertex(moduleGraph.module(from)), renderVertex(moduleGraph.module(to))) } Graph(vertices, edges) } + + def asciiGraphSetttings = Seq[sbt.Def.Setting[_]]( + DependencyGraphKeys.asciiGraph := asciiGraph(moduleGraph.value), + dependencyGraph := { + val force = DependencyGraphSettings.shouldForceParser.parsed + val log = streams.value.log + if (force || moduleGraph.value.nodes.size < 15) { + log.info(rendering.AsciiGraph.asciiGraph(moduleGraph.value)) + log.info("\n\n") + log.info("Note: The old tree layout is still available by using `dependency-tree`") + } + + log.info(rendering.AsciiTree.asciiTree(moduleGraph.value)) + + if (!force) { + log.info("\n") + log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.") + } + } + ) } diff --git a/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala b/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala new file mode 100644 index 000000000..b9e187a3b --- /dev/null +++ b/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala @@ -0,0 +1,22 @@ +/* + * Copyright 2017 Johannes Rudolph + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.virtualvoid.sbt.graph +package rendering + +object AsciiGraph { + def asciiGraphSetttings = Seq.empty[sbt.Def.Setting[_]] +} \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index ab0fd6779..790453585 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -18,15 +18,11 @@ package net.virtualvoid.sbt.graph import sbt._ import Keys._ - import CrossVersion._ - import sbt.complete.Parser - import org.apache.ivy.core.resolve.ResolveOptions - import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } -import net.virtualvoid.sbt.graph.rendering.DagreHTML +import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML } import net.virtualvoid.sbt.graph.util.IOUtil object DependencyGraphSettings { @@ -55,23 +51,6 @@ object DependencyGraphSettings { else graph }, moduleGraphStore <<= moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph, - asciiGraph <<= moduleGraph map rendering.AsciiGraph.asciiGraph, - dependencyGraph <<= InputTask(shouldForceParser) { force ⇒ - (force, moduleGraph, streams) map { (force, graph, streams) ⇒ - if (force || graph.nodes.size < 15) { - streams.log.info(rendering.AsciiGraph.asciiGraph(graph)) - streams.log.info("\n\n") - streams.log.info("Note: The old tree layout is still available by using `dependency-tree`") - } else { - streams.log.info(rendering.AsciiTree.asciiTree(graph)) - - if (!force) { - streams.log.info("\n") - streams.log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.") - } - } - } - }, asciiTree <<= moduleGraph map rendering.AsciiTree.asciiTree, dependencyTree <<= print(asciiTree), dependencyGraphMLFile <<= target / "dependencies-%s.graphml".format(config.toString), @@ -101,7 +80,7 @@ object DependencyGraphSettings { streams.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(graph, module))) } }, - licenseInfo <<= (moduleGraph, streams) map showLicenseInfo)) + licenseInfo <<= (moduleGraph, streams) map showLicenseInfo) ++ AsciiGraph.asciiGraphSetttings) def ivyReportFunctionTask = (sbtVersion, target, projectID, ivyModule, appConfiguration, streams) map { (sbtV, target, projectID, ivyModule, config, streams) ⇒ From 0e20a090f380040de98f5449c2e50e52e150bdd1 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 29 Aug 2017 16:48:27 +0200 Subject: [PATCH 11/38] half-broken initial attempt at sbt 1.0.0 support --- build.sbt | 19 +- .../scala-sbt-0.13/sbt/compat/SbtCompat.scala | 11 ++ .../scala-sbt-1.0/sbt/compat/SbtCompat.scala | 3 + .../sbt/graph/DependencyGraphSettings.scala | 175 +++++++++--------- .../net/virtualvoid/sbt/graph/model.scala | 25 ++- src/main/scala/sbt/SbtAccess.scala | 9 + 6 files changed, 156 insertions(+), 86 deletions(-) create mode 100644 src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala create mode 100644 src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala diff --git a/build.sbt b/build.sbt index ab195ffae..f33b9585a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,8 @@ ScriptedPlugin.scriptedSettings libraryDependencies ++= { - if (sbtVersion.value startsWith "0.13") + println(s"Evaluated ${sbtVersion in pluginCrossBuild value}") + if ((sbtVersion in pluginCrossBuild).value startsWith "0.13") Seq("com.github.mdr" %% "ascii-graphs" % "0.0.3") else Nil @@ -12,3 +13,19 @@ libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test" scalacOptions ++= Seq("-deprecation", "-unchecked") ScalariformSupport.formatSettings + +crossSbtVersions := Seq("1.0.1", "0.13.16") + +//sbtVersion in pluginCrossBuild := "1.0.0" + +/* +Try to prevent silly warnings + +libraryDependencies += ("org.scala-sbt" %% "main-settings" % "1.0.1-SNAPSHOT")//.excludeAll(ExclusionRule(organization = "org.scala-sbt")) + +libraryDependencies += "org.scala-sbt" %% "command" % "1.0.0"force() +libraryDependencies += "org.scala-sbt" %% "completion" % "1.0.0"force() +libraryDependencies += "org.scala-sbt" %% "task-system" % "1.0.0"force() +libraryDependencies += "org.scala-sbt" %% "core-macros" % "1.0.0" force() + +*/ \ No newline at end of file diff --git a/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala b/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala new file mode 100644 index 000000000..c3d8570bd --- /dev/null +++ b/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala @@ -0,0 +1,11 @@ +package sbt.compat + +object SbtCompat { + object librarymanagement + object internal { + object librarymanagement + object util { + val JLine: { def usingTerminal[T](f: jline.Terminal => T): T } = sbt.JLine + } + } +} \ No newline at end of file diff --git a/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala b/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala new file mode 100644 index 000000000..9da65489d --- /dev/null +++ b/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala @@ -0,0 +1,3 @@ +package sbt.compat + +object SbtCompat \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 790453585..fd3828488 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -25,48 +25,58 @@ import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML } import net.virtualvoid.sbt.graph.util.IOUtil +import sbt.compat.SbtCompat._ +import internal.librarymanagement._ +import librarymanagement._ + object DependencyGraphSettings { import DependencyGraphKeys._ import ModuleGraphProtocol._ def graphSettings = Seq( - ivyReportFunction <<= ivyReportFunctionTask, - updateConfiguration in ignoreMissingUpdate <<= updateConfiguration(config ⇒ new UpdateConfiguration(config.retrieve, true, config.logging)), - ignoreMissingUpdateT, + ivyReportFunction := ivyReportFunctionTask.value, + updateConfiguration in ignoreMissingUpdate := updateConfiguration.value.withMissingOk(true), + ignoreMissingUpdate := update.value, filterScalaLibrary in Global := true) ++ Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) def ivyReportForConfig(config: Configuration) = inConfig(config)(Seq( - ivyReport <<= ivyReportFunction map (_(config.toString)) dependsOn (ignoreMissingUpdate), - crossProjectId <<= (scalaVersion, scalaBinaryVersion, projectID)((sV, sBV, id) ⇒ CrossVersion(sV, sBV)(id)), - moduleGraphSbt <<= moduleGraphSbtTask, - moduleGraphIvyReport <<= moduleGraphIvyReportTask, - moduleGraph <<= (sbtVersion, moduleGraphSbt, moduleGraphIvyReport) { (version, graphSbt, graphIvy) ⇒ - version match { - case Version(0, 13, x, _) if x >= 6 ⇒ graphSbt - case _ ⇒ graphIvy + ivyReport := { Def.task { ivyReportFunction.value.apply(config.toString) } dependsOn (ignoreMissingUpdate) }.value, + crossProjectId := sbt.CrossVersion(scalaVersion.value, scalaBinaryVersion.value)(projectID.value), + moduleGraphSbt := + ignoreMissingUpdate.value.configuration(configuration.value).map(report ⇒ SbtUpdateReport.fromConfigurationReport(report, crossProjectId.value)).getOrElse(ModuleGraph.empty), + moduleGraphIvyReport := IvyReport.fromReportFile(absoluteReportPath(ivyReport.value)), + moduleGraph := { + sbtVersion.value match { + case Version(0, 13, x, _) if x >= 6 ⇒ moduleGraphSbt.value + case Version(1, _, _, _) ⇒ moduleGraphSbt.value } }, - moduleGraph <<= (scalaVersion, moduleGraph, filterScalaLibrary) map { (scalaV, graph, filter) ⇒ - if (filter) GraphTransformations.ignoreScalaLibrary(scalaV, graph) - else graph + moduleGraph := { + // FIXME: remove busywork + val scalaVersion = Keys.scalaVersion.value + val moduleGraph = DependencyGraphKeys.moduleGraph.value + + if (filterScalaLibrary.value) GraphTransformations.ignoreScalaLibrary(scalaVersion, moduleGraph) + else moduleGraph }, - moduleGraphStore <<= moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph, - asciiTree <<= moduleGraph map rendering.AsciiTree.asciiTree, - dependencyTree <<= print(asciiTree), - dependencyGraphMLFile <<= target / "dependencies-%s.graphml".format(config.toString), - dependencyGraphML <<= dependencyGraphMLTask, - dependencyDotFile <<= target / "dependencies-%s.dot".format(config.toString), - dependencyDotString <<= dependencyDotStringTask, - dependencyDot <<= writeToFile(dependencyDotString, dependencyDotFile), - dependencyBrowseGraphTarget <<= target / "browse-dependency-graph", - dependencyBrowseGraphHTML <<= browseGraphHTMLTask, - dependencyBrowseGraph <<= (dependencyBrowseGraphHTML, streams).map { (uri, streams) ⇒ - streams.log.info("Opening in browser...") + moduleGraphStore := (moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph).value, + asciiTree := rendering.AsciiTree.asciiTree(moduleGraph.value), + dependencyTree := print(asciiTree).value, + dependencyGraphMLFile := { target.value / "dependencies-%s.graphml".format(config.toString) }, + dependencyGraphML := dependencyGraphMLTask.value, + dependencyDotFile := { target.value / "dependencies-%s.dot".format(config.toString) }, + dependencyDotString := rendering.DOT.dotGraph(moduleGraph.value, dependencyDotHeader.value, dependencyDotNodeLabel.value, rendering.DOT.AngleBrackets), + dependencyDot := writeToFile(dependencyDotString, dependencyDotFile).value, + dependencyBrowseGraphTarget := { target.value / "browse-dependency-graph" }, + dependencyBrowseGraphHTML := browseGraphHTMLTask.value, + dependencyBrowseGraph := { + val uri = dependencyBrowseGraphHTML.value + streams.value.log.info("Opening in browser...") java.awt.Desktop.getDesktop.browse(uri) uri }, - dependencyList <<= printFromGraph(rendering.FlatList.render(_, _.id.idString)), - dependencyStats <<= printFromGraph(rendering.Statistics.renderModuleStatsList), + dependencyList := printFromGraph(rendering.FlatList.render(_, _.id.idString)).value, + dependencyStats := printFromGraph(rendering.Statistics.renderModuleStatsList).value, dependencyDotHeader := """digraph "dependency-graph" { | graph[rankdir="LR"] | edge [ @@ -75,79 +85,71 @@ object DependencyGraphSettings { dependencyDotNodeLabel := { (organisation: String, name: String, version: String) ⇒ """%s
%s
%s""".format(organisation, name, version) }, - whatDependsOn <<= InputTask(artifactIdParser) { module ⇒ - (module, streams, moduleGraph) map { (module, streams, graph) ⇒ - streams.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(graph, module))) - } + whatDependsOn := { + val module = artifactIdParser.parsed + streams.value.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(moduleGraph.value, module))) }, - licenseInfo <<= (moduleGraph, streams) map showLicenseInfo) ++ AsciiGraph.asciiGraphSetttings) + licenseInfo := showLicenseInfo(moduleGraph.value, streams.value)) ++ AsciiGraph.asciiGraphSetttings) - def ivyReportFunctionTask = - (sbtVersion, target, projectID, ivyModule, appConfiguration, streams) map { (sbtV, target, projectID, ivyModule, config, streams) ⇒ - sbtV match { - case Version(0, min, fix, _) if min > 12 || (min == 12 && fix >= 3) ⇒ - (c: String) ⇒ file("%s/resolution-cache/reports/%s-%s-%s.xml".format(target, projectID.organization, crossName(ivyModule), c)) - case Version(0, min, fix, _) if min == 12 && fix >= 1 && fix < 3 ⇒ - ivyModule.withModule(streams.log) { (i, moduleDesc, _) ⇒ - val id = ResolveOptions.getDefaultResolveId(moduleDesc) - (c: String) ⇒ file("%s/resolution-cache/reports/%s/%s-resolved.xml" format (target, id, c)) - } - case _ ⇒ - val home = config.provider.scalaProvider.launcher.ivyHome - (c: String) ⇒ file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c)) - } + def ivyReportFunctionTask = Def.task { + // FIXME: and remove busywork after https://github.com/sbt/sbt/issues/3299 is fixed + val target = Keys.target.value + val projectID = Keys.projectID.value + val ivyModule = Keys.ivyModule.value + + sbtVersion.value match { + case Version(0, min, fix, _) if min > 12 || (min == 12 && fix >= 3) ⇒ + (c: String) ⇒ file("%s/resolution-cache/reports/%s-%s-%s.xml".format(target, projectID.organization, crossName(ivyModule), c)) + case Version(0, min, fix, _) if min == 12 && fix >= 1 && fix < 3 ⇒ + ivyModule.withModule(streams.value.log) { (i, moduleDesc, _) ⇒ + val id = ResolveOptions.getDefaultResolveId(moduleDesc) + (c: String) ⇒ file("%s/resolution-cache/reports/%s/%s-resolved.xml" format (target, id, c)) + } + case _ ⇒ + val home = appConfiguration.value.provider.scalaProvider.launcher.ivyHome + (c: String) ⇒ file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c)) } - - def moduleGraphIvyReportTask = ivyReport map (absoluteReportPath.andThen(IvyReport.fromReportFile)) - def moduleGraphSbtTask = - (ignoreMissingUpdate, crossProjectId, configuration) map { (update, root, config) ⇒ - update.configuration(config.name).map(report ⇒ SbtUpdateReport.fromConfigurationReport(report, root)).getOrElse(ModuleGraph.empty) - } - - def printAsciiGraphTask = - (streams, asciiGraph) map (_.log.info(_)) + } def dependencyGraphMLTask = - (moduleGraph, dependencyGraphMLFile, streams) map { (graph, resultFile, streams) ⇒ - rendering.GraphML.saveAsGraphML(graph, resultFile.getAbsolutePath) - streams.log.info("Wrote dependency graph to '%s'" format resultFile) + Def.task { + val resultFile = dependencyGraphMLFile.value + rendering.GraphML.saveAsGraphML(moduleGraph.value, resultFile.getAbsolutePath) + streams.value.log.info("Wrote dependency graph to '%s'" format resultFile) resultFile } - def dependencyDotStringTask = - (moduleGraph, dependencyDotHeader, dependencyDotNodeLabel).map { - (graph, dotHead, nodeLabel) ⇒ rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.AngleBrackets) - } def browseGraphHTMLTask = - (moduleGraph, dependencyDotHeader, dependencyDotNodeLabel, dependencyBrowseGraphTarget, streams).map { (graph, dotHead, nodeLabel, target, streams) ⇒ - val dotGraph = rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.LabelTypeHtml) - val link = DagreHTML.createLink(dotGraph, target) - streams.log.info(s"HTML graph written to $link") + Def.task { + val dotGraph = rendering.DOT.dotGraph(moduleGraph.value, dependencyDotHeader.value, dependencyDotNodeLabel.value, rendering.DOT.LabelTypeHtml) + val link = DagreHTML.createLink(dotGraph, target.value) + streams.value.log.info(s"HTML graph written to $link") link } def writeToFile(dataTask: TaskKey[String], fileTask: SettingKey[File]) = - (dataTask, fileTask, streams).map { (data, outFile, streams) ⇒ - IOUtil.writeToFile(data, outFile) + Def.task { + val outFile = fileTask.value + IOUtil.writeToFile(dataTask.value, outFile) - streams.log.info("Wrote dependency graph to '%s'" format outFile) + streams.value.log.info("Wrote dependency graph to '%s'" format outFile) outFile } def absoluteReportPath = (file: File) ⇒ file.getAbsolutePath def print(key: TaskKey[String]) = - (streams, key) map (_.log.info(_)) + Def.task { streams.value.log.info(key.value) } def printFromGraph(f: ModuleGraph ⇒ String) = - (streams, moduleGraph) map ((streams, graph) ⇒ streams.log.info(f(graph))) + Def.task { streams.value.log.info(f(moduleGraph.value)) } def showLicenseInfo(graph: ModuleGraph, streams: TaskStreams) { val output = graph.nodes.filter(_.isUsed).groupBy(_.license).toSeq.sortBy(_._1).map { case (license, modules) ⇒ license.getOrElse("No license specified") + "\n" + - modules.map(_.id.idString formatted "\t %s").mkString("\n") + modules.map("\t %s" format _.id.idString).mkString("\n") }.mkString("\n\n") streams.log.info(output) } @@ -159,7 +161,7 @@ object DependencyGraphSettings { (Space ~> token("--force")).?.map(_.isDefined) } - val artifactIdParser: Initialize[State ⇒ Parser[ModuleId]] = + val artifactIdParser: Def.Initialize[State ⇒ Parser[ModuleId]] = resolvedScoped { ctx ⇒ (state: State) ⇒ val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(Nil, Nil) @@ -197,11 +199,17 @@ object DependencyGraphSettings { } /** - * This is copied directly from sbt/main/Defaults.java and then changed to update the UpdateConfiguration + * This is copied directly from sbt/main/Defaults.scala and then changed to update the UpdateConfiguration * to ignore missing artifacts. */ - def ignoreMissingUpdateT = - ignoreMissingUpdate <<= Def.task { + /*def ignoreMissingUpdateT = + ignoreMissingUpdate := { + // FIXME: remove busywork + + val scalaVersion = Keys.scalaVersion.value + val unmanagedScalaInstanceOnly = SbtAccess.unmanagedScalaInstanceOnly.value + val scalaOrganization = Keys.scalaOrganization.value + val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) val isRoot = executionRoots.value contains resolvedScoped.value val s = streams.value @@ -211,18 +219,19 @@ object DependencyGraphSettings { // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ - (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { + (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion)) match { case (Some(res), Some(sh), _) if res == sh ⇒ jars case (Some(res), _, Some(decl)) if res == decl ⇒ jars case _ ⇒ Nil } - val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { - case Some(si) ⇒ subUnmanaged(si.version, si.jars) + val subScalaJars: String ⇒ Seq[File] = unmanagedScalaInstanceOnly match { + case Some(si) ⇒ subUnmanaged(si.version, si.allJars) case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil } - val transform: UpdateReport ⇒ UpdateReport = r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + val transform: UpdateReport ⇒ UpdateReport = r ⇒ Classpaths.substituteScalaFiles(scalaOrganization, r)(subScalaJars) val show = Reference.display(thisProjectRef.value) - Classpaths.cachedUpdate(s.cacheDirectory, show, ivyModule.value, (updateConfiguration in ignoreMissingUpdate).value, transform, skip = (skip in update).value, force = isRoot, depsUpdated = depsUpdated, log = s.log) - } + SbtAccess.cachedUpdater( + s.cacheDirectory, show, ivyModule.value, (updateConfiguration in ignoreMissingUpdate).value, transform, skip = (skip in update).value, force = isRoot, depsUpdated = depsUpdated, log = s.log) + }*/ } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/model.scala b/src/main/scala/net/virtualvoid/sbt/graph/model.scala index 68b6a8862..850a43047 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/model.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/model.scala @@ -16,9 +16,13 @@ package net.virtualvoid.sbt.graph -import java.io.File +import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File } +import java.util.Base64 -import scala.collection.mutable.{ MultiMap, HashMap, Set } +import sbinary.{ JavaInput, JavaOutput } +import sjsonnew.{ Builder, Unbuilder } + +import scala.collection.mutable.{ HashMap, MultiMap, Set } case class ModuleId(organisation: String, name: String, @@ -71,4 +75,21 @@ object ModuleGraphProtocol extends DefaultProtocol { implicit val ModuleIdFormat: Format[ModuleId] = asProduct3(ModuleId)(ModuleId.unapply(_).get) implicit val ModuleFormat: Format[Module] = asProduct6(Module)(Module.unapply(_).get) implicit val ModuleGraphFormat: Format[ModuleGraph] = asProduct2(ModuleGraph.apply _)(ModuleGraph.unapply(_).get) + + // + implicit def sjsonNewAndShinyTransformAndTranspileAdapterFactoryModuleImplementation[T](implicit format: Format[T]): sjsonnew.JsonFormat[T] = + new sjsonnew.JsonFormat[T] { + // note, how this is simpler to write than to learn any sjonnew protocol syntax + def write[J](obj: T, builder: Builder[J]): Unit = { + val baos = new ByteArrayOutputStream() + format.writes(new JavaOutput(baos), obj) + val str = Base64.getEncoder.encodeToString(baos.toByteArray) + builder.writeString(str) + } + def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): T = { + val str = unbuilder.readString(jsOpt.get) + val bais = new ByteArrayInputStream(Base64.getDecoder.decode(str)) + format.reads(new JavaInput(bais)) + } + } } diff --git a/src/main/scala/sbt/SbtAccess.scala b/src/main/scala/sbt/SbtAccess.scala index a75a57c31..455e232e1 100644 --- a/src/main/scala/sbt/SbtAccess.scala +++ b/src/main/scala/sbt/SbtAccess.scala @@ -16,9 +16,18 @@ package sbt +import sbt.compat.SbtCompat._ +import librarymanagement._ +import internal._ +import librarymanagement._ +import Classpaths._ +import LibraryManagement._ +import internal.util.JLine + /** Accessors to private[sbt] symbols. */ object SbtAccess { val unmanagedScalaInstanceOnly = Defaults.unmanagedScalaInstanceOnly def getTerminalWidth: Int = JLine.usingTerminal(_.getWidth) + } From 58947bfec6ca26075375f4808da18bc1d9f7333e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Thu, 7 Sep 2017 17:04:59 +0200 Subject: [PATCH 12/38] Use sbt-compat lib --- build.sbt | 6 ++++++ project.sbt | 2 -- project/plugins.sbt | 1 + src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala | 11 ----------- src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala | 3 --- .../sbt/graph/DependencyGraphSettings.scala | 1 - src/main/scala/sbt/SbtAccess.scala | 3 --- 7 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala delete mode 100644 src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala diff --git a/build.sbt b/build.sbt index f33b9585a..30a72a31a 100644 --- a/build.sbt +++ b/build.sbt @@ -10,6 +10,12 @@ libraryDependencies ++= { libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test" +libraryDependencies += Defaults.sbtPluginExtra( + "com.dwijnand" % "sbt-compat" % "1.0.0+2-ae121c50", + (sbtBinaryVersion in pluginCrossBuild).value, + (scalaBinaryVersion in update).value +) + scalacOptions ++= Seq("-deprecation", "-unchecked") ScalariformSupport.formatSettings diff --git a/project.sbt b/project.sbt index 0d211ee31..8d6305446 100644 --- a/project.sbt +++ b/project.sbt @@ -4,8 +4,6 @@ name := "sbt-dependency-graph" organization := "net.virtual-void" -version := "0.8.3-SNAPSHOT" - homepage := Some(url("http://github.com/jrudolph/sbt-dependency-graph")) licenses in GlobalScope += "Apache License 2.0" -> url("https://github.com/jrudolph/sbt-dependency-graph/raw/master/LICENSE") diff --git a/project/plugins.sbt b/project/plugins.sbt index 0a919c7d8..576698340 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") +addSbtPlugin("com.dwijnand" % "sbt-dynver" % "2.0.0") diff --git a/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala b/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala deleted file mode 100644 index c3d8570bd..000000000 --- a/src/main/scala-sbt-0.13/sbt/compat/SbtCompat.scala +++ /dev/null @@ -1,11 +0,0 @@ -package sbt.compat - -object SbtCompat { - object librarymanagement - object internal { - object librarymanagement - object util { - val JLine: { def usingTerminal[T](f: jline.Terminal => T): T } = sbt.JLine - } - } -} \ No newline at end of file diff --git a/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala b/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala deleted file mode 100644 index 9da65489d..000000000 --- a/src/main/scala-sbt-1.0/sbt/compat/SbtCompat.scala +++ /dev/null @@ -1,3 +0,0 @@ -package sbt.compat - -object SbtCompat \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index fd3828488..15f0d8da2 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -25,7 +25,6 @@ import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML } import net.virtualvoid.sbt.graph.util.IOUtil -import sbt.compat.SbtCompat._ import internal.librarymanagement._ import librarymanagement._ diff --git a/src/main/scala/sbt/SbtAccess.scala b/src/main/scala/sbt/SbtAccess.scala index 455e232e1..6ddc71f48 100644 --- a/src/main/scala/sbt/SbtAccess.scala +++ b/src/main/scala/sbt/SbtAccess.scala @@ -16,10 +16,7 @@ package sbt -import sbt.compat.SbtCompat._ -import librarymanagement._ import internal._ -import librarymanagement._ import Classpaths._ import LibraryManagement._ import internal.util.JLine From 00c3ab7da65e133dc2056b6d0e1dff5f13c6a76d Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Fri, 6 Oct 2017 11:43:08 +0200 Subject: [PATCH 13/38] Upgrade to released sbt-compat 1.1.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 30a72a31a..1efc21333 100644 --- a/build.sbt +++ b/build.sbt @@ -11,7 +11,7 @@ libraryDependencies ++= { libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test" libraryDependencies += Defaults.sbtPluginExtra( - "com.dwijnand" % "sbt-compat" % "1.0.0+2-ae121c50", + "com.dwijnand" % "sbt-compat" % "1.1.0", (sbtBinaryVersion in pluginCrossBuild).value, (scalaBinaryVersion in update).value ) From 05ee0e4f1d67793df7c669d52aa4c34244db9144 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Fri, 6 Oct 2017 11:43:27 +0200 Subject: [PATCH 14/38] Fix scripted tests and detect version automatically --- build.sbt | 1 + .../sbt-dependency-graph/ignoreScalaLibrary/build.sbt | 4 +++- .../ignoreScalaLibrary/project/build.properties | 1 - .../sbt-dependency-graph/intervalRangedVersions/build.sbt | 5 ++++- .../intervalRangedVersions/project/build.properties | 1 - src/sbt-test/sbt-dependency-graph/plugins.sbt | 2 +- .../sbt-dependency-graph/showMissingUpdates/build.sbt | 5 ++++- .../showMissingUpdates/project/build.properties | 1 - .../testDotFileGeneration/project/Build.scala | 3 ++- .../testDotFileGeneration/project/build.properties | 1 - 10 files changed, 15 insertions(+), 9 deletions(-) delete mode 120000 src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties diff --git a/build.sbt b/build.sbt index 1efc21333..15c1afcb6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ ScriptedPlugin.scriptedSettings +ScriptedPlugin.scriptedLaunchOpts += s"-Dproject.version=${version.value}" libraryDependencies ++= { println(s"Evaluated ${sbtVersion in pluginCrossBuild value}") diff --git a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt index 8c47bfc25..1d004c5b6 100644 --- a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt @@ -5,7 +5,9 @@ libraryDependencies ++= Seq( "ch.qos.logback" % "logback-classic" % "1.0.7" ) -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => +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).map(_.trim).mkString("\n") val expectedGraph = """default:default-e95e05_2.9.2:0.1-SNAPSHOT [S] diff --git a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt index 2cec07ae8..7521ddc46 100644 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt @@ -6,7 +6,10 @@ libraryDependencies ++= Seq( "com.codahale" % "jerkson_2.9.1" % "0.5.0" ) -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => +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).map(_.trim).mkString("\n") val expectedGraph = """default:default-dbc48d_2.9.2:0.1-SNAPSHOT [S] diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/plugins.sbt b/src/sbt-test/sbt-dependency-graph/plugins.sbt index 80a3cbfcc..6fdebb6d6 100644 --- a/src/sbt-test/sbt-dependency-graph/plugins.sbt +++ b/src/sbt-test/sbt-dependency-graph/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.3-SNAPSHOT") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % sys.props("project.version")) diff --git a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt index 6ca4b0313..da6ad1a2a 100644 --- a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt @@ -3,7 +3,10 @@ scalaVersion := "2.9.2" libraryDependencies += "at.blub" % "blib" % "1.2.3" % "test" -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => +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:default-91180e_2.9.2:0.1-SNAPSHOT diff --git a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala index d5081feb1..255092115 100644 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala +++ b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala @@ -27,7 +27,8 @@ object Build extends sbt.Build { Project("test-dot-file-generation", file("d")) .settings(defaultSettings: _*) .settings( - TaskKey[Unit]("check") <<= (dependencyDot in Compile) map { (dotFile) => + TaskKey[Unit]("check") := { + val dotFile = (dependencyDot in Compile).value val expectedGraph = """digraph "dependency-graph" { | graph[rankdir="LR"] diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file From 8591a5adaeac38abaaf51ac3409d0f702ea506d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Mon, 16 Oct 2017 13:32:54 +0200 Subject: [PATCH 15/38] Bump to sbt 0.13.16, drop support for sbt 0.12.x --- README.md | 23 +- build.sbt | 15 +- project/Helpers.scala | 16 -- project/build.properties | 2 +- project/pgp.sbt | 2 +- publish.sbt | 29 ++- .../sbt/graph/DependencyGraphSettings.scala | 218 ++++++++++-------- .../sbt/graph/backend/SbtUpdateReport.scala | 3 + .../sbt-dependency-graph/build.properties | 2 +- .../ignoreScalaLibrary/build.sbt | 26 ++- .../intervalRangedVersions/build.sbt | 17 +- .../showMissingUpdates/build.sbt | 8 +- .../testDotFileGeneration/build.sbt | 65 ++++++ .../testDotFileGeneration/project/Build.scala | 68 ------ 14 files changed, 262 insertions(+), 232 deletions(-) delete mode 100644 project/Helpers.scala create mode 100644 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt delete mode 100644 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala diff --git a/README.md b/README.md index 1e86e5f96..f8893990b 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ Visualize your project's dependencies. -## Preliminaries - -The plugin works best with sbt >= 0.13.6. See the [compatibility notes](#compatibility-notes) to use this plugin with an older version of sbt. - ## Usage Instructions Since sbt-dependency-graph is an informational tool rather than one that changes your build, you will more than likely wish to @@ -20,8 +16,6 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") To add the plugin only to a single project, put this line into `project/plugins.sbt` of your project, instead. -This plugin is an auto-plugin which will be automatically enabled starting from sbt 0.13.5. - ## Main Tasks * `dependencyTree`: Shows an ASCII tree representation of the project's dependencies @@ -66,20 +60,6 @@ dependencyDotFile := file("dependencies.dot") //render dot file to `./dependenci * [#19]: There's an unfixed bug with graph generation for particular layouts. Workaround: Use `dependency-tree` instead of `dependency-graph`. - * [#39]: When using sbt-dependency-graph with sbt < 0.13.6. - -## Compatibility notes - - * sbt < 0.13.6: The plugin will fall back on the old ivy report XML backend which suffers from [#39]. - * sbt < 0.13.5: Old versions of sbt have no `AutoPlugin` support, you need to add - -```scala -net.virtualvoid.sbt.graph.DependencyGraphSettings.graphSettings -``` - - to your `build.sbt` or (`~/.sbt/0.13/user.sbt` for global configuration) to enable the plugin. - * sbt <= 0.12.x: Old versions of sbt are not actively supported any more. Please use the old version from the [0.7 branch](https://github.com/jrudolph/sbt-dependency-graph/tree/0.7). - ## License @@ -87,5 +67,4 @@ Published under the [Apache License 2.0](http://en.wikipedia.org/wiki/Apache_lic [global plugin]: http://www.scala-sbt.org/0.13/tutorial/Using-Plugins.html#Global+plugins [global build configuration]: http://www.scala-sbt.org/0.13/docs/Global-Settings.html -[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 -[#39]: https://github.com/jrudolph/sbt-dependency-graph/issues/39 +[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 \ No newline at end of file diff --git a/build.sbt b/build.sbt index 6b4943943..3659705f3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,16 @@ ScriptedPlugin.scriptedSettings -libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.3" +libraryDependencies ++= Seq( + "com.github.mdr" %% "ascii-graphs" % "0.0.3", + "org.specs2" %% "specs2" % "2.3.11" % Test +) -libraryDependencies += "org.specs2" %% "specs2" % "2.3.11" % "test" - -scalacOptions ++= Seq("-deprecation", "-unchecked") +scalacOptions ++= Seq( + "-deprecation", + "-encoding", + "UTF-8", + "-feature", + "-unchecked" +) ScalariformSupport.formatSettings diff --git a/project/Helpers.scala b/project/Helpers.scala deleted file mode 100644 index 4c426be62..000000000 --- a/project/Helpers.scala +++ /dev/null @@ -1,16 +0,0 @@ -import java.net.URL - -object Helpers { - def generatePomExtra(scmUrl: String, scmConnection: String, - developerId: String, developerName: String): xml.NodeSeq = - - { scmUrl } - { scmConnection } - - - - { developerId } - { developerName } - - -} \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index a6e117b61..406a7d255 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.8 +sbt.version=0.13.16 \ No newline at end of file diff --git a/project/pgp.sbt b/project/pgp.sbt index 4ce4d9ed4..2efcc4b69 100644 --- a/project/pgp.sbt +++ b/project/pgp.sbt @@ -1 +1 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") diff --git a/publish.sbt b/publish.sbt index 9d44a4f3a..65b3c0489 100644 --- a/publish.sbt +++ b/publish.sbt @@ -1,7 +1,11 @@ -publishTo <<= version { v: String => +publishTo := { val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots") - else Some("releases" at nexus + "service/local/staging/deploy/maven2") + if (version.value.trim.endsWith("SNAPSHOT")) { + Some("snapshots" at nexus + "content/repositories/snapshots") + } + else { + Some("releases" at nexus + "service/local/staging/deploy/maven2") + } } publishMavenStyle := true @@ -10,9 +14,20 @@ publishArtifact in Test := false pomIncludeRepository := { _ => false } -pomExtra := - Helpers.generatePomExtra("git@github.com:jrudolph/sbt-dependency-graph.git", - "scm:git:git@github.com:jrudolph/sbt-dependency-graph.git", - "jrudolph", "Johannes Rudolph") +scmInfo := Some( + ScmInfo( + browseUrl = url("https://github.com/jrudolph/sbt-dependency-graph"), + connection = "scm:git:git@github.com:jrudolph/sbt-dependency-graph.git" + ) +) + +developers := List( + Developer( + "jrudolph", + "Johannes Rudolph", + "johannes.rudolph@gmail.com", + url("http://virtual-void.net") + ) +) useGpg := true diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index ab0fd6779..5c66eb37f 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -29,139 +29,154 @@ import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } import net.virtualvoid.sbt.graph.rendering.DagreHTML import net.virtualvoid.sbt.graph.util.IOUtil +import scala.language.reflectiveCalls + object DependencyGraphSettings { import DependencyGraphKeys._ import ModuleGraphProtocol._ def graphSettings = Seq( - ivyReportFunction <<= ivyReportFunctionTask, - updateConfiguration in ignoreMissingUpdate <<= updateConfiguration(config ⇒ new UpdateConfiguration(config.retrieve, true, config.logging)), + ivyReportFunction := ivyReportFunctionTask.value, + updateConfiguration in ignoreMissingUpdate := { + val config = updateConfiguration.value + new UpdateConfiguration(config.retrieve, true, config.logging) + }, ignoreMissingUpdateT, filterScalaLibrary in Global := true) ++ Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) def ivyReportForConfig(config: Configuration) = inConfig(config)(Seq( - ivyReport <<= ivyReportFunction map (_(config.toString)) dependsOn (ignoreMissingUpdate), - crossProjectId <<= (scalaVersion, scalaBinaryVersion, projectID)((sV, sBV, id) ⇒ CrossVersion(sV, sBV)(id)), - moduleGraphSbt <<= moduleGraphSbtTask, - moduleGraphIvyReport <<= moduleGraphIvyReportTask, - moduleGraph <<= (sbtVersion, moduleGraphSbt, moduleGraphIvyReport) { (version, graphSbt, graphIvy) ⇒ - version match { - case Version(0, 13, x, _) if x >= 6 ⇒ graphSbt - case _ ⇒ graphIvy - } + ivyReport := { + Def.task { + ivyReportFunction.value.apply(config.toString) + }.dependsOn(ignoreMissingUpdate) + }.value, + crossProjectId := sbt.CrossVersion( + scalaVersion.value, + scalaBinaryVersion.value)(projectID.value), + moduleGraphSbt := { + val update = ignoreMissingUpdate.value + val root = crossProjectId.value + val config = configuration.value + + update.configuration(config.name).map(report ⇒ + SbtUpdateReport.fromConfigurationReport(report, root)).getOrElse(ModuleGraph.empty) }, - moduleGraph <<= (scalaVersion, moduleGraph, filterScalaLibrary) map { (scalaV, graph, filter) ⇒ + moduleGraphIvyReport := { + IvyReport.fromReportFile(absoluteReportPath(ivyReport.value)) + }, + moduleGraph := { + val graphSbt = moduleGraphSbt.value + val graphIvy = moduleGraphIvyReport.value + val filter = filterScalaLibrary.value + val scalaV = scalaVersion.value + + val graph = + sbtVersion.value match { + case Version(0, 13, x, _) if x >= 6 ⇒ graphSbt + case Version(1, _, _, _) ⇒ graphSbt + case _ ⇒ graphIvy + } + if (filter) GraphTransformations.ignoreScalaLibrary(scalaV, graph) else graph }, - moduleGraphStore <<= moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph, - asciiGraph <<= moduleGraph map rendering.AsciiGraph.asciiGraph, - dependencyGraph <<= InputTask(shouldForceParser) { force ⇒ - (force, moduleGraph, streams) map { (force, graph, streams) ⇒ - if (force || graph.nodes.size < 15) { - streams.log.info(rendering.AsciiGraph.asciiGraph(graph)) - streams.log.info("\n\n") - streams.log.info("Note: The old tree layout is still available by using `dependency-tree`") - } else { - streams.log.info(rendering.AsciiTree.asciiTree(graph)) + moduleGraphStore := (moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph).value, + asciiGraph := rendering.AsciiGraph.asciiGraph(moduleGraph.value), + dependencyGraph := { + val force = shouldForceParser.parsed + val log = streams.value.log + val graph = moduleGraph.value - if (!force) { - streams.log.info("\n") - streams.log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.") - } - } + if (force || graph.nodes.size < 15) { + log.info(rendering.AsciiGraph.asciiGraph(graph)) + log.info("\n\n") + log.info("Note: The old tree layout is still available by using `dependency-tree`") + } + + log.info(rendering.AsciiTree.asciiTree(graph)) + + if (!force) { + log.info("\n") + log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.") } }, - asciiTree <<= moduleGraph map rendering.AsciiTree.asciiTree, - dependencyTree <<= print(asciiTree), - dependencyGraphMLFile <<= target / "dependencies-%s.graphml".format(config.toString), - dependencyGraphML <<= dependencyGraphMLTask, - dependencyDotFile <<= target / "dependencies-%s.dot".format(config.toString), - dependencyDotString <<= dependencyDotStringTask, - dependencyDot <<= writeToFile(dependencyDotString, dependencyDotFile), - dependencyBrowseGraphTarget <<= target / "browse-dependency-graph", - dependencyBrowseGraphHTML <<= browseGraphHTMLTask, - dependencyBrowseGraph <<= (dependencyBrowseGraphHTML, streams).map { (uri, streams) ⇒ - streams.log.info("Opening in browser...") + asciiTree := rendering.AsciiTree.asciiTree(moduleGraph.value), + dependencyTree := print(asciiTree).value, + dependencyGraphMLFile := { target.value / "dependencies-%s.graphml".format(config.toString) }, + dependencyGraphML := dependencyGraphMLTask.value, + dependencyDotFile := { target.value / "dependencies-%s.dot".format(config.toString) }, + dependencyDotString := rendering.DOT.dotGraph(moduleGraph.value, dependencyDotHeader.value, dependencyDotNodeLabel.value, rendering.DOT.AngleBrackets), + dependencyDot := writeToFile(dependencyDotString, dependencyDotFile).value, + dependencyBrowseGraphTarget := { target.value / "browse-dependency-graph" }, + dependencyBrowseGraphHTML := browseGraphHTMLTask.value, + dependencyBrowseGraph := { + val uri = dependencyBrowseGraphHTML.value + streams.value.log.info("Opening in browser...") java.awt.Desktop.getDesktop.browse(uri) uri }, - dependencyList <<= printFromGraph(rendering.FlatList.render(_, _.id.idString)), - dependencyStats <<= printFromGraph(rendering.Statistics.renderModuleStatsList), - dependencyDotHeader := """digraph "dependency-graph" { - | graph[rankdir="LR"] - | edge [ - | arrowtail="none" - | ]""".stripMargin, + dependencyList := printFromGraph(rendering.FlatList.render(_, _.id.idString)).value, + dependencyStats := printFromGraph(rendering.Statistics.renderModuleStatsList).value, + dependencyDotHeader := { + """|digraph "dependency-graph" { + | graph[rankdir="LR"] + | edge [ + | arrowtail="none" + | ]""".stripMargin + }, dependencyDotNodeLabel := { (organisation: String, name: String, version: String) ⇒ """%s
%s
%s""".format(organisation, name, version) }, - whatDependsOn <<= InputTask(artifactIdParser) { module ⇒ - (module, streams, moduleGraph) map { (module, streams, graph) ⇒ - streams.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(graph, module))) - } + whatDependsOn := { + val module = artifactIdParser.parsed + streams.value.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(moduleGraph.value, module))) }, - licenseInfo <<= (moduleGraph, streams) map showLicenseInfo)) + licenseInfo := showLicenseInfo(moduleGraph.value, streams.value))) - def ivyReportFunctionTask = - (sbtVersion, target, projectID, ivyModule, appConfiguration, streams) map { (sbtV, target, projectID, ivyModule, config, streams) ⇒ - sbtV match { - case Version(0, min, fix, _) if min > 12 || (min == 12 && fix >= 3) ⇒ - (c: String) ⇒ file("%s/resolution-cache/reports/%s-%s-%s.xml".format(target, projectID.organization, crossName(ivyModule), c)) - case Version(0, min, fix, _) if min == 12 && fix >= 1 && fix < 3 ⇒ - ivyModule.withModule(streams.log) { (i, moduleDesc, _) ⇒ - val id = ResolveOptions.getDefaultResolveId(moduleDesc) - (c: String) ⇒ file("%s/resolution-cache/reports/%s/%s-resolved.xml" format (target, id, c)) - } - case _ ⇒ - val home = config.provider.scalaProvider.launcher.ivyHome - (c: String) ⇒ file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c)) - } + def ivyReportFunctionTask = Def.task { + val crossTarget = Keys.crossTarget.value + val projectID = Keys.projectID.value + val ivyModule = Keys.ivyModule.value + + (config: String) ⇒ { + val org = projectID.organization + val name = crossName(ivyModule) + file(s"${crossTarget}/resolution-cache/reports/$org-$name-$config.xml") } - - def moduleGraphIvyReportTask = ivyReport map (absoluteReportPath.andThen(IvyReport.fromReportFile)) - def moduleGraphSbtTask = - (ignoreMissingUpdate, crossProjectId, configuration) map { (update, root, config) ⇒ - update.configuration(config.name).map(report ⇒ SbtUpdateReport.fromConfigurationReport(report, root)).getOrElse(ModuleGraph.empty) - } - - def printAsciiGraphTask = - (streams, asciiGraph) map (_.log.info(_)) + } def dependencyGraphMLTask = - (moduleGraph, dependencyGraphMLFile, streams) map { (graph, resultFile, streams) ⇒ - rendering.GraphML.saveAsGraphML(graph, resultFile.getAbsolutePath) - streams.log.info("Wrote dependency graph to '%s'" format resultFile) + Def.task { + val resultFile = dependencyGraphMLFile.value + rendering.GraphML.saveAsGraphML(moduleGraph.value, resultFile.getAbsolutePath) + streams.value.log.info("Wrote dependency graph to '%s'" format resultFile) resultFile } - def dependencyDotStringTask = - (moduleGraph, dependencyDotHeader, dependencyDotNodeLabel).map { - (graph, dotHead, nodeLabel) ⇒ rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.AngleBrackets) - } def browseGraphHTMLTask = - (moduleGraph, dependencyDotHeader, dependencyDotNodeLabel, dependencyBrowseGraphTarget, streams).map { (graph, dotHead, nodeLabel, target, streams) ⇒ - val dotGraph = rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.LabelTypeHtml) - val link = DagreHTML.createLink(dotGraph, target) - streams.log.info(s"HTML graph written to $link") + Def.task { + val dotGraph = rendering.DOT.dotGraph(moduleGraph.value, dependencyDotHeader.value, dependencyDotNodeLabel.value, rendering.DOT.LabelTypeHtml) + val link = DagreHTML.createLink(dotGraph, target.value) + streams.value.log.info(s"HTML graph written to $link") link } def writeToFile(dataTask: TaskKey[String], fileTask: SettingKey[File]) = - (dataTask, fileTask, streams).map { (data, outFile, streams) ⇒ - IOUtil.writeToFile(data, outFile) + Def.task { + val outFile = fileTask.value + IOUtil.writeToFile(dataTask.value, outFile) - streams.log.info("Wrote dependency graph to '%s'" format outFile) + streams.value.log.info("Wrote dependency graph to '%s'" format outFile) outFile } def absoluteReportPath = (file: File) ⇒ file.getAbsolutePath def print(key: TaskKey[String]) = - (streams, key) map (_.log.info(_)) + Def.task { streams.value.log.info(key.value) } def printFromGraph(f: ModuleGraph ⇒ String) = - (streams, moduleGraph) map ((streams, graph) ⇒ streams.log.info(f(graph))) + Def.task { streams.value.log.info(f(moduleGraph.value)) } def showLicenseInfo(graph: ModuleGraph, streams: TaskStreams) { val output = @@ -180,7 +195,7 @@ object DependencyGraphSettings { (Space ~> token("--force")).?.map(_.isDefined) } - val artifactIdParser: Initialize[State ⇒ Parser[ModuleId]] = + val artifactIdParser: Def.Initialize[State ⇒ Parser[ModuleId]] = resolvedScoped { ctx ⇒ (state: State) ⇒ val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(Nil, Nil) @@ -222,7 +237,7 @@ object DependencyGraphSettings { * to ignore missing artifacts. */ def ignoreMissingUpdateT = - ignoreMissingUpdate <<= Def.task { + ignoreMissingUpdate := Def.task { val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) val isRoot = executionRoots.value contains resolvedScoped.value val s = streams.value @@ -237,13 +252,26 @@ object DependencyGraphSettings { case (Some(res), _, Some(decl)) if res == decl ⇒ jars case _ ⇒ Nil } + val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { case Some(si) ⇒ subUnmanaged(si.version, si.jars) case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil } - val transform: UpdateReport ⇒ UpdateReport = r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + + val transform: UpdateReport ⇒ UpdateReport = + r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) val show = Reference.display(thisProjectRef.value) - Classpaths.cachedUpdate(s.cacheDirectory, show, ivyModule.value, (updateConfiguration in ignoreMissingUpdate).value, transform, skip = (skip in update).value, force = isRoot, depsUpdated = depsUpdated, log = s.log) - } -} + + Classpaths.cachedUpdate( + cacheFile = s.cacheDirectory, + label = show, + module = ivyModule.value, + config = (updateConfiguration in ignoreMissingUpdate).value, + transform = transform, + skip = (skip in update).value, + force = isRoot, + depsUpdated = depsUpdated, + log = s.log) + }.value +} \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala index f5596269a..9a8c4787a 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala @@ -19,6 +19,9 @@ package backend import sbt._ +import scala.language.implicitConversions +import scala.language.reflectiveCalls + object SbtUpdateReport { type OrganizationArtifactReport = { def modules: Seq[ModuleReport] diff --git a/src/sbt-test/sbt-dependency-graph/build.properties b/src/sbt-test/sbt-dependency-graph/build.properties index df58110af..406a7d255 100644 --- a/src/sbt-test/sbt-dependency-graph/build.properties +++ b/src/sbt-test/sbt-dependency-graph/build.properties @@ -1 +1 @@ -sbt.version=0.13.6 \ No newline at end of file +sbt.version=0.13.16 \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt index 8c47bfc25..bb28eae3d 100644 --- a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/build.sbt @@ -1,21 +1,27 @@ -scalaVersion := "2.9.2" +scalaVersion := "2.12.3" libraryDependencies ++= Seq( "org.slf4j" % "slf4j-api" % "1.7.2", "ch.qos.logback" % "logback-classic" % "1.0.7" ) -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => +TaskKey[Unit]("check") := { + val report = (ivyReport in Test).value + val graph = (asciiTree in Test).value + val scalaV = scalaVersion.value + def sanitize(str: String): String = str.split('\n').drop(1).map(_.trim).mkString("\n") + val expectedGraph = - """default:default-e95e05_2.9.2:0.1-SNAPSHOT [S] - | +-ch.qos.logback:logback-classic:1.0.7 - | | +-ch.qos.logback:logback-core:1.0.7 - | | +-org.slf4j:slf4j-api:1.6.6 (evicted by: 1.7.2) - | | +-org.slf4j:slf4j-api:1.7.2 - | | - | +-org.slf4j:slf4j-api:1.7.2 - | """.stripMargin + s"""|default:default-e95e05_${scalaV}:0.1-SNAPSHOT [S] + | +-ch.qos.logback:logback-classic:1.0.7 + | | +-ch.qos.logback:logback-core:1.0.7 + | | +-org.slf4j:slf4j-api:1.6.6 (evicted by: 1.7.2) + | | +-org.slf4j:slf4j-api:1.7.2 + | | + | +-org.slf4j:slf4j-api:1.7.2 + | """.stripMargin + IO.writeLines(file("/tmp/blib"), sanitize(graph).split("\n")) IO.writeLines(file("/tmp/blub"), sanitize(expectedGraph).split("\n")) 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/intervalRangedVersions/build.sbt b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt index 2cec07ae8..4ec5f7d51 100644 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt @@ -6,17 +6,24 @@ libraryDependencies ++= Seq( "com.codahale" % "jerkson_2.9.1" % "0.5.0" ) -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => +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).map(_.trim).mkString("\n") + + // latest: 1.9.13 + // http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.jackson%22%20AND%20a%3A%22jackson-core-asl%22 + val expectedGraph = """default:default-dbc48d_2.9.2:0.1-SNAPSHOT [S] | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | +-org.codehaus.jackson:jackson-core-asl:1.9.13 - | +-org.codehaus.jackson:jackson-mapper-asl:1.9.13 - | +-org.codehaus.jackson:jackson-core-asl:1.9.13 + | +-org.codehaus.jackson:jackson-core-asl:1.9.11 + | +-org.codehaus.jackson:jackson-mapper-asl:1.9.11 + | +-org.codehaus.jackson:jackson-core-asl:1.9.11 | """.stripMargin IO.writeLines(file("/tmp/blib"), sanitize(graph).split("\n")) IO.writeLines(file("/tmp/blub"), sanitize(expectedGraph).split("\n")) require(sanitize(graph) == sanitize(expectedGraph), "Graph for report %s was '\n%s' but should have been '\n%s'" format (report, sanitize(graph), sanitize(expectedGraph))) () -} +} \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt index 6ca4b0313..86455cc25 100644 --- a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt @@ -3,8 +3,12 @@ scalaVersion := "2.9.2" libraryDependencies += "at.blub" % "blib" % "1.2.3" % "test" -TaskKey[Unit]("check") <<= (ivyReport in Test, asciiTree in Test) map { (report, graph) => - def sanitize(str: String): String = str.split('\n').drop(1).mkString("\n") +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).map(_.trim).mkString("\n") + val expectedGraph = """default:default-91180e_2.9.2:0.1-SNAPSHOT | +-%sat.blub:blib:1.2.3 (error: not found)%s diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt new file mode 100644 index 000000000..6f3281886 --- /dev/null +++ b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt @@ -0,0 +1,65 @@ +import collection.mutable.ListBuffer + +def defaultSettings = Seq(scalaVersion := "2.12.3") + +lazy val `just-a-transitive-dependency-endpoint` = + project + .in(file("a")) + .settings(defaultSettings) + +lazy val `just-a-transitive-dependency` = + project + .in(file("b")) + .settings(defaultSettings) + .dependsOn(`just-a-transitive-dependency-endpoint`) + +lazy val `just-a-dependency` = + project + .in(file("c")) + .settings(defaultSettings) + +lazy val `test-dot-file-generation` = + project + .in(file("d")) + .settings(defaultSettings) + .settings( + TaskKey[Unit]("check") := { + val dotFile = (dependencyDot in Compile).value + val scalaV = scalaBinaryVersion.value + + val expectedGraph = + s"""|digraph "dependency-graph" { + | graph[rankdir="LR"] + | edge [ + | arrowtail="none" + | ] + | "test-dot-file-generation:test-dot-file-generation_${scalaV}:0.1-SNAPSHOT"[label=test-dot-file-generation_${scalaV}
0.1-SNAPSHOT> style=""] + | "just-a-transitive-dependency:just-a-transitive-dependency_${scalaV}:0.1-SNAPSHOT"[label=just-a-transitive-dependency_${scalaV}
0.1-SNAPSHOT> style=""] + | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_${scalaV}:0.1-SNAPSHOT"[label=just-a-transitive-dependency-endpoint_${scalaV}
0.1-SNAPSHOT> style=""] + | "just-a-dependency:just-a-dependency_${scalaV}:0.1-SNAPSHOT"[label=just-a-dependency_${scalaV}
0.1-SNAPSHOT> style=""] + | "test-dot-file-generation:test-dot-file-generation_${scalaV}:0.1-SNAPSHOT" -> "just-a-transitive-dependency:just-a-transitive-dependency_${scalaV}:0.1-SNAPSHOT" + | "just-a-transitive-dependency:just-a-transitive-dependency_${scalaV}:0.1-SNAPSHOT" -> "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_${scalaV}:0.1-SNAPSHOT" + | "test-dot-file-generation:test-dot-file-generation_${scalaV}:0.1-SNAPSHOT" -> "just-a-dependency:just-a-dependency_${scalaV}:0.1-SNAPSHOT" + |}""".stripMargin + + val graph : String = scala.io.Source.fromFile(dotFile.getAbsolutePath).mkString + val errors = compareByLine(graph, expectedGraph) + require(errors.isEmpty , errors.mkString("\n")) + () + } + ) + .dependsOn(`just-a-dependency`, `just-a-transitive-dependency`) + +def compareByLine(got : String, expected : String) : Seq[String] = { + val errors = ListBuffer[String]() + got.split("\n").zip(expected.split("\n").toSeq).zipWithIndex.foreach { case((got_line : String, expected_line : String), i : Int) => + if(got_line != expected_line) { + errors.append( + """not matching lines at line %s + |expected: %s + |got: %s + |""".stripMargin.format(i,expected_line, got_line)) + } + } + errors +} \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala deleted file mode 100644 index d5081feb1..000000000 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala +++ /dev/null @@ -1,68 +0,0 @@ -import collection.mutable.ListBuffer - -import sbt._ -import sbt.Keys._ - -import net.virtualvoid.sbt.graph.DependencyGraphKeys._ - -object Build extends sbt.Build { - - def defaultSettings = - Seq(scalaVersion := "2.9.2") - - lazy val justATransiviteDependencyEndpointProject = - Project("just-a-transitive-dependency-endpoint", file("a")) - .settings(defaultSettings: _*) - - lazy val justATransitiveDependencyProject = - Project("just-a-transitive-dependency", file("b")) - .settings(defaultSettings: _*) - .dependsOn(justATransiviteDependencyEndpointProject) - - lazy val justADependencyProject = - Project("just-a-dependency", file("c")) - .settings(defaultSettings: _*) - - lazy val test_project = - Project("test-dot-file-generation", file("d")) - .settings(defaultSettings: _*) - .settings( - TaskKey[Unit]("check") <<= (dependencyDot in Compile) map { (dotFile) => - val expectedGraph = - """digraph "dependency-graph" { - | graph[rankdir="LR"] - | edge [ - | arrowtail="none" - | ] - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT"[label=test-dot-file-generation_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency-endpoint_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-dependency_2.9.2
0.1-SNAPSHOT> style=""] - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" - | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT" - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT" - |} - """.stripMargin - - val graph : String = scala.io.Source.fromFile(dotFile.getAbsolutePath).mkString - val errors = compareByLine(graph, expectedGraph) - require(errors.isEmpty , errors.mkString("\n")) - () - } - ) - .dependsOn(justADependencyProject, justATransitiveDependencyProject) - - def compareByLine(got : String, expected : String) : Seq[String] = { - val errors = ListBuffer[String]() - got.split("\n").zip(expected.split("\n").toSeq).zipWithIndex.foreach { case((got_line : String, expected_line : String), i : Int) => - if(got_line != expected_line) { - errors.append( - """not matching lines at line %s - |expected: %s - |got: %s - |""".stripMargin.format(i,expected_line, got_line)) - } - } - errors - } -} From 66f801bf92a34a7ffbc045b3875d343ee09ff617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Tue, 17 Oct 2017 00:06:55 +0200 Subject: [PATCH 16/38] Compiles with sbt 1.0 and sbt 0.13 1. ascii-graphs We need a 2.12 version of ascii-graphs. The last commit to the project is in June 2013 (https://github.com/mdr/ascii-graphs/graphs/contributors). We are now in October 2017. I opened a PR (https://github.com/mdr/ascii-graphs/pull/11) but I don't expect any progress on this front. We can maintain a fork or drop ascii-graphs. 2. ignoreMissingUpdate ignoreMissingUpdate is a tricky one. Here is some explanation: we need to duplicate the updateTask in sbt it's define as: ```scala def updateTask: Initialize[Task[UpdateReport]] = Def.task { // ... val uc0 = updateConfiguration.value // ... } ``` since it's not scoped to our task (ex: `updateConfiguration in ignoreMissingUpdate`) we cannot just do ```scala updateConfiguration in ignoreMissingUpdate := { updateConfiguration.value.withMissingOk(true) } ``` For example, the following example yield `"u2: false" ``` val update2 = TaskKey[Unit]("update2", "...") val update2Configuration = SettingKey[Boolean]("...") update2 := Def.task { val u2 = (update2Configuration in update2).value println(s"u2: $u2") }.value update2Configuration := false update2Configuration in update2 := true ``` 3. cross publishing We can use the ^ operator to publish. For example: `sbt "^ publish"` to publish for both sbt 0.13 and 1.0. --- .travis.yml | 10 ++- build.sbt | 15 +++- .../scala/net/virtualvoid/graph/compat.scala | 25 +++++++ .../scala/net/virtualvoid/graph/model.scala | 26 +++++++ .../scala-sbt-0.13/scala/sbt/compat.scala | 48 ++++++++++++ .../scala/net/virtualvoid/graph/compat.scala | 19 +++++ .../scala/net/virtualvoid/graph/model.scala | 70 ++++++++++++++++++ src/main/scala-sbt-1.0/scala/sbt/compat.scala | 62 ++++++++++++++++ .../sbt/graph/DependencyGraphSettings.scala | 74 +++++-------------- .../net/virtualvoid/sbt/graph/model.scala | 10 +-- .../sbt/graph/rendering/AsciiGraph.scala | 7 +- src/main/scala/sbt/SbtAccess.scala | 2 +- .../project/build.properties | 1 - .../project/build.properties | 1 - .../showMissingUpdates/build.sbt | 5 +- .../project/build.properties | 1 - .../project/build.properties | 1 - 17 files changed, 300 insertions(+), 77 deletions(-) create mode 100644 src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/compat.scala create mode 100644 src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/model.scala create mode 100644 src/main/scala-sbt-0.13/scala/sbt/compat.scala create mode 100644 src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/compat.scala create mode 100644 src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/model.scala create mode 100644 src/main/scala-sbt-1.0/scala/sbt/compat.scala delete mode 120000 src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties delete mode 120000 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties diff --git a/.travis.yml b/.travis.yml index 30f872264..c0d5bcc7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,12 @@ sudo: false language: scala jdk: oraclejdk7 script: -- sbt test scripted +# pending https://github.com/mdr/ascii-graphs/pull/11 +- git clone git://github.com/MasseGuillaume/ascii-graphs.git +- pushd ascii-graphs +- git checkout 2.12 +- sbt "+ publishLocal" +- popd + +- sbt ";^test ;^scripted" + diff --git a/build.sbt b/build.sbt index 3659705f3..be7047aa0 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,18 @@ ScriptedPlugin.scriptedSettings libraryDependencies ++= Seq( - "com.github.mdr" %% "ascii-graphs" % "0.0.3", - "org.specs2" %% "specs2" % "2.3.11" % Test + "com.github.mdr" %% "ascii-graphs" % "0.0.7-SNAPSHOT", + "org.specs2" %% "specs2-core" % "3.9.5" % Test ) +libraryDependencies += Defaults.sbtPluginExtra( + "com.dwijnand" % "sbt-compat" % "1.1.0", + (sbtBinaryVersion in pluginCrossBuild).value, + (scalaBinaryVersion in update).value +) + +crossSbtVersions := List("0.13.16", "1.0.2") + scalacOptions ++= Seq( "-deprecation", "-encoding", @@ -14,3 +22,6 @@ scalacOptions ++= Seq( ) ScalariformSupport.formatSettings + +addCommandAlias("c1", ";cls;^^ 1.0.2;compile") +addCommandAlias("c0", ";cls;^^ 0.13.16;compile") \ No newline at end of file diff --git a/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/compat.scala b/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/compat.scala new file mode 100644 index 000000000..588bcc270 --- /dev/null +++ b/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/compat.scala @@ -0,0 +1,25 @@ +package net.virtualvoid.sbt.graph + +import sbt._ +import Keys._ + +import CrossVersion._ +import DependencyGraphKeys._ + +object compat { + def convertConfig(config: sbt.Configuration): String = { + config.toString + } + +/** + * This is copied directly from sbt/main/Defaults.java and then changed to update the UpdateConfiguration + * to ignore missing artifacts. + */ + def ingnoreMissingSettings: Seq[Setting[_]] = Seq( + updateConfiguration in ignoreMissingUpdate := { + val config = updateConfiguration.value + new UpdateConfiguration(config.retrieve, true, config.logging) + }, + ignoreMissingUpdate := sbt.Compat.updateTask(ignoreMissingUpdate).value + ) +} \ No newline at end of file diff --git a/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/model.scala b/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/model.scala new file mode 100644 index 000000000..7af90cc3c --- /dev/null +++ b/src/main/scala-sbt-0.13/scala/net/virtualvoid/graph/model.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2015 Johannes Rudolph + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.virtualvoid.sbt.graph + +import sbinary.{ Format, DefaultProtocol } + +object ModuleGraphProtocol extends DefaultProtocol { + implicit def seqFormat[T: Format]: Format[Seq[T]] = wrap[Seq[T], List[T]](_.toList, _.toSeq) + implicit val ModuleIdFormat: Format[ModuleId] = asProduct3(ModuleId)(ModuleId.unapply(_).get) + implicit val ModuleFormat: Format[Module] = asProduct6(Module)(Module.unapply(_).get) + implicit val ModuleGraphFormat: Format[ModuleGraph] = asProduct2(ModuleGraph.apply _)(ModuleGraph.unapply(_).get) +} diff --git a/src/main/scala-sbt-0.13/scala/sbt/compat.scala b/src/main/scala-sbt-0.13/scala/sbt/compat.scala new file mode 100644 index 000000000..962f5e518 --- /dev/null +++ b/src/main/scala-sbt-0.13/scala/sbt/compat.scala @@ -0,0 +1,48 @@ +package sbt + +import Keys._ +import Def.Initialize + +import CrossVersion.partialVersion + +object Compat { + + // https://github.com/sbt/sbt/blob/e3c4db5ae80fa3e2a40b7a81bee0822e49f76aaf/main/src/main/scala/sbt/Defaults.scala#L1471 + def updateTask(task: TaskKey[_]): Initialize[Task[UpdateReport]] = Def.task { + val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) + val isRoot = executionRoots.value contains resolvedScoped.value + val s = streams.value + val scalaProvider = appConfiguration.value.provider.scalaProvider + + // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: + // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) + // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion + def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ + (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { + case (Some(res), Some(sh), _) if res == sh ⇒ jars + case (Some(res), _, Some(decl)) if res == decl ⇒ jars + case _ ⇒ Nil + } + + val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { + case Some(si) ⇒ subUnmanaged(si.version, si.allJars) + case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil + } + + val transform: UpdateReport ⇒ UpdateReport = + r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + + val show = Reference.display(thisProjectRef.value) + + Classpaths.cachedUpdate( + cacheFile = s.cacheDirectory, + label = show, + module = ivyModule.value, + config = (updateConfiguration in task).value, + transform = transform, + skip = (skip in update).value, + force = isRoot, + depsUpdated = depsUpdated, + log = s.log) + } +} \ No newline at end of file diff --git a/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/compat.scala b/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/compat.scala new file mode 100644 index 000000000..33cddb047 --- /dev/null +++ b/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/compat.scala @@ -0,0 +1,19 @@ +package net.virtualvoid.sbt.graph + +import DependencyGraphKeys._ + +import sbt._ +import Keys._ + +object compat { + def convertConfig(config: sbt.Configuration): sbt.Configuration = { + config + } + + val ingnoreMissingSettings: Seq[Setting[_]] = Seq( + updateConfiguration in ignoreMissingUpdate := { + updateConfiguration.value.withMissingOk(true) + }, + ignoreMissingUpdate := sbt.Compat.updateTask(ignoreMissingUpdate).value + ) +} \ No newline at end of file diff --git a/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/model.scala b/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/model.scala new file mode 100644 index 000000000..c14ac8640 --- /dev/null +++ b/src/main/scala-sbt-1.0/scala/net/virtualvoid/graph/model.scala @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Johannes Rudolph + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.virtualvoid.sbt.graph + +import sjsonnew._, LList.:*: + +object ModuleGraphProtocol extends BasicJsonProtocol { + + implicit val ModuleIdFormat: IsoLList[ModuleId] = + LList.isoCurried( + (m: ModuleId) => + ("organisation", m.organisation) :*: + ("name", m.name) :*: + ("version", m.version) :*: + LNil + ) { case + (_, organisation) :*: + (_, name) :*: + (version, _) :*: + LNil => ModuleId(organisation, name, version) + } + + implicit val ModuleFormat: IsoLList[Module] = + LList.isoCurried( + (m: Module) => + ("id", m.id) :*: + ("license", m.license) :*: + ("extraInfo", m.extraInfo) :*: + ("evictedByVersion", m.evictedByVersion) :*: + ("jarFile", m.jarFile) :*: + ("error", m.error) :*: + LNil + ) { + case + (_, id) :*: + (_, license) :*: + (_, extraInfo) :*: + (_, evictedByVersion) :*: + (_, jarFile) :*: + (_, error) :*: + LNil => Module(id, license, extraInfo, evictedByVersion, jarFile, error) + } + + + implicit val ModuleGraphFormat: IsoLList[ModuleGraph] = + LList.isoCurried( + (g: ModuleGraph) => + ("nodes", g.nodes) :*: + ("edges", g.edges) :*: + LNil + ) { case + (_, nodes) :*: + (_, edges) :*: + LNil => ModuleGraph(nodes, edges) + } +} \ No newline at end of file diff --git a/src/main/scala-sbt-1.0/scala/sbt/compat.scala b/src/main/scala-sbt-1.0/scala/sbt/compat.scala new file mode 100644 index 000000000..28cb6b28a --- /dev/null +++ b/src/main/scala-sbt-1.0/scala/sbt/compat.scala @@ -0,0 +1,62 @@ +package sbt + +import Keys._ +import Def.Initialize + +import CrossVersion.partialVersion +import sbt.internal.LibraryManagement + +object Compat { + + // https://github.com/sbt/sbt/blob/4ce4fb72bde3b8acfaf526b79d32ca1463bc687b/main/src/main/scala/sbt/Defaults.scala#L2298 + def updateTask(task: TaskKey[_]): Initialize[Task[UpdateReport]] = Def.task { + val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) + val isRoot = executionRoots.value contains resolvedScoped.value + val s = streams.value + val scalaProvider = appConfiguration.value.provider.scalaProvider + + // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: + // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) + // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion + def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ + (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { + case (Some(res), Some(sh), _) if res == sh ⇒ jars + case (Some(res), _, Some(decl)) if res == decl ⇒ jars + case _ ⇒ Nil + } + + val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { + case Some(si) ⇒ subUnmanaged(si.version, si.allJars) + case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil + } + + val transform: UpdateReport ⇒ UpdateReport = + r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + + val evictionOptions = Def.taskDyn { + if (executionRoots.value.exists(_.key == evicted.key)) + Def.task(EvictionWarningOptions.empty) + else Def.task((evictionWarningOptions in update).value) + }.value + + LibraryManagement.cachedUpdate( + // LM API + lm = dependencyResolution.value, + // Ivy-free ModuleDescriptor + module = ivyModule.value, + s.cacheStoreFactory.sub(updateCacheName.value), + Reference.display(thisProjectRef.value), + (updateConfiguration in task).value, + transform = transform, + skip = (skip in update).value, + force = isRoot, + depsUpdated = transitiveUpdate.value.exists(!_.stats.cached), + uwConfig = (unresolvedWarningConfiguration in update).value, + ewo = evictionOptions, + mavenStyle = publishMavenStyle.value, + compatWarning = compatibilityWarningOptions.value, + log = s.log + ) + } +} + diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 5c66eb37f..0f3ae5a37 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -16,10 +16,13 @@ package net.virtualvoid.sbt.graph +import compat._ +import sbt.librarymanagement._ + import sbt._ import Keys._ -import CrossVersion._ +import sbt.CrossVersion._ import sbt.complete.Parser @@ -35,21 +38,26 @@ object DependencyGraphSettings { import DependencyGraphKeys._ import ModuleGraphProtocol._ - def graphSettings = Seq( + def graphSettings = baseSettings ++ ingnoreMissingSettings ++ reportSettings + + def baseSettings = Seq( ivyReportFunction := ivyReportFunctionTask.value, - updateConfiguration in ignoreMissingUpdate := { - val config = updateConfiguration.value - new UpdateConfiguration(config.retrieve, true, config.logging) - }, - ignoreMissingUpdateT, - filterScalaLibrary in Global := true) ++ Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) + filterScalaLibrary in Global := true) + + def reportSettings = + Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) def ivyReportForConfig(config: Configuration) = inConfig(config)(Seq( ivyReport := { Def.task { - ivyReportFunction.value.apply(config.toString) + val ivyReportF = ivyReportFunction.value + + ivyReportF(config.toString) }.dependsOn(ignoreMissingUpdate) }.value, + + // ivyReport := { Def.task { ivyReportFunction.value.apply(config.toString) } dependsOn (ignoreMissingUpdate) }.value, + crossProjectId := sbt.CrossVersion( scalaVersion.value, scalaBinaryVersion.value)(projectID.value), @@ -58,9 +66,10 @@ object DependencyGraphSettings { val root = crossProjectId.value val config = configuration.value - update.configuration(config.name).map(report ⇒ + update.configuration(convertConfig(config)).map(report ⇒ SbtUpdateReport.fromConfigurationReport(report, root)).getOrElse(ModuleGraph.empty) }, + moduleGraphIvyReport := { IvyReport.fromReportFile(absoluteReportPath(ivyReport.value)) }, @@ -216,7 +225,7 @@ object DependencyGraphSettings { type HasModule = { val module: ModuleID } - def crossName(ivyModule: IvySbt#Module) = + def crossName(ivyModule: ModuleDescriptor) = ivyModule.moduleSettings match { case ic: InlineConfiguration ⇒ ic.module.name case hm: HasModule if hm.getClass.getName == "sbt.InlineConfigurationWithExcludes" ⇒ hm.module.name @@ -231,47 +240,4 @@ object DependencyGraphSettings { case _ ⇒ None } } - - /** - * This is copied directly from sbt/main/Defaults.java and then changed to update the UpdateConfiguration - * to ignore missing artifacts. - */ - def ignoreMissingUpdateT = - ignoreMissingUpdate := Def.task { - val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) - val isRoot = executionRoots.value contains resolvedScoped.value - val s = streams.value - val scalaProvider = appConfiguration.value.provider.scalaProvider - - // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: - // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) - // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion - def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ - (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { - case (Some(res), Some(sh), _) if res == sh ⇒ jars - case (Some(res), _, Some(decl)) if res == decl ⇒ jars - case _ ⇒ Nil - } - - val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { - case Some(si) ⇒ subUnmanaged(si.version, si.jars) - case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil - } - - val transform: UpdateReport ⇒ UpdateReport = - r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) - - val show = Reference.display(thisProjectRef.value) - - Classpaths.cachedUpdate( - cacheFile = s.cacheDirectory, - label = show, - module = ivyModule.value, - config = (updateConfiguration in ignoreMissingUpdate).value, - transform = transform, - skip = (skip in update).value, - force = isRoot, - depsUpdated = depsUpdated, - log = s.log) - }.value } \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/model.scala b/src/main/scala/net/virtualvoid/sbt/graph/model.scala index 68b6a8862..04f6b3f30 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/model.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/model.scala @@ -63,12 +63,4 @@ case class ModuleGraph(nodes: Seq[Module], edges: Seq[Edge]) { def roots: Seq[Module] = nodes.filter(n ⇒ !edges.exists(_._2 == n.id)).sortBy(_.id.idString) -} - -import sbinary.{ Format, DefaultProtocol } -object ModuleGraphProtocol extends DefaultProtocol { - implicit def seqFormat[T: Format]: Format[Seq[T]] = wrap[Seq[T], List[T]](_.toList, _.toSeq) - implicit val ModuleIdFormat: Format[ModuleId] = asProduct3(ModuleId)(ModuleId.unapply(_).get) - implicit val ModuleFormat: Format[Module] = asProduct6(Module)(Module.unapply(_).get) - implicit val ModuleGraphFormat: Format[ModuleGraph] = asProduct2(ModuleGraph.apply _)(ModuleGraph.unapply(_).get) -} +} \ No newline at end of file diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala index 8da025149..c64fdf9e0 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala @@ -17,11 +17,12 @@ package net.virtualvoid.sbt.graph package rendering -import com.github.mdr.ascii.layout._ +import com.github.mdr.ascii.graph.Graph +import com.github.mdr.ascii.layout.GraphLayout object AsciiGraph { def asciiGraph(graph: ModuleGraph): String = - Layouter.renderGraph(buildAsciiGraph(graph)) + GraphLayout.renderGraph(buildAsciiGraph(graph)) private def buildAsciiGraph(moduleGraph: ModuleGraph): Graph[String] = { def renderVertex(module: Module): String = @@ -31,7 +32,7 @@ object AsciiGraph { module.error.map("\nerror: " + _).getOrElse("") + module.evictedByVersion.map(_ formatted "\nevicted by: %s").getOrElse("") - val vertices = moduleGraph.nodes.map(renderVertex).toList + val vertices = moduleGraph.nodes.map(renderVertex).toSet val edges = moduleGraph.edges.toList.map { case (from, to) ⇒ (renderVertex(moduleGraph.module(from)), renderVertex(moduleGraph.module(to))) } Graph(vertices, edges) } diff --git a/src/main/scala/sbt/SbtAccess.scala b/src/main/scala/sbt/SbtAccess.scala index a75a57c31..1cb984aef 100644 --- a/src/main/scala/sbt/SbtAccess.scala +++ b/src/main/scala/sbt/SbtAccess.scala @@ -20,5 +20,5 @@ package sbt object SbtAccess { val unmanagedScalaInstanceOnly = Defaults.unmanagedScalaInstanceOnly - def getTerminalWidth: Int = JLine.usingTerminal(_.getWidth) + def getTerminalWidth: Int = internal.util.JLine.usingTerminal(_.getWidth) } diff --git a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties b/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/ignoreScalaLibrary/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt index 86455cc25..8db54664e 100644 --- a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/build.sbt @@ -1,7 +1,6 @@ -scalaVersion := "2.9.2" +scalaVersion := "2.12.3" -libraryDependencies += - "at.blub" % "blib" % "1.2.3" % "test" +libraryDependencies += "at.blub" % "blib" % "1.2.3" % Test TaskKey[Unit]("check") := { val report = (ivyReport in Test).value diff --git a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties b/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/showMissingUpdates/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties deleted file mode 120000 index fe5407f08..000000000 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -../../build.properties \ No newline at end of file From 8d5e9d901572b42de133564d0cfffa916d76fc56 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:14:18 +0200 Subject: [PATCH 17/38] Cleanup README --- README.md | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index 1e86e5f96..f8893990b 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ Visualize your project's dependencies. -## Preliminaries - -The plugin works best with sbt >= 0.13.6. See the [compatibility notes](#compatibility-notes) to use this plugin with an older version of sbt. - ## Usage Instructions Since sbt-dependency-graph is an informational tool rather than one that changes your build, you will more than likely wish to @@ -20,8 +16,6 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") To add the plugin only to a single project, put this line into `project/plugins.sbt` of your project, instead. -This plugin is an auto-plugin which will be automatically enabled starting from sbt 0.13.5. - ## Main Tasks * `dependencyTree`: Shows an ASCII tree representation of the project's dependencies @@ -66,20 +60,6 @@ dependencyDotFile := file("dependencies.dot") //render dot file to `./dependenci * [#19]: There's an unfixed bug with graph generation for particular layouts. Workaround: Use `dependency-tree` instead of `dependency-graph`. - * [#39]: When using sbt-dependency-graph with sbt < 0.13.6. - -## Compatibility notes - - * sbt < 0.13.6: The plugin will fall back on the old ivy report XML backend which suffers from [#39]. - * sbt < 0.13.5: Old versions of sbt have no `AutoPlugin` support, you need to add - -```scala -net.virtualvoid.sbt.graph.DependencyGraphSettings.graphSettings -``` - - to your `build.sbt` or (`~/.sbt/0.13/user.sbt` for global configuration) to enable the plugin. - * sbt <= 0.12.x: Old versions of sbt are not actively supported any more. Please use the old version from the [0.7 branch](https://github.com/jrudolph/sbt-dependency-graph/tree/0.7). - ## License @@ -87,5 +67,4 @@ Published under the [Apache License 2.0](http://en.wikipedia.org/wiki/Apache_lic [global plugin]: http://www.scala-sbt.org/0.13/tutorial/Using-Plugins.html#Global+plugins [global build configuration]: http://www.scala-sbt.org/0.13/docs/Global-Settings.html -[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 -[#39]: https://github.com/jrudolph/sbt-dependency-graph/issues/39 +[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 \ No newline at end of file From 0bbeea39777ac6ca5f5cc5943e1cbf50f58c0a27 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:19:47 +0200 Subject: [PATCH 18/38] Modernize and adapt build, update to newest versions --- build.sbt | 28 ++++++++++------------------ project/Helpers.scala | 16 ---------------- project/pgp.sbt | 2 +- publish.sbt | 27 ++++++++++++++++++++------- 4 files changed, 31 insertions(+), 42 deletions(-) delete mode 100644 project/Helpers.scala diff --git a/build.sbt b/build.sbt index 15c1afcb6..411b401b2 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,8 @@ libraryDependencies ++= { Nil } -libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test" + +libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.5" % Test libraryDependencies += Defaults.sbtPluginExtra( "com.dwijnand" % "sbt-compat" % "1.1.0", @@ -17,22 +18,13 @@ libraryDependencies += Defaults.sbtPluginExtra( (scalaBinaryVersion in update).value ) -scalacOptions ++= Seq("-deprecation", "-unchecked") +crossSbtVersions := Seq("1.0.2", "0.13.16") -ScalariformSupport.formatSettings +scalacOptions ++= Seq( + "-deprecation", + "-encoding", "UTF-8", + "-feature", + "-unchecked" +) -crossSbtVersions := Seq("1.0.1", "0.13.16") - -//sbtVersion in pluginCrossBuild := "1.0.0" - -/* -Try to prevent silly warnings - -libraryDependencies += ("org.scala-sbt" %% "main-settings" % "1.0.1-SNAPSHOT")//.excludeAll(ExclusionRule(organization = "org.scala-sbt")) - -libraryDependencies += "org.scala-sbt" %% "command" % "1.0.0"force() -libraryDependencies += "org.scala-sbt" %% "completion" % "1.0.0"force() -libraryDependencies += "org.scala-sbt" %% "task-system" % "1.0.0"force() -libraryDependencies += "org.scala-sbt" %% "core-macros" % "1.0.0" force() - -*/ \ No newline at end of file +ScalariformSupport.formatSettings \ No newline at end of file diff --git a/project/Helpers.scala b/project/Helpers.scala deleted file mode 100644 index 4c426be62..000000000 --- a/project/Helpers.scala +++ /dev/null @@ -1,16 +0,0 @@ -import java.net.URL - -object Helpers { - def generatePomExtra(scmUrl: String, scmConnection: String, - developerId: String, developerName: String): xml.NodeSeq = - - { scmUrl } - { scmConnection } - - - - { developerId } - { developerName } - - -} \ No newline at end of file diff --git a/project/pgp.sbt b/project/pgp.sbt index cefa8ec57..2efcc4b69 100644 --- a/project/pgp.sbt +++ b/project/pgp.sbt @@ -1 +1 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") diff --git a/publish.sbt b/publish.sbt index 9d44a4f3a..a8a28600c 100644 --- a/publish.sbt +++ b/publish.sbt @@ -1,7 +1,9 @@ -publishTo <<= version { v: String => +publishTo := { val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots") - else Some("releases" at nexus + "service/local/staging/deploy/maven2") + Some { + if (version.value.trim.endsWith("SNAPSHOT")) "snapshots" at nexus + "content/repositories/snapshots" + else "releases" at nexus + "service/local/staging/deploy/maven2" + } } publishMavenStyle := true @@ -10,9 +12,20 @@ publishArtifact in Test := false pomIncludeRepository := { _ => false } -pomExtra := - Helpers.generatePomExtra("git@github.com:jrudolph/sbt-dependency-graph.git", - "scm:git:git@github.com:jrudolph/sbt-dependency-graph.git", - "jrudolph", "Johannes Rudolph") +scmInfo := Some( + ScmInfo( + browseUrl = url("https://github.com/jrudolph/sbt-dependency-graph"), + connection = "scm:git:git@github.com:jrudolph/sbt-dependency-graph.git" + ) +) + +developers := List( + Developer( + "jrudolph", + "Johannes Rudolph", + "johannes.rudolph@gmail.com", + url("https://virtual-void.net") + ) +) useGpg := true From cfa9f462cf24b2bd47bc80ef67ebfa90fefdf695 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:20:00 +0200 Subject: [PATCH 19/38] Test for all sbt versions on travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 30f872264..38f878a6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ sudo: false language: scala jdk: oraclejdk7 script: -- sbt test scripted +- sbt ";^test ;^scripted" From e813b28a1c90bfcedc2d98fb57afee799e25b939 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:44:15 +0200 Subject: [PATCH 20/38] Move SbtAccess to our own package below sbt to prevent accidental namespace clashes with other plugins / sbt --- .../virtualvoid/sbt/graph/util/AsciiTreeLayout.scala | 4 +++- .../scala/sbt/{ => dependencygraph}/SbtAccess.scala | 10 +++------- src/sbt-test/sbt-dependency-graph/build.properties | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) rename src/main/scala/sbt/{ => dependencygraph}/SbtAccess.scala (82%) delete mode 100644 src/sbt-test/sbt-dependency-graph/build.properties diff --git a/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala b/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala index 24b8d6063..dc26c98c0 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala @@ -5,6 +5,8 @@ */ package net.virtualvoid.sbt.graph.util +import sbt.dependencygraph.SbtAccess + object AsciiTreeLayout { // [info] foo // [info] +-bar @@ -52,7 +54,7 @@ object AsciiTreeLayout { } def defaultColumnSize: Int = { - val termWidth = sbt.SbtAccess.getTerminalWidth + val termWidth = SbtAccess.getTerminalWidth if (termWidth > 20) termWidth - 8 else 80 // ignore termWidth } diff --git a/src/main/scala/sbt/SbtAccess.scala b/src/main/scala/sbt/dependencygraph/SbtAccess.scala similarity index 82% rename from src/main/scala/sbt/SbtAccess.scala rename to src/main/scala/sbt/dependencygraph/SbtAccess.scala index 6ddc71f48..558aeb1b6 100644 --- a/src/main/scala/sbt/SbtAccess.scala +++ b/src/main/scala/sbt/dependencygraph/SbtAccess.scala @@ -14,17 +14,13 @@ * limitations under the License. */ -package sbt +package sbt.dependencygraph -import internal._ -import Classpaths._ -import LibraryManagement._ -import internal.util.JLine +import sbt.Defaults /** Accessors to private[sbt] symbols. */ object SbtAccess { val unmanagedScalaInstanceOnly = Defaults.unmanagedScalaInstanceOnly - def getTerminalWidth: Int = JLine.usingTerminal(_.getWidth) - + def getTerminalWidth: Int = sbt.internal.util.JLine.usingTerminal(_.getWidth) } diff --git a/src/sbt-test/sbt-dependency-graph/build.properties b/src/sbt-test/sbt-dependency-graph/build.properties deleted file mode 100644 index df58110af..000000000 --- a/src/sbt-test/sbt-dependency-graph/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.13.6 \ No newline at end of file From 73faf777f2005701d43576a6b74f0b469502b3f6 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:52:38 +0200 Subject: [PATCH 21/38] Make autoconversion from sbinary -> jsonnew only apply in sbt 1.x --- .../sbt/graph/ModuleGraphProtocolCompat.scala | 3 +++ .../sbt/graph/ModuleGraphProtocolCompat.scala | 25 ++++++++++++++++++ .../net/virtualvoid/sbt/graph/model.scala | 26 +++---------------- 3 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala create mode 100644 src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala diff --git a/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala new file mode 100644 index 000000000..d28f20d8b --- /dev/null +++ b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala @@ -0,0 +1,3 @@ +package net.virtualvoid.sbt.graph + +trait ModuleGraphProtocolCompat diff --git a/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala b/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala new file mode 100644 index 000000000..1fb08ccc7 --- /dev/null +++ b/src/main/scala-sbt-1.0/net/virtualvoid/sbt/graph/ModuleGraphProtocolCompat.scala @@ -0,0 +1,25 @@ +package net.virtualvoid.sbt.graph + +import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File } +import java.util.Base64 + +import sbinary.{ Format, JavaInput, JavaOutput } +import sjsonnew.{ Builder, Unbuilder } + +trait ModuleGraphProtocolCompat { + implicit def sjsonNewAndShinyTransformAndTranspileAdapterFactoryModuleImplementation[T](implicit format: Format[T]): sjsonnew.JsonFormat[T] = + new sjsonnew.JsonFormat[T] { + // note, how this is simpler to write than to learn any sjonnew protocol syntax + def write[J](obj: T, builder: Builder[J]): Unit = { + val baos = new ByteArrayOutputStream() + format.writes(new JavaOutput(baos), obj) + val str = Base64.getEncoder.encodeToString(baos.toByteArray) + builder.writeString(str) + } + def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): T = { + val str = unbuilder.readString(jsOpt.get) + val bais = new ByteArrayInputStream(Base64.getDecoder.decode(str)) + format.reads(new JavaInput(bais)) + } + } +} diff --git a/src/main/scala/net/virtualvoid/sbt/graph/model.scala b/src/main/scala/net/virtualvoid/sbt/graph/model.scala index 850a43047..04cf57ff7 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/model.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/model.scala @@ -16,11 +16,9 @@ package net.virtualvoid.sbt.graph -import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File } -import java.util.Base64 +import java.io.File -import sbinary.{ JavaInput, JavaOutput } -import sjsonnew.{ Builder, Unbuilder } +import sbinary.{ DefaultProtocol, Format } import scala.collection.mutable.{ HashMap, MultiMap, Set } @@ -69,27 +67,9 @@ case class ModuleGraph(nodes: Seq[Module], edges: Seq[Edge]) { nodes.filter(n ⇒ !edges.exists(_._2 == n.id)).sortBy(_.id.idString) } -import sbinary.{ Format, DefaultProtocol } -object ModuleGraphProtocol extends DefaultProtocol { +object ModuleGraphProtocol extends DefaultProtocol with ModuleGraphProtocolCompat { implicit def seqFormat[T: Format]: Format[Seq[T]] = wrap[Seq[T], List[T]](_.toList, _.toSeq) implicit val ModuleIdFormat: Format[ModuleId] = asProduct3(ModuleId)(ModuleId.unapply(_).get) implicit val ModuleFormat: Format[Module] = asProduct6(Module)(Module.unapply(_).get) implicit val ModuleGraphFormat: Format[ModuleGraph] = asProduct2(ModuleGraph.apply _)(ModuleGraph.unapply(_).get) - - // - implicit def sjsonNewAndShinyTransformAndTranspileAdapterFactoryModuleImplementation[T](implicit format: Format[T]): sjsonnew.JsonFormat[T] = - new sjsonnew.JsonFormat[T] { - // note, how this is simpler to write than to learn any sjonnew protocol syntax - def write[J](obj: T, builder: Builder[J]): Unit = { - val baos = new ByteArrayOutputStream() - format.writes(new JavaOutput(baos), obj) - val str = Base64.getEncoder.encodeToString(baos.toByteArray) - builder.writeString(str) - } - def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): T = { - val str = unbuilder.readString(jsOpt.get) - val bais = new ByteArrayInputStream(Base64.getDecoder.decode(str)) - format.reads(new JavaInput(bais)) - } - } } From d3676dd17fca422d281d3457623522e8e55b0b4a Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 16:53:00 +0200 Subject: [PATCH 22/38] Fix configuration usage for sbt 0.13 --- .../sbt/dependencygraph/DependencyGraphSbtCompat.scala | 7 +++++++ .../sbt/dependencygraph/DependencyGraphSbtCompat.scala | 7 +++++++ .../virtualvoid/sbt/graph/DependencyGraphSettings.scala | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala create mode 100644 src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala diff --git a/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala new file mode 100644 index 000000000..694eab1d3 --- /dev/null +++ b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -0,0 +1,7 @@ +package sbt.dependencygraph + +object DependencyGraphSbtCompat { + object Implicits { + implicit def convertConfig(config: sbt.Configuration): String = config.toString + } +} diff --git a/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala new file mode 100644 index 000000000..68887c10c --- /dev/null +++ b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -0,0 +1,7 @@ +package sbt.dependencygraph + +object DependencyGraphSbtCompat { + object Implicits { + implicit def convertConfig(config: sbt.Configuration): sbt.Configuration = config + } +} diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 15f0d8da2..9768de3e9 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -28,6 +28,8 @@ import net.virtualvoid.sbt.graph.util.IOUtil import internal.librarymanagement._ import librarymanagement._ +import sbt.dependencygraph.DependencyGraphSbtCompat.Implicits._ + object DependencyGraphSettings { import DependencyGraphKeys._ import ModuleGraphProtocol._ From a66dabcc3be0f88fd0c3808b4a14373ee1afac9d Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 17:24:49 +0200 Subject: [PATCH 23/38] Make ignoreMissingUpdate work again for both sbt 0.13 and 1.0 --- .../DependencyGraphSbtCompat.scala | 76 ++++++++++++++++++- .../DependencyGraphSbtCompat.scala | 63 ++++++++++++++- .../sbt/graph/DependencyGraphSettings.scala | 45 +---------- 3 files changed, 139 insertions(+), 45 deletions(-) diff --git a/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala index 694eab1d3..cb65aa82c 100644 --- a/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala +++ b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -1,7 +1,81 @@ -package sbt.dependencygraph +package sbt +package dependencygraph + +import scala.language.implicitConversions + +import java.util.concurrent.TimeUnit + +import Keys._ +import Def.Initialize +import CrossVersion._ + +import scala.concurrent.duration.FiniteDuration object DependencyGraphSbtCompat { object Implicits { implicit def convertConfig(config: sbt.Configuration): String = config.toString + + implicit class RichUpdateConfiguration(val updateConfig: UpdateConfiguration) extends AnyVal { + def withMissingOk(missingOk: Boolean): UpdateConfiguration = + updateConfig.copy(missingOk = missingOk) + } + } + + /** + * This is copied directly from https://github.com/sbt/sbt/blob/2952a2b9b672c5402b824ad2d2076243eb643598/main/src/main/scala/sbt/Defaults.scala#L1471-L1523 + * and then changed to update the UpdateConfiguration to ignore missing artifacts. + */ + def updateTask(task: TaskKey[_]): Initialize[Task[UpdateReport]] = Def.task { + val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) + val isRoot = executionRoots.value contains resolvedScoped.value + val forceUpdate = forceUpdatePeriod.value + val s = streams.value + val fullUpdateOutput = s.cacheDirectory / "out" + val forceUpdateByTime = forceUpdate match { + case None => false + case Some(period) => + val elapsedDuration = new FiniteDuration(System.currentTimeMillis() - fullUpdateOutput.lastModified(), TimeUnit.MILLISECONDS) + fullUpdateOutput.exists() && elapsedDuration > period + } + val scalaProvider = appConfiguration.value.provider.scalaProvider + + // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: + // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) + // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion + def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) => + (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { + case (Some(res), Some(sh), _) if res == sh => jars + case (Some(res), _, Some(decl)) if res == decl => jars + case _ => Nil + } + val subScalaJars: String => Seq[File] = Defaults.unmanagedScalaInstanceOnly.value match { + case Some(si) => subUnmanaged(si.version, si.jars) + case None => sv => if (scalaProvider.version == sv) scalaProvider.jars else Nil + } + val transform: UpdateReport => UpdateReport = r => sbt.Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + val uwConfig = (unresolvedWarningConfiguration in update).value + val show = Reference.display(thisProjectRef.value) + val st = state.value + val logicalClock = LogicalClock(st.hashCode) + val depDir = dependencyCacheDirectory.value + val uc0 = (updateConfiguration in task).value + val ms = publishMavenStyle.value + val cw = compatibilityWarningOptions.value + // Normally, log would capture log messages at all levels. + // Ivy logs are treated specially using sbt.UpdateConfiguration.logging. + // This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug. + import UpdateLogging.{ Full, DownloadOnly, Default } + val uc = (logLevel in update).?.value orElse st.get(logLevel.key) match { + case Some(Level.Debug) if uc0.logging == Default => uc0.copy(logging = Full) + case Some(x) if uc0.logging == Default => uc0.copy(logging = DownloadOnly) + case _ => uc0 + } + val ewo = + if (executionRoots.value exists { _.key == evicted.key }) EvictionWarningOptions.empty + else (evictionWarningOptions in update).value + sbt.Classpaths.cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc, transform, + skip = (skip in update).value, force = isRoot || forceUpdateByTime, depsUpdated = depsUpdated, + uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir), + ewo = ewo, mavenStyle = ms, compatWarning = cw, log = s.log) } } diff --git a/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala index 68887c10c..4e08319db 100644 --- a/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala +++ b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -1,7 +1,64 @@ -package sbt.dependencygraph +package sbt +package dependencygraph + +import Keys._ +import Def.Initialize + +import CrossVersion.partialVersion +import sbt.internal.LibraryManagement object DependencyGraphSbtCompat { - object Implicits { - implicit def convertConfig(config: sbt.Configuration): sbt.Configuration = config + object Implicits + + // https://github.com/sbt/sbt/blob/4ce4fb72bde3b8acfaf526b79d32ca1463bc687b/main/src/main/scala/sbt/Defaults.scala#L2298 adapted + // to allow customization of UpdateConfiguration + def updateTask(task: TaskKey[_]): Initialize[Task[UpdateReport]] = Def.task { + val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) + val isRoot = executionRoots.value contains resolvedScoped.value + val s = streams.value + val scalaProvider = appConfiguration.value.provider.scalaProvider + + // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: + // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) + // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion + def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ + (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { + case (Some(res), Some(sh), _) if res == sh ⇒ jars + case (Some(res), _, Some(decl)) if res == decl ⇒ jars + case _ ⇒ Nil + } + + val subScalaJars: String ⇒ Seq[File] = SbtAccess.unmanagedScalaInstanceOnly.value match { + case Some(si) ⇒ subUnmanaged(si.version, si.allJars) + case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil + } + + val transform: UpdateReport ⇒ UpdateReport = + r ⇒ Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + + val evictionOptions = Def.taskDyn { + if (executionRoots.value.exists(_.key == evicted.key)) + Def.task(EvictionWarningOptions.empty) + else Def.task((evictionWarningOptions in update).value) + }.value + + LibraryManagement.cachedUpdate( + // LM API + lm = dependencyResolution.value, + // Ivy-free ModuleDescriptor + module = ivyModule.value, + s.cacheStoreFactory.sub(updateCacheName.value), + Reference.display(thisProjectRef.value), + (updateConfiguration in task).value, + transform = transform, + skip = (skip in update).value, + force = isRoot, + depsUpdated = transitiveUpdate.value.exists(!_.stats.cached), + uwConfig = (unresolvedWarningConfiguration in update).value, + ewo = evictionOptions, + mavenStyle = publishMavenStyle.value, + compatWarning = compatibilityWarningOptions.value, + log = s.log + ) } } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 9768de3e9..369c7f3dc 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -16,18 +16,18 @@ package net.virtualvoid.sbt.graph +import scala.language.reflectiveCalls + import sbt._ import Keys._ -import CrossVersion._ import sbt.complete.Parser import org.apache.ivy.core.resolve.ResolveOptions import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML } import net.virtualvoid.sbt.graph.util.IOUtil - import internal.librarymanagement._ import librarymanagement._ - +import sbt.dependencygraph.DependencyGraphSbtCompat import sbt.dependencygraph.DependencyGraphSbtCompat.Implicits._ object DependencyGraphSettings { @@ -37,7 +37,7 @@ object DependencyGraphSettings { def graphSettings = Seq( ivyReportFunction := ivyReportFunctionTask.value, updateConfiguration in ignoreMissingUpdate := updateConfiguration.value.withMissingOk(true), - ignoreMissingUpdate := update.value, + ignoreMissingUpdate := DependencyGraphSbtCompat.updateTask(ignoreMissingUpdate).value, filterScalaLibrary in Global := true) ++ Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) def ivyReportForConfig(config: Configuration) = inConfig(config)(Seq( @@ -198,41 +198,4 @@ object DependencyGraphSettings { case _ ⇒ None } } - - /** - * This is copied directly from sbt/main/Defaults.scala and then changed to update the UpdateConfiguration - * to ignore missing artifacts. - */ - /*def ignoreMissingUpdateT = - ignoreMissingUpdate := { - // FIXME: remove busywork - - val scalaVersion = Keys.scalaVersion.value - val unmanagedScalaInstanceOnly = SbtAccess.unmanagedScalaInstanceOnly.value - val scalaOrganization = Keys.scalaOrganization.value - - val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) - val isRoot = executionRoots.value contains resolvedScoped.value - val s = streams.value - val scalaProvider = appConfiguration.value.provider.scalaProvider - - // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: - // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) - // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion - def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ - (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion)) match { - case (Some(res), Some(sh), _) if res == sh ⇒ jars - case (Some(res), _, Some(decl)) if res == decl ⇒ jars - case _ ⇒ Nil - } - val subScalaJars: String ⇒ Seq[File] = unmanagedScalaInstanceOnly match { - case Some(si) ⇒ subUnmanaged(si.version, si.allJars) - case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil - } - val transform: UpdateReport ⇒ UpdateReport = r ⇒ Classpaths.substituteScalaFiles(scalaOrganization, r)(subScalaJars) - - val show = Reference.display(thisProjectRef.value) - SbtAccess.cachedUpdater( - s.cacheDirectory, show, ivyModule.value, (updateConfiguration in ignoreMissingUpdate).value, transform, skip = (skip in update).value, force = isRoot, depsUpdated = depsUpdated, log = s.log) - }*/ } From 68bc4f53cf0198a1910cf2eda48d996834bbeb43 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 17:35:14 +0200 Subject: [PATCH 24/38] Fix sbt-test issues --- .../intervalRangedVersions/build.sbt | 6 +- .../testDotFileGeneration/build.sbt | 65 +++++++++++++++++ .../testDotFileGeneration/project/Build.scala | 69 ------------------- 3 files changed, 68 insertions(+), 72 deletions(-) create mode 100644 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt delete mode 100644 src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala diff --git a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt index 7521ddc46..95c0d0d2a 100644 --- a/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/intervalRangedVersions/build.sbt @@ -14,9 +14,9 @@ TaskKey[Unit]("check") := { val expectedGraph = """default:default-dbc48d_2.9.2:0.1-SNAPSHOT [S] | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | +-org.codehaus.jackson:jackson-core-asl:1.9.13 - | +-org.codehaus.jackson:jackson-mapper-asl:1.9.13 - | +-org.codehaus.jackson:jackson-core-asl:1.9.13 + | +-org.codehaus.jackson:jackson-core-asl:1.9.11 + | +-org.codehaus.jackson:jackson-mapper-asl:1.9.11 + | +-org.codehaus.jackson:jackson-core-asl:1.9.11 | """.stripMargin IO.writeLines(file("/tmp/blib"), sanitize(graph).split("\n")) IO.writeLines(file("/tmp/blub"), sanitize(expectedGraph).split("\n")) diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt new file mode 100644 index 000000000..22edf69e4 --- /dev/null +++ b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt @@ -0,0 +1,65 @@ +import collection.mutable.ListBuffer + +import net.virtualvoid.sbt.graph.DependencyGraphKeys.dependencyDot + +import scala.collection.mutable.ListBuffer + +def defaultSettings = + Seq(scalaVersion := "2.9.2") + +lazy val justATransiviteDependencyEndpointProject = + Project("just-a-transitive-dependency-endpoint", file("a")) + .settings(defaultSettings: _*) + +lazy val justATransitiveDependencyProject = + Project("just-a-transitive-dependency", file("b")) + .settings(defaultSettings: _*) + .dependsOn(justATransiviteDependencyEndpointProject) + +lazy val justADependencyProject = + Project("just-a-dependency", file("c")) + .settings(defaultSettings: _*) + +lazy val test_project = + Project("test-dot-file-generation", file("d")) + .settings(defaultSettings: _*) + .settings( + TaskKey[Unit]("check") := { + val dotFile = (dependencyDot in Compile).value + val expectedGraph = + """digraph "dependency-graph" { + | graph[rankdir="LR"] + | edge [ + | arrowtail="none" + | ] + | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT"[label=test-dot-file-generation_2.9.2
0.1-SNAPSHOT> style=""] + | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency_2.9.2
0.1-SNAPSHOT> style=""] + | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency-endpoint_2.9.2
0.1-SNAPSHOT> style=""] + | "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-dependency_2.9.2
0.1-SNAPSHOT> style=""] + | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" + | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT" + | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT" + |} + """.stripMargin + + val graph : String = scala.io.Source.fromFile(dotFile.getAbsolutePath).mkString + val errors = compareByLine(graph, expectedGraph) + require(errors.isEmpty , errors.mkString("\n")) + () + } + ) + .dependsOn(justADependencyProject, justATransitiveDependencyProject) + +def compareByLine(got : String, expected : String) : Seq[String] = { + val errors = ListBuffer[String]() + got.split("\n").zip(expected.split("\n").toSeq).zipWithIndex.foreach { case((got_line : String, expected_line : String), i : Int) => + if(got_line != expected_line) { + errors.append( + """not matching lines at line %s + |expected: %s + |got: %s + |""".stripMargin.format(i,expected_line, got_line)) + } + } + errors +} \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala deleted file mode 100644 index 255092115..000000000 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala +++ /dev/null @@ -1,69 +0,0 @@ -import collection.mutable.ListBuffer - -import sbt._ -import sbt.Keys._ - -import net.virtualvoid.sbt.graph.DependencyGraphKeys._ - -object Build extends sbt.Build { - - def defaultSettings = - Seq(scalaVersion := "2.9.2") - - lazy val justATransiviteDependencyEndpointProject = - Project("just-a-transitive-dependency-endpoint", file("a")) - .settings(defaultSettings: _*) - - lazy val justATransitiveDependencyProject = - Project("just-a-transitive-dependency", file("b")) - .settings(defaultSettings: _*) - .dependsOn(justATransiviteDependencyEndpointProject) - - lazy val justADependencyProject = - Project("just-a-dependency", file("c")) - .settings(defaultSettings: _*) - - lazy val test_project = - Project("test-dot-file-generation", file("d")) - .settings(defaultSettings: _*) - .settings( - TaskKey[Unit]("check") := { - val dotFile = (dependencyDot in Compile).value - val expectedGraph = - """digraph "dependency-graph" { - | graph[rankdir="LR"] - | edge [ - | arrowtail="none" - | ] - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT"[label=test-dot-file-generation_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency-endpoint_2.9.2
0.1-SNAPSHOT> style=""] - | "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-dependency_2.9.2
0.1-SNAPSHOT> style=""] - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" - | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT" - | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT" - |} - """.stripMargin - - val graph : String = scala.io.Source.fromFile(dotFile.getAbsolutePath).mkString - val errors = compareByLine(graph, expectedGraph) - require(errors.isEmpty , errors.mkString("\n")) - () - } - ) - .dependsOn(justADependencyProject, justATransitiveDependencyProject) - - def compareByLine(got : String, expected : String) : Seq[String] = { - val errors = ListBuffer[String]() - got.split("\n").zip(expected.split("\n").toSeq).zipWithIndex.foreach { case((got_line : String, expected_line : String), i : Int) => - if(got_line != expected_line) { - errors.append( - """not matching lines at line %s - |expected: %s - |got: %s - |""".stripMargin.format(i,expected_line, got_line)) - } - } - errors - } -} From f82df1071174f4e54c4d0d03a45cab77d296e2d9 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 23 Oct 2017 17:35:30 +0200 Subject: [PATCH 25/38] Fix compilation warnings --- .../net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala index f5596269a..3c8af89f6 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala @@ -17,6 +17,9 @@ package net.virtualvoid.sbt.graph package backend +import scala.language.implicitConversions +import scala.language.reflectiveCalls + import sbt._ object SbtUpdateReport { From 014e74c68b97bd284e6f92ea5e6042199f9c55cf Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 24 Oct 2017 17:24:20 +0200 Subject: [PATCH 26/38] sbt-dynver produces named builds, so use those to detect when to use snapshot repo --- publish.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/publish.sbt b/publish.sbt index a8a28600c..efef315bc 100644 --- a/publish.sbt +++ b/publish.sbt @@ -1,8 +1,8 @@ publishTo := { val nexus = "https://oss.sonatype.org/" Some { - if (version.value.trim.endsWith("SNAPSHOT")) "snapshots" at nexus + "content/repositories/snapshots" - else "releases" at nexus + "service/local/staging/deploy/maven2" + if (version.value.trim.contains("+")) "snapshots" at nexus + "content/repositories/snapshots" + else "releases" at nexus + "service/local/staging/deploy/maven2" } } From 57356c5b54906d88c56ca64165034f1bfc7c5261 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 24 Oct 2017 17:49:22 +0200 Subject: [PATCH 27/38] Slight refactorings in DependencyGraphSettings --- .../sbt/graph/DependencyGraphSettings.scala | 41 +++++++++---------- .../net/virtualvoid/sbt/graph/model.scala | 6 ++- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 369c7f3dc..2bf7a13b6 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -21,7 +21,6 @@ import scala.language.reflectiveCalls import sbt._ import Keys._ import sbt.complete.Parser -import org.apache.ivy.core.resolve.ResolveOptions import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport } import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML } import net.virtualvoid.sbt.graph.util.IOUtil @@ -34,11 +33,16 @@ object DependencyGraphSettings { import DependencyGraphKeys._ import ModuleGraphProtocol._ - def graphSettings = Seq( + def graphSettings = baseSettings ++ reportSettings + + def baseSettings = Seq( ivyReportFunction := ivyReportFunctionTask.value, updateConfiguration in ignoreMissingUpdate := updateConfiguration.value.withMissingOk(true), ignoreMissingUpdate := DependencyGraphSbtCompat.updateTask(ignoreMissingUpdate).value, - filterScalaLibrary in Global := true) ++ Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) + filterScalaLibrary in Global := true) + + def reportSettings = + Seq(Compile, Test, IntegrationTest, Runtime, Provided, Optional).flatMap(ivyReportForConfig) def ivyReportForConfig(config: Configuration) = inConfig(config)(Seq( ivyReport := { Def.task { ivyReportFunction.value.apply(config.toString) } dependsOn (ignoreMissingUpdate) }.value, @@ -78,11 +82,12 @@ object DependencyGraphSettings { }, dependencyList := printFromGraph(rendering.FlatList.render(_, _.id.idString)).value, dependencyStats := printFromGraph(rendering.Statistics.renderModuleStatsList).value, - dependencyDotHeader := """digraph "dependency-graph" { - | graph[rankdir="LR"] - | edge [ - | arrowtail="none" - | ]""".stripMargin, + dependencyDotHeader := + """|digraph "dependency-graph" { + | graph[rankdir="LR"] + | edge [ + | arrowtail="none" + | ]""".stripMargin, dependencyDotNodeLabel := { (organisation: String, name: String, version: String) ⇒ """%s
%s
%s""".format(organisation, name, version) }, @@ -93,22 +98,14 @@ object DependencyGraphSettings { licenseInfo := showLicenseInfo(moduleGraph.value, streams.value)) ++ AsciiGraph.asciiGraphSetttings) def ivyReportFunctionTask = Def.task { - // FIXME: and remove busywork after https://github.com/sbt/sbt/issues/3299 is fixed - val target = Keys.target.value + val crossTarget = Keys.crossTarget.value val projectID = Keys.projectID.value val ivyModule = Keys.ivyModule.value - sbtVersion.value match { - case Version(0, min, fix, _) if min > 12 || (min == 12 && fix >= 3) ⇒ - (c: String) ⇒ file("%s/resolution-cache/reports/%s-%s-%s.xml".format(target, projectID.organization, crossName(ivyModule), c)) - case Version(0, min, fix, _) if min == 12 && fix >= 1 && fix < 3 ⇒ - ivyModule.withModule(streams.value.log) { (i, moduleDesc, _) ⇒ - val id = ResolveOptions.getDefaultResolveId(moduleDesc) - (c: String) ⇒ file("%s/resolution-cache/reports/%s/%s-resolved.xml" format (target, id, c)) - } - case _ ⇒ - val home = appConfiguration.value.provider.scalaProvider.launcher.ivyHome - (c: String) ⇒ file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c)) + (config: String) ⇒ { + val org = projectID.organization + val name = crossName(ivyModule) + file(s"${crossTarget}/resolution-cache/reports/$org-$name-$config.xml") } } @@ -150,7 +147,7 @@ object DependencyGraphSettings { graph.nodes.filter(_.isUsed).groupBy(_.license).toSeq.sortBy(_._1).map { case (license, modules) ⇒ license.getOrElse("No license specified") + "\n" + - modules.map("\t %s" format _.id.idString).mkString("\n") + modules.map(_.id.idString formatted "\t %s").mkString("\n") }.mkString("\n\n") streams.log.info(output) } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/model.scala b/src/main/scala/net/virtualvoid/sbt/graph/model.scala index 04cf57ff7..96ce95258 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/model.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/model.scala @@ -18,7 +18,7 @@ package net.virtualvoid.sbt.graph import java.io.File -import sbinary.{ DefaultProtocol, Format } +import sbinary.Format import scala.collection.mutable.{ HashMap, MultiMap, Set } @@ -67,7 +67,9 @@ case class ModuleGraph(nodes: Seq[Module], edges: Seq[Edge]) { nodes.filter(n ⇒ !edges.exists(_._2 == n.id)).sortBy(_.id.idString) } -object ModuleGraphProtocol extends DefaultProtocol with ModuleGraphProtocolCompat { +object ModuleGraphProtocol extends ModuleGraphProtocolCompat { + import sbinary.DefaultProtocol._ + implicit def seqFormat[T: Format]: Format[Seq[T]] = wrap[Seq[T], List[T]](_.toList, _.toSeq) implicit val ModuleIdFormat: Format[ModuleId] = asProduct3(ModuleId)(ModuleId.unapply(_).get) implicit val ModuleFormat: Format[Module] = asProduct6(Module)(Module.unapply(_).get) From 90fc1a7f4f3fe82548eb8d42a8dfe1462ffbe1c0 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 24 Oct 2017 18:18:21 +0200 Subject: [PATCH 28/38] Update README to reflect 0.9.0 changes --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8893990b..ce67a58d1 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,19 @@ Visualize your project's dependencies. ## Usage Instructions -Since sbt-dependency-graph is an informational tool rather than one that changes your build, you will more than likely wish to +sbt-dependency-graph is an informational tool rather than one that changes your build, so you will more than likely wish to install it as a [global plugin] so that you can use it in any SBT project without the need to explicitly add it to each one. To do -this, add the plugin dependency to `~/.sbt/0.13/plugins/plugins.sbt`: +this, add the plugin dependency to `~/.sbt/0.13/plugins/plugins.sbt` for sbt 0.13 or `~/.sbt/1.0/plugins/plugins.sbt` for sbt 1.0: ```scala -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") ``` To add the plugin only to a single project, put this line into `project/plugins.sbt` of your project, instead. +The plugin currently supports sbt versions >= 0.13.6 and sbt 1.0.x. For versions supporting older versions of sbt see +the notes of version [0.8.2](https://github.com/jrudolph/sbt-dependency-graph/tree/v0.8.2#compatibility-notes). + ## Main Tasks * `dependencyTree`: Shows an ASCII tree representation of the project's dependencies From 93899f2eca2f8bc0c13d7dbda185b112ce33ba99 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 24 Oct 2017 18:35:40 +0200 Subject: [PATCH 29/38] Update README to de-emphasize `dependencyGraph` which is missing from sbt 1.0 version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce67a58d1..e4ad588b8 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ the notes of version [0.8.2](https://github.com/jrudolph/sbt-dependency-graph/tr * `dependencyTree`: Shows an ASCII tree representation of the project's dependencies * `dependencyBrowseGraph`: Opens a browser window with a visualization of the dependency graph (courtesy of graphlib-dot + dagre-d3). - * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console * `dependencyList`: Shows a flat list of all transitive dependencies on the sbt console (sorted by organization and name) * `whatDependsOn `: Find out what depends on an artifact. Shows a reverse dependency tree for the selected module. @@ -33,6 +32,7 @@ the notes of version [0.8.2](https://github.com/jrudolph/sbt-dependency-graph/tr Use e.g. [yEd](http://www.yworks.com/en/products_yed_about.html) to format the graph to your needs. * `dependencyDot`: Generates a .dot file with the project's dependencies to `target/dependencies-.dot`. Use [graphviz](http://www.graphviz.org/) to render it to your preferred graphic format. + * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console (only supported on sbt 0.13) * `ivyReport`: let's ivy generate the resolution report for you project. Use `show ivyReport` for the filename of the generated report @@ -70,4 +70,4 @@ Published under the [Apache License 2.0](http://en.wikipedia.org/wiki/Apache_lic [global plugin]: http://www.scala-sbt.org/0.13/tutorial/Using-Plugins.html#Global+plugins [global build configuration]: http://www.scala-sbt.org/0.13/docs/Global-Settings.html -[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 \ No newline at end of file +[#19]: https://github.com/jrudolph/sbt-dependency-graph/issues/19 From 85284c6a4f6c43320aa0fbe5dec2b6a5b0cc1653 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Wed, 25 Oct 2017 17:48:40 +0200 Subject: [PATCH 30/38] Add release notes for 0.9.0 (even if they cannot be published any more) --- notes/0.9.0.markdown | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 notes/0.9.0.markdown diff --git a/notes/0.9.0.markdown b/notes/0.9.0.markdown new file mode 100644 index 000000000..ab40c856e --- /dev/null +++ b/notes/0.9.0.markdown @@ -0,0 +1,7 @@ +This version (finally!) adds support for sbt 1.0. sbt-dependency-graph depends on a lot of internals from sbt to do its +work which is why it was quite an effort to do the migration. Thanks [@MasseGuillaume](https://github.com/MasseGuillaume) from Scala Center, +[@2m](https://github.com/2m), and [@xuwei-k](https://github.com/xuwei-k) for helping out with the effort. + +The plugin is cross-built for sbt 0.13 (and will continued to be for while). The `dependencyGraph` task is currently not +supported on sbt 1.0. Use `dependencyBrowseGraph`, instead. + From d9b159ba8ae609f565b84ed3c7bb6141215717c2 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Wed, 25 Oct 2017 17:54:18 +0200 Subject: [PATCH 31/38] Replace notes file by a single CHANGELOG.md --- CHANGELOG.md | 124 +++++++++++++++++++++++++++++++++++++++++++ notes/0.6.0.markdown | 12 ----- notes/0.7.0.markdown | 12 ----- notes/0.7.1.markdown | 5 -- notes/0.7.2.markdown | 5 -- notes/0.7.3.markdown | 7 --- notes/0.7.4.markdown | 1 - notes/0.7.5.markdown | 10 ---- notes/0.8.0.markdown | 20 ------- notes/0.8.1.markdown | 9 ---- notes/0.8.2.markdown | 2 - notes/0.9.0.markdown | 7 --- notes/about.markdown | 1 - 13 files changed, 124 insertions(+), 91 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 notes/0.6.0.markdown delete mode 100644 notes/0.7.0.markdown delete mode 100644 notes/0.7.1.markdown delete mode 100644 notes/0.7.2.markdown delete mode 100644 notes/0.7.3.markdown delete mode 100644 notes/0.7.4.markdown delete mode 100644 notes/0.7.5.markdown delete mode 100644 notes/0.8.0.markdown delete mode 100644 notes/0.8.1.markdown delete mode 100644 notes/0.8.2.markdown delete mode 100644 notes/0.9.0.markdown delete mode 100644 notes/about.markdown diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..1c3c62d82 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,124 @@ +# Changelog + +## Version 0.9.0 (2017-10-25) + +This version (finally!) adds support for sbt 1.0. *sbt-dependency-graph* depends on a lot of internals from sbt to do its +work which is why it was quite an effort to do the migration. Thanks [@MasseGuillaume](https://github.com/MasseGuillaume) from Scala Center, +[@2m](https://github.com/2m), and [@xuwei-k](https://github.com/xuwei-k) for helping out with the effort. + +The plugin is cross-built for sbt 0.13 (and will continued to be for while). The `dependencyGraph` task is currently not +supported on sbt 1.0. Use `dependencyBrowseGraph`, instead. + +## Version 0.8.2 (2016-02-01) + +This is a maintenance release [fixing](https://github.com/jrudolph/sbt-dependency-graph/issues/89) `dependencyBrowseGraph` +in the latest Chrome versions. Thanks [@chtefi](https://github.com/chtefi)! + +## Version 0.8.1 + +This is a maintenance release fixing a regression in 0.8.0 and adding two small features. + +All changes: + + * [#84](https://github.com/jrudolph/sbt-dependency-graph/issues/84): Fix regression of DOT label rendering introduced in 0.8.0. + * [#83](https://github.com/jrudolph/sbt-dependency-graph/issues/83): Added new task `dependencyStats` which prints a + simple table of jar sizes for all your dependencies. Handy if you want to know why your assembled jar gets so big. + * [#85](https://github.com/jrudolph/sbt-dependency-graph/issues/85): Added new task `dependencyList` which prints a + flat, deduplicated list of all the transitive dependencies. + +## Version 0.8.0 + +sbt-dependency-graph is finally an AutoPlugin and can now show the dependency graph in the browser directly. + +### New features + + - (experimental) open dependency graph directly in the browser with `dependencyBrowseGraph` ([#29](https://github.com/jrudolph/sbt-dependency-graph/issues/29)) + ![dependencyBrowseGraph in action](https://gist.githubusercontent.com/jrudolph/941754bcf67a0fafe495/raw/7d80d766feb7af6ba2a69494e1f3ceb1fd40d4da/Screenshot%2520from%25202015-11-26%252014:18:19.png) + + - this plugin is finally an sbt AutoPlugin and it is automatically enabled + ([#51](https://github.com/jrudolph/sbt-dependency-graph/issues/51)) + +**Note: To update from 0.7.x remove the `net.virtualvoid.sbt.graph.Plugin.graphSettings` line from your configurations.** + +### Other changes + + - a new backend was implemented which accesses the in-memory dependency data structures of sbt directly. The plugin doesn't + require accessing the ivy report XML any more (the old backend can still be wired in for comparisons if needed) which + should have solved the race condition and the dreaded `FileNotFoundException` ([#39](https://github.com/jrudolph/sbt-dependency-graph/issues/39)) + in multi-module projects. The new backend is only used for sbt >= 0.13.6. + - code was restructured which touched a lot of the classes but didn't change the function or syntax of settings and tasks. + - fixed [#77](https://github.com/jrudolph/sbt-dependency-graph/issues/77) + + +## Version 0.7.5 + +This is a maintenance release adding support for sbt 0.13.8. + +All changes: + + * [#67](https://github.com/jrudolph/sbt-dependency-graph/issues/67): Added support for sbt 0.13.8. Thanks + [@eed3si9n](https://github.com/eed3si9n) for the fix. + * [#37](https://github.com/jrudolph/sbt-dependency-graph/issues/37): Don't fail with StringIndexOutOfBoundsException + for deep trees. + * [#44](https://github.com/jrudolph/sbt-dependency-graph/issues/44): Only match scala lib by org/name. + Thanks [@2beaucoup](https://github.com/2beaucoup) for the fix. + +## Version 0.7.4 + +This is a maintenance release fixing an exception when generating graphs without a terminal [#32](https://github.com/jrudolph/sbt-dependency-graph/issues/32). + +## Version 0.7.3 + +This is a maintenance release. Following issues have been fixed: + + * [#27](https://github.com/jrudolph/sbt-dependency-graph/issues/27): A dependency configured with + a version range was not properly associated with its dependant. + * [#30](https://github.com/jrudolph/sbt-dependency-graph/issues/30) & [#31](https://github.com/jrudolph/sbt-dependency-graph/issues/31): + Make it work again with sbt 0.12.3. The path of the dependency resolution file changed in sbt 0.12.3. + Thanks [ebowman](https://github.com/ebowman) for the fix. + +## Version 0.7.2 + +This is a maintenance release. Following issues have been fixed: + + * [#27](https://github.com/jrudolph/sbt-dependency-graph/issues/27): A dependency configured with + a version range was not properly associated with its dependant. + + +## Version 0.7.1 + +New features in this version: + + * `dependency-license-info`: show dependencies grouped by declared license + * `dependency-dot`: create dot file from dependency graph. Contributed by + [berleon](https://github.com/berleon). + +## Version 0.7.0 + +New features in this version: + + * `dependency-graph` now renders a real graph. Thanks go to [Matt Russell](https://github.com/mdr/) for + this added awesomeness. + * The tree output from previous versions is now available with `dependency-tree`. + * New task `what-depends-on` showing reverse dependency tree for a selected module (incl. tab-completion for modules) + * Don't fail in cases of a missing dependency. Show errors directly in the output. + * Show info about evicted versions. + * By default, exclude scala-library dependency and append `[S]` to the artifact name instead. Set + `filter-scala-library` to `false` to disable this feature. + * Works with sbt 0.12.1. The ivy report files were moved to a new location making an update necessary. + + +## Version 0.6.0 + +New features in this version: + + * `dependency-graph` task now prints the dependency graph to the console + (contributed by @gseitz) + * `dependency-graph-ml` contains now the old functionality of `dependency-graph` + which generates a `.graphml` file. Nodes now contain the dependency version as well (contributed by @gseitz). + * The output filename of `dependency-graph-ml` has been changed to include the configuration name. It is now + configurable using the `dependency-graph-ml-file` setting. + * The common `scalaVersion in update` idiom to support Scala 2.9.1 libraries in a + Scala 2.9.2 broke the plugin in 0.5.2, because it wouldn't find the ivy report xml file + any more. This was fixed. + * All tasks are scoped by configuration. diff --git a/notes/0.6.0.markdown b/notes/0.6.0.markdown deleted file mode 100644 index ddfef082d..000000000 --- a/notes/0.6.0.markdown +++ /dev/null @@ -1,12 +0,0 @@ -New features in this version: - - * `dependency-graph` task now prints the dependency graph to the console - (contributed by @gseitz) - * `dependency-graph-ml` contains now the old functionality of `dependency-graph` - which generates a `.graphml` file. Nodes now contain the dependency version as well (contributed by @gseitz). - * The output filename of `dependency-graph-ml` has been changed to include the configuration name. It is now - configurable using the `dependency-graph-ml-file` setting. - * The common `scalaVersion in update` idiom to support Scala 2.9.1 libraries in a - Scala 2.9.2 broke the plugin in 0.5.2, because it wouldn't find the ivy report xml file - any more. This was fixed. - * All tasks are scoped by configuration. diff --git a/notes/0.7.0.markdown b/notes/0.7.0.markdown deleted file mode 100644 index 5ec96ae07..000000000 --- a/notes/0.7.0.markdown +++ /dev/null @@ -1,12 +0,0 @@ -New features in this version: - - * `dependency-graph` now renders a real graph. Thanks go to [Matt Russell](https://github.com/mdr/) for - this added awesomeness. - * The tree output from previous versions is now available with `dependency-tree`. - * New task `what-depends-on` showing reverse dependency tree for a selected module (incl. tab-completion for modules) - * Don't fail in cases of a missing dependency. Show errors directly in the output. - * Show info about evicted versions. - * By default, exclude scala-library dependency and append `[S]` to the artifact name instead. Set - `filter-scala-library` to `false` to disable this feature. - * Works with sbt 0.12.1. The ivy report files were moved to a new location making an update necessary. - diff --git a/notes/0.7.1.markdown b/notes/0.7.1.markdown deleted file mode 100644 index dd7a66315..000000000 --- a/notes/0.7.1.markdown +++ /dev/null @@ -1,5 +0,0 @@ -New features in this version: - - * `dependency-license-info`: show dependencies grouped by declared license - * `dependency-dot`: create dot file from dependency graph. Contributed by - [berleon](https://github.com/berleon). diff --git a/notes/0.7.2.markdown b/notes/0.7.2.markdown deleted file mode 100644 index da96a4007..000000000 --- a/notes/0.7.2.markdown +++ /dev/null @@ -1,5 +0,0 @@ -This is a maintenance release. Following issues have been fixed: - - * [#27](https://github.com/jrudolph/sbt-dependency-graph/issues/27): A dependency configured with - a version range was not properly associated with its dependant. - diff --git a/notes/0.7.3.markdown b/notes/0.7.3.markdown deleted file mode 100644 index 4fc8b1f75..000000000 --- a/notes/0.7.3.markdown +++ /dev/null @@ -1,7 +0,0 @@ -This is a maintenance release. Following issues have been fixed: - - * [#27](https://github.com/jrudolph/sbt-dependency-graph/issues/27): A dependency configured with - a version range was not properly associated with its dependant. - * [#30](https://github.com/jrudolph/sbt-dependency-graph/issues/30) & [#31](https://github.com/jrudolph/sbt-dependency-graph/issues/31): - Make it work again with sbt 0.12.3. The path of the dependency resolution file changed in sbt 0.12.3. - Thanks [ebowman](https://github.com/ebowman) for the fix. diff --git a/notes/0.7.4.markdown b/notes/0.7.4.markdown deleted file mode 100644 index ac535986a..000000000 --- a/notes/0.7.4.markdown +++ /dev/null @@ -1 +0,0 @@ -This is a maintenance release fixing an exception when generating graphs without a terminal [#32](https://github.com/jrudolph/sbt-dependency-graph/issues/32). diff --git a/notes/0.7.5.markdown b/notes/0.7.5.markdown deleted file mode 100644 index fbb41457a..000000000 --- a/notes/0.7.5.markdown +++ /dev/null @@ -1,10 +0,0 @@ -This is a maintenance release adding support for sbt 0.13.8. - -All changes: - - * [#67](https://github.com/jrudolph/sbt-dependency-graph/issues/67): Added support for sbt 0.13.8. Thanks - [@eed3si9n](https://github.com/eed3si9n) for the fix. - * [#37](https://github.com/jrudolph/sbt-dependency-graph/issues/37): Don't fail with StringIndexOutOfBoundsException - for deep trees. - * [#44](https://github.com/jrudolph/sbt-dependency-graph/issues/44): Only match scala lib by org/name. - Thanks [@2beaucoup](https://github.com/2beaucoup) for the fix. diff --git a/notes/0.8.0.markdown b/notes/0.8.0.markdown deleted file mode 100644 index 9670242c8..000000000 --- a/notes/0.8.0.markdown +++ /dev/null @@ -1,20 +0,0 @@ -sbt-dependency-graph is finally an AutoPlugin and can now show the dependency graph in the browser directly. - -## New features - - - (experimental) open dependency graph directly in the browser with `dependencyBrowseGraph` ([#29](https://github.com/jrudolph/sbt-dependency-graph/issues/29)) - ![dependencyBrowseGraph in action](https://gist.githubusercontent.com/jrudolph/941754bcf67a0fafe495/raw/7d80d766feb7af6ba2a69494e1f3ceb1fd40d4da/Screenshot%2520from%25202015-11-26%252014:18:19.png) - - - this plugin is finally an sbt AutoPlugin and it is automatically enabled - ([#51](https://github.com/jrudolph/sbt-dependency-graph/issues/51)) - -**Note: To update from 0.7.x remove the `net.virtualvoid.sbt.graph.Plugin.graphSettings` line from your configurations.** - -## Other changes - - - a new backend was implemented which accesses the in-memory dependency data structures of sbt directly. The plugin doesn't - require accessing the ivy report XML any more (the old backend can still be wired in for comparisons if needed) which - should have solved the race condition and the dreaded `FileNotFoundException` ([#39](https://github.com/jrudolph/sbt-dependency-graph/issues/39)) - in multi-module projects. The new backend is only used for sbt >= 0.13.6. - - code was restructured which touched a lot of the classes but didn't change the function or syntax of settings and tasks. - - fixed [#77](https://github.com/jrudolph/sbt-dependency-graph/issues/77) diff --git a/notes/0.8.1.markdown b/notes/0.8.1.markdown deleted file mode 100644 index 21f9aaabe..000000000 --- a/notes/0.8.1.markdown +++ /dev/null @@ -1,9 +0,0 @@ -This is a maintenance release fixing a regression in 0.8.0 and adding two small features. - -All changes: - - * [#84](https://github.com/jrudolph/sbt-dependency-graph/issues/84): Fix regression of DOT label rendering introduced in 0.8.0. - * [#83](https://github.com/jrudolph/sbt-dependency-graph/issues/83): Added new task `dependencyStats` which prints a - simple table of jar sizes for all your dependencies. Handy if you want to know why your assembled jar gets so big. - * [#85](https://github.com/jrudolph/sbt-dependency-graph/issues/85): Added new task `dependencyList` which prints a - flat, deduplicated list of all the transitive dependencies. \ No newline at end of file diff --git a/notes/0.8.2.markdown b/notes/0.8.2.markdown deleted file mode 100644 index 400e9b929..000000000 --- a/notes/0.8.2.markdown +++ /dev/null @@ -1,2 +0,0 @@ -This is a maintenance release [fixing](https://github.com/jrudolph/sbt-dependency-graph/issues/89) `dependencyBrowseGraph` -in the latest Chrome versions. Thanks [@chtefi](https://github.com/chtefi)! \ No newline at end of file diff --git a/notes/0.9.0.markdown b/notes/0.9.0.markdown deleted file mode 100644 index ab40c856e..000000000 --- a/notes/0.9.0.markdown +++ /dev/null @@ -1,7 +0,0 @@ -This version (finally!) adds support for sbt 1.0. sbt-dependency-graph depends on a lot of internals from sbt to do its -work which is why it was quite an effort to do the migration. Thanks [@MasseGuillaume](https://github.com/MasseGuillaume) from Scala Center, -[@2m](https://github.com/2m), and [@xuwei-k](https://github.com/xuwei-k) for helping out with the effort. - -The plugin is cross-built for sbt 0.13 (and will continued to be for while). The `dependencyGraph` task is currently not -supported on sbt 1.0. Use `dependencyBrowseGraph`, instead. - diff --git a/notes/about.markdown b/notes/about.markdown deleted file mode 100644 index 62e921d0a..000000000 --- a/notes/about.markdown +++ /dev/null @@ -1 +0,0 @@ -[sbt-dependency-graph](https://github.com/jrudolph/sbt-dependency-graph/) is an sbt plugin to visualize dependencies of your build. From 5e0aa1d0fc01991417c670983047bcccfbbaee34 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Wed, 25 Oct 2017 17:59:24 +0200 Subject: [PATCH 32/38] Add dates to released versions It's been a long ride... almost six years by now :) --- CHANGELOG.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c3c62d82..3e6f99b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ supported on sbt 1.0. Use `dependencyBrowseGraph`, instead. This is a maintenance release [fixing](https://github.com/jrudolph/sbt-dependency-graph/issues/89) `dependencyBrowseGraph` in the latest Chrome versions. Thanks [@chtefi](https://github.com/chtefi)! -## Version 0.8.1 +## Version 0.8.1 (2016-01-08) This is a maintenance release fixing a regression in 0.8.0 and adding two small features. @@ -26,7 +26,7 @@ All changes: * [#85](https://github.com/jrudolph/sbt-dependency-graph/issues/85): Added new task `dependencyList` which prints a flat, deduplicated list of all the transitive dependencies. -## Version 0.8.0 +## Version 0.8.0 (2015-11-26) sbt-dependency-graph is finally an AutoPlugin and can now show the dependency graph in the browser directly. @@ -50,7 +50,7 @@ sbt-dependency-graph is finally an AutoPlugin and can now show the dependency gr - fixed [#77](https://github.com/jrudolph/sbt-dependency-graph/issues/77) -## Version 0.7.5 +## Version 0.7.5 (2015-03-30) This is a maintenance release adding support for sbt 0.13.8. @@ -63,11 +63,11 @@ All changes: * [#44](https://github.com/jrudolph/sbt-dependency-graph/issues/44): Only match scala lib by org/name. Thanks [@2beaucoup](https://github.com/2beaucoup) for the fix. -## Version 0.7.4 +## Version 0.7.4 (2013-06-26) This is a maintenance release fixing an exception when generating graphs without a terminal [#32](https://github.com/jrudolph/sbt-dependency-graph/issues/32). -## Version 0.7.3 +## Version 0.7.3 (2013-04-28) This is a maintenance release. Following issues have been fixed: @@ -77,7 +77,7 @@ This is a maintenance release. Following issues have been fixed: Make it work again with sbt 0.12.3. The path of the dependency resolution file changed in sbt 0.12.3. Thanks [ebowman](https://github.com/ebowman) for the fix. -## Version 0.7.2 +## Version 0.7.2 (2013-03-02) This is a maintenance release. Following issues have been fixed: @@ -93,7 +93,7 @@ New features in this version: * `dependency-dot`: create dot file from dependency graph. Contributed by [berleon](https://github.com/berleon). -## Version 0.7.0 +## Version 0.7.0 (2012-10-24) New features in this version: @@ -108,7 +108,7 @@ New features in this version: * Works with sbt 0.12.1. The ivy report files were moved to a new location making an update necessary. -## Version 0.6.0 +## Version 0.6.0 (2012-05-23) New features in this version: @@ -122,3 +122,9 @@ New features in this version: Scala 2.9.2 broke the plugin in 0.5.2, because it wouldn't find the ivy report xml file any more. This was fixed. * All tasks are scoped by configuration. + +## Version 0.5.2 (2012-02-13) + +## Version 0.5.1 (2011-11-18) + +## Version 0.5 (2011-11-15) \ No newline at end of file From 6cff0c5e8d87b50d4fe25793ceb170e9053991b4 Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Thu, 26 Oct 2017 13:33:28 +0900 Subject: [PATCH 33/38] use oraclejdk8 travis-ci no longer support oraclejdk7 https://github.com/travis-ci/travis-ci/issues/7884#issuecomment-308451879 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38f878a6d..90b2f79dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false language: scala -jdk: oraclejdk7 +jdk: oraclejdk8 script: - sbt ";^test ;^scripted" From 5e3bbdb8c230ec3b6a2a35a647df0adc45eecd53 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 2 Jan 2018 13:55:48 +0100 Subject: [PATCH 34/38] README: sbt 0.13 is only supported starting from 0.13.10 Fixes #148. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4ad588b8..07b9c420b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") To add the plugin only to a single project, put this line into `project/plugins.sbt` of your project, instead. -The plugin currently supports sbt versions >= 0.13.6 and sbt 1.0.x. For versions supporting older versions of sbt see +The plugin currently supports sbt versions >= 0.13.10 and sbt 1.0.x. For versions supporting older versions of sbt see the notes of version [0.8.2](https://github.com/jrudolph/sbt-dependency-graph/tree/v0.8.2#compatibility-notes). ## Main Tasks From 6f4dfaa45ecd8b607df689bade5b7bebd87ac96e Mon Sep 17 00:00:00 2001 From: Leif Wickland Date: Tue, 10 Apr 2018 10:22:48 -0600 Subject: [PATCH 35/38] Fix minor typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07b9c420b..0fa1cb755 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ the notes of version [0.8.2](https://github.com/jrudolph/sbt-dependency-graph/tr * `dependencyDot`: Generates a .dot file with the project's dependencies to `target/dependencies-.dot`. Use [graphviz](http://www.graphviz.org/) to render it to your preferred graphic format. * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console (only supported on sbt 0.13) - * `ivyReport`: let's ivy generate the resolution report for you project. Use + * `ivyReport`: Lets ivy generate the resolution report for you project. Use `show ivyReport` for the filename of the generated report All tasks can be scoped to a configuration to get the report for a specific configuration. `test:dependencyGraph`, From b3fd3ce7e4e5f06f04269d4c024dd8aa5afc45c3 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Wed, 23 May 2018 13:15:49 +0900 Subject: [PATCH 36/38] fix procedure syntax --- .../net/virtualvoid/sbt/graph/DependencyGraphSettings.scala | 2 +- .../scala/net/virtualvoid/sbt/graph/rendering/GraphML.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 2bf7a13b6..15b443775 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -142,7 +142,7 @@ object DependencyGraphSettings { def printFromGraph(f: ModuleGraph ⇒ String) = Def.task { streams.value.log.info(f(moduleGraph.value)) } - def showLicenseInfo(graph: ModuleGraph, streams: TaskStreams) { + def showLicenseInfo(graph: ModuleGraph, streams: TaskStreams): Unit = { val output = graph.nodes.filter(_.isUsed).groupBy(_.license).toSeq.sortBy(_._1).map { case (license, modules) ⇒ diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/GraphML.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/GraphML.scala index 436a90c2e..e1681fdad 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/GraphML.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/GraphML.scala @@ -21,7 +21,7 @@ import net.virtualvoid.sbt.graph.ModuleGraph import scala.xml.XML object GraphML { - def saveAsGraphML(graph: ModuleGraph, outputFile: String) { + def saveAsGraphML(graph: ModuleGraph, outputFile: String): Unit = { val nodesXml = for (n ← graph.nodes) yield From 978c3c4e2c99a14a6f0af9c861819a8fa1f487ea Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 16 Jul 2018 11:44:03 +0200 Subject: [PATCH 37/38] Move the sbt invocation notice --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e667d9987..8315118c8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This plugin is an auto-plugin which will be automatically enabled starting from * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console * `dependencyList`: Shows a flat list of all transitive dependencies on the sbt console (sorted by organization and name) * `whatDependsOn `: Find out what depends on an artifact. Shows a reverse dependency - tree for the selected module. Enclose the command in quotes (i.e. `sbt "whatDependsOn "` when not using within an sbt shell). + tree for the selected module. * `dependencyLicenseInfo`: show dependencies grouped by declared license * `dependencyStats`: Shows a table with each module a row with (transitive) Jar sizes and number of dependencies * `dependencyGraphMl`: Generates a `.graphml` file with the project's dependencies to `target/dependencies-.graphml`. @@ -43,6 +43,8 @@ All tasks can be scoped to a configuration to get the report for a specific conf for example, prints the dependencies in the `test` configuration. If you don't specify any configuration, `compile` is assumed as usual. +Note: If you want to run tasks with parameters from outside the sbt shell, make sure to put the whole task invocation in quotes, e.g. `sbt "whatDependsOn "`. + ## Configuration settings * `filterScalaLibrary`: Defines if the scala library should be excluded from the output of the dependency-* functions. From 321f70b17f3d8478e381f65220ec9ece28e8fa76 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 16 Jul 2018 11:57:50 +0200 Subject: [PATCH 38/38] Update to sbt 1.1.6 + new plugin versions + new dependency versions + freshly autoformatted --- build.sbt | 10 ++- project/build.properties | 2 +- project/plugins.sbt | 4 +- .../sbt/graph/rendering/AsciiGraph.scala | 3 +- .../DependencyGraphSbtCompat.scala | 32 ++++----- .../DependencyGraphSbtCompat.scala | 3 +- .../sbt/graph/DependencyGraphKeys.scala | 69 ++++++++++++------- .../sbt/graph/DependencyGraphSettings.scala | 23 +++---- .../sbt/graph/backend/IvyReport.scala | 3 +- .../sbt/graph/backend/SbtUpdateReport.scala | 3 +- .../net/virtualvoid/sbt/graph/model.scala | 20 +++--- .../virtualvoid/sbt/graph/rendering/DOT.scala | 12 ++-- .../sbt/graph/rendering/Statistics.scala | 12 ++-- .../sbt/graph/util/AsciiTreeLayout.scala | 9 +-- .../testDotFileGeneration/build.sbt | 5 +- 15 files changed, 119 insertions(+), 91 deletions(-) diff --git a/build.sbt b/build.sbt index 411b401b2..817aaeeda 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,6 @@ -ScriptedPlugin.scriptedSettings -ScriptedPlugin.scriptedLaunchOpts += s"-Dproject.version=${version.value}" +scriptedLaunchOpts += s"-Dproject.version=${version.value}" libraryDependencies ++= { - println(s"Evaluated ${sbtVersion in pluginCrossBuild value}") if ((sbtVersion in pluginCrossBuild).value startsWith "0.13") Seq("com.github.mdr" %% "ascii-graphs" % "0.0.3") else @@ -10,15 +8,15 @@ libraryDependencies ++= { } -libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.5" % Test +libraryDependencies += "org.specs2" %% "specs2-core" % "3.10.0" % Test libraryDependencies += Defaults.sbtPluginExtra( - "com.dwijnand" % "sbt-compat" % "1.1.0", + "com.dwijnand" % "sbt-compat" % "1.2.6", (sbtBinaryVersion in pluginCrossBuild).value, (scalaBinaryVersion in update).value ) -crossSbtVersions := Seq("1.0.2", "0.13.16") +crossSbtVersions := Seq("1.1.6", "0.13.16") scalacOptions ++= Seq( "-deprecation", diff --git a/project/build.properties b/project/build.properties index c091b86ca..d6e35076c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.16 +sbt.version=1.1.6 diff --git a/project/plugins.sbt b/project/plugins.sbt index 576698340..cb24a862c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value +libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value -addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") +addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "2.0.0") diff --git a/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala index 701fdce7d..f1c83ec18 100644 --- a/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala +++ b/src/main/scala-sbt-0.13/net/virtualvoid/sbt/graph/rendering/AsciiGraph.scala @@ -55,6 +55,5 @@ object AsciiGraph { log.info("\n") log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.") } - } - ) + }) } diff --git a/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala index cb65aa82c..9408ed050 100644 --- a/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala +++ b/src/main/scala-sbt-0.13/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -22,9 +22,9 @@ object DependencyGraphSbtCompat { } /** - * This is copied directly from https://github.com/sbt/sbt/blob/2952a2b9b672c5402b824ad2d2076243eb643598/main/src/main/scala/sbt/Defaults.scala#L1471-L1523 - * and then changed to update the UpdateConfiguration to ignore missing artifacts. - */ + * This is copied directly from https://github.com/sbt/sbt/blob/2952a2b9b672c5402b824ad2d2076243eb643598/main/src/main/scala/sbt/Defaults.scala#L1471-L1523 + * and then changed to update the UpdateConfiguration to ignore missing artifacts. + */ def updateTask(task: TaskKey[_]): Initialize[Task[UpdateReport]] = Def.task { val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached) val isRoot = executionRoots.value contains resolvedScoped.value @@ -32,8 +32,8 @@ object DependencyGraphSbtCompat { val s = streams.value val fullUpdateOutput = s.cacheDirectory / "out" val forceUpdateByTime = forceUpdate match { - case None => false - case Some(period) => + case None ⇒ false + case Some(period) ⇒ val elapsedDuration = new FiniteDuration(System.currentTimeMillis() - fullUpdateOutput.lastModified(), TimeUnit.MILLISECONDS) fullUpdateOutput.exists() && elapsedDuration > period } @@ -42,17 +42,17 @@ object DependencyGraphSbtCompat { // Only substitute unmanaged jars for managed jars when the major.minor parts of the versions the same for: // the resolved Scala version and the scalaHome version: compatible (weakly- no qualifier checked) // the resolved Scala version and the declared scalaVersion: assume the user intended scalaHome to override anything with scalaVersion - def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) => + def subUnmanaged(subVersion: String, jars: Seq[File]) = (sv: String) ⇒ (partialVersion(sv), partialVersion(subVersion), partialVersion(scalaVersion.value)) match { - case (Some(res), Some(sh), _) if res == sh => jars - case (Some(res), _, Some(decl)) if res == decl => jars - case _ => Nil + case (Some(res), Some(sh), _) if res == sh ⇒ jars + case (Some(res), _, Some(decl)) if res == decl ⇒ jars + case _ ⇒ Nil } - val subScalaJars: String => Seq[File] = Defaults.unmanagedScalaInstanceOnly.value match { - case Some(si) => subUnmanaged(si.version, si.jars) - case None => sv => if (scalaProvider.version == sv) scalaProvider.jars else Nil + val subScalaJars: String ⇒ Seq[File] = Defaults.unmanagedScalaInstanceOnly.value match { + case Some(si) ⇒ subUnmanaged(si.version, si.jars) + case None ⇒ sv ⇒ if (scalaProvider.version == sv) scalaProvider.jars else Nil } - val transform: UpdateReport => UpdateReport = r => sbt.Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) + val transform: UpdateReport ⇒ UpdateReport = r ⇒ sbt.Classpaths.substituteScalaFiles(scalaOrganization.value, r)(subScalaJars) val uwConfig = (unresolvedWarningConfiguration in update).value val show = Reference.display(thisProjectRef.value) val st = state.value @@ -66,9 +66,9 @@ object DependencyGraphSbtCompat { // This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug. import UpdateLogging.{ Full, DownloadOnly, Default } val uc = (logLevel in update).?.value orElse st.get(logLevel.key) match { - case Some(Level.Debug) if uc0.logging == Default => uc0.copy(logging = Full) - case Some(x) if uc0.logging == Default => uc0.copy(logging = DownloadOnly) - case _ => uc0 + case Some(Level.Debug) if uc0.logging == Default ⇒ uc0.copy(logging = Full) + case Some(x) if uc0.logging == Default ⇒ uc0.copy(logging = DownloadOnly) + case _ ⇒ uc0 } val ewo = if (executionRoots.value exists { _.key == evicted.key }) EvictionWarningOptions.empty diff --git a/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala index 4e08319db..06a466a31 100644 --- a/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala +++ b/src/main/scala-sbt-1.0/sbt/dependencygraph/DependencyGraphSbtCompat.scala @@ -58,7 +58,6 @@ object DependencyGraphSbtCompat { ewo = evictionOptions, mavenStyle = publishMavenStyle.value, compatWarning = compatibilityWarningOptions.value, - log = s.log - ) + log = s.log) } } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala index ace01d160..ef19a0a6d 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala @@ -19,53 +19,76 @@ package net.virtualvoid.sbt.graph import sbt._ trait DependencyGraphKeys { - val dependencyGraphMLFile = SettingKey[File]("dependency-graph-ml-file", + val dependencyGraphMLFile = SettingKey[File]( + "dependency-graph-ml-file", "The location the graphml file should be generated at") - val dependencyGraphML = TaskKey[File]("dependency-graph-ml", + val dependencyGraphML = TaskKey[File]( + "dependency-graph-ml", "Creates a graphml file containing the dependency-graph for a project") - val dependencyDotFile = SettingKey[File]("dependency-dot-file", + val dependencyDotFile = SettingKey[File]( + "dependency-dot-file", "The location the dot file should be generated at") - val dependencyDotNodeLabel = SettingKey[(String, String, String) ⇒ String]("dependency-dot-node-label", + val dependencyDotNodeLabel = SettingKey[(String, String, String) ⇒ String]( + "dependency-dot-node-label", "Returns a formated string of a dependency. Takes organisation, name and version as parameters") - val dependencyDotHeader = SettingKey[String]("dependency-dot-header", + val dependencyDotHeader = SettingKey[String]( + "dependency-dot-header", "The header of the dot file. (e.g. to set your preferred node shapes)") - val dependencyDot = TaskKey[File]("dependency-dot", + val dependencyDot = TaskKey[File]( + "dependency-dot", "Creates a dot file containing the dependency-graph for a project") - val dependencyDotString = TaskKey[String]("dependency-dot-string", + val dependencyDotString = TaskKey[String]( + "dependency-dot-string", "Creates a String containing the dependency-graph for a project in dot format") - val dependencyBrowseGraphTarget = SettingKey[File]("dependency-browse-graph-target", + val dependencyBrowseGraphTarget = SettingKey[File]( + "dependency-browse-graph-target", "The location dependency browse graph files should be put.") - val dependencyBrowseGraphHTML = TaskKey[URI]("dependency-browse-graph-html", + val dependencyBrowseGraphHTML = TaskKey[URI]( + "dependency-browse-graph-html", "Creates an HTML page that can be used to view the graph.") - val dependencyBrowseGraph = TaskKey[URI]("dependency-browse-graph", + val dependencyBrowseGraph = TaskKey[URI]( + "dependency-browse-graph", "Opens an HTML page that can be used to view the graph.") - val moduleGraph = TaskKey[ModuleGraph]("module-graph", + val moduleGraph = TaskKey[ModuleGraph]( + "module-graph", "The dependency graph for a project") - val moduleGraphIvyReport = TaskKey[ModuleGraph]("module-graph-ivy-report", + val moduleGraphIvyReport = TaskKey[ModuleGraph]( + "module-graph-ivy-report", "The dependency graph for a project as generated from an Ivy Report XML") - val moduleGraphSbt = TaskKey[ModuleGraph]("module-graph-sbt", + val moduleGraphSbt = TaskKey[ModuleGraph]( + "module-graph-sbt", "The dependency graph for a project as generated from SBT data structures.") - val asciiGraph = TaskKey[String]("dependency-graph-string", + val asciiGraph = TaskKey[String]( + "dependency-graph-string", "Returns a string containing the ascii representation of the dependency graph for a project") - val dependencyGraph = InputKey[Unit]("dependency-graph", + val dependencyGraph = InputKey[Unit]( + "dependency-graph", "Prints the ascii graph to the console") - val asciiTree = TaskKey[String]("dependency-tree-string", + val asciiTree = TaskKey[String]( + "dependency-tree-string", "Returns a string containing an ascii tree representation of the dependency graph for a project") - val dependencyTree = TaskKey[Unit]("dependency-tree", + val dependencyTree = TaskKey[Unit]( + "dependency-tree", "Prints an ascii tree of all the dependencies to the console") - val dependencyList = TaskKey[Unit]("dependency-list", + val dependencyList = TaskKey[Unit]( + "dependency-list", "Prints a list of all dependencies to the console") - val dependencyStats = TaskKey[Unit]("dependency-stats", + val dependencyStats = TaskKey[Unit]( + "dependency-stats", "Prints statistics for all dependencies to the console") - val ivyReportFunction = TaskKey[String ⇒ File]("ivy-report-function", + val ivyReportFunction = TaskKey[String ⇒ File]( + "ivy-report-function", "A function which returns the file containing the ivy report from the ivy cache for a given configuration") - val ivyReport = TaskKey[File]("ivy-report", + val ivyReport = TaskKey[File]( + "ivy-report", "A task which returns the location of the ivy report file for a given configuration (default `compile`).") val ignoreMissingUpdate = Keys.update in ivyReport - val filterScalaLibrary = SettingKey[Boolean]("filter-scala-library", + val filterScalaLibrary = SettingKey[Boolean]( + "filter-scala-library", "Specifies if scala dependency should be filtered in dependency-* output") - val licenseInfo = TaskKey[Unit]("dependency-license-info", + val licenseInfo = TaskKey[Unit]( + "dependency-license-info", "Aggregates and shows information about the licenses of dependencies") // internal diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 15b443775..f2b3bf3bc 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -160,20 +160,19 @@ object DependencyGraphSettings { } val artifactIdParser: Def.Initialize[State ⇒ Parser[ModuleId]] = - resolvedScoped { ctx ⇒ - (state: State) ⇒ - val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(Nil, Nil) + resolvedScoped { ctx ⇒ (state: State) ⇒ + val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(Nil, Nil) - import sbt.complete.DefaultParsers._ - graph.nodes.map(_.id).map { - case id @ ModuleId(org, name, version) ⇒ - (Space ~ token(org) ~ token(Space ~ name) ~ token(Space ~ version)).map(_ ⇒ id) - }.reduceOption(_ | _).getOrElse { - (Space ~> token(StringBasic, "organization") ~ Space ~ token(StringBasic, "module") ~ Space ~ token(StringBasic, "version")).map { - case ((((org, _), mod), _), version) ⇒ - ModuleId(org, mod, version) - } + import sbt.complete.DefaultParsers._ + graph.nodes.map(_.id).map { + case id @ ModuleId(org, name, version) ⇒ + (Space ~ token(org) ~ token(Space ~ name) ~ token(Space ~ version)).map(_ ⇒ id) + }.reduceOption(_ | _).getOrElse { + (Space ~> token(StringBasic, "organization") ~ Space ~ token(StringBasic, "module") ~ Space ~ token(StringBasic, "version")).map { + case ((((org, _), mod), _), version) ⇒ + ModuleId(org, mod, version) } + } } // This is to support 0.13.8's InlineConfigurationWithExcludes while not forcing 0.13.8 diff --git a/src/main/scala/net/virtualvoid/sbt/graph/backend/IvyReport.scala b/src/main/scala/net/virtualvoid/sbt/graph/backend/IvyReport.scala index 129dde6d9..426a68a3e 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/backend/IvyReport.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/backend/IvyReport.scala @@ -36,7 +36,8 @@ object IvyReport { revision ← mod \ "revision" rev = revision.attribute("name").get.text moduleId = moduleIdFromElement(mod, rev) - module = Module(moduleId, + module = Module( + moduleId, (revision \ "license").headOption.flatMap(_.attribute("name")).map(_.text), evictedByVersion = (revision \ "evicted-by").headOption.flatMap(_.attribute("rev").map(_.text)), error = revision.attribute("error").map(_.text)) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala index 3c8af89f6..42778efc5 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/backend/SbtUpdateReport.scala @@ -38,7 +38,8 @@ object SbtUpdateReport { def moduleEdge(chosenVersion: Option[String])(report: ModuleReport): (Module, Seq[Edge]) = { val evictedByVersion = if (report.evicted) chosenVersion else None val jarFile = report.artifacts.find(_._1.`type` == "jar").orElse(report.artifacts.find(_._1.extension == "jar")).map(_._2) - (Module( + ( + Module( id = report.module, license = report.licenses.headOption.map(_._1), evictedByVersion = evictedByVersion, diff --git a/src/main/scala/net/virtualvoid/sbt/graph/model.scala b/src/main/scala/net/virtualvoid/sbt/graph/model.scala index 96ce95258..cbfc43294 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/model.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/model.scala @@ -22,17 +22,19 @@ import sbinary.Format import scala.collection.mutable.{ HashMap, MultiMap, Set } -case class ModuleId(organisation: String, - name: String, - version: String) { +case class ModuleId( + organisation: String, + name: String, + version: String) { def idString: String = organisation + ":" + name + ":" + version } -case class Module(id: ModuleId, - license: Option[String] = None, - extraInfo: String = "", - evictedByVersion: Option[String] = None, - jarFile: Option[File] = None, - error: Option[String] = None) { +case class Module( + id: ModuleId, + license: Option[String] = None, + extraInfo: String = "", + evictedByVersion: Option[String] = None, + jarFile: Option[File] = None, + error: Option[String] = None) { def hadError: Boolean = error.isDefined def isUsed: Boolean = !isEvicted def isEvicted: Boolean = evictedByVersion.isDefined diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala index 368cf9e2d..dd63bacb3 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala @@ -20,15 +20,17 @@ package rendering object DOT { val EvictedStyle = "stroke-dasharray: 5,5" - def dotGraph(graph: ModuleGraph, - dotHead: String, - nodeFormation: (String, String, String) ⇒ String, - labelRendering: HTMLLabelRendering): String = { + def dotGraph( + graph: ModuleGraph, + dotHead: String, + nodeFormation: (String, String, String) ⇒ String, + labelRendering: HTMLLabelRendering): String = { val nodes = { for (n ← graph.nodes) yield { val style = if (n.isEvicted) EvictedStyle else "" val label = nodeFormation(n.id.organisation, n.id.name, n.id.version) - """ "%s"[%s style="%s"]""".format(n.id.idString, + """ "%s"[%s style="%s"]""".format( + n.id.idString, labelRendering.renderLabel(label), style) } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/Statistics.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/Statistics.scala index 5a82e922b..a9d10fdba 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/Statistics.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/Statistics.scala @@ -20,12 +20,12 @@ package rendering object Statistics { def renderModuleStatsList(graph: ModuleGraph): String = { case class ModuleStats( - id: ModuleId, - numDirectDependencies: Int, - numTransitiveDependencies: Int, - selfSize: Option[Long], - transitiveSize: Long, - transitiveDependencyStats: Map[ModuleId, ModuleStats]) { + id: ModuleId, + numDirectDependencies: Int, + numTransitiveDependencies: Int, + selfSize: Option[Long], + transitiveSize: Long, + transitiveDependencyStats: Map[ModuleId, ModuleStats]) { def transitiveStatsWithSelf: Map[ModuleId, ModuleStats] = transitiveDependencyStats + (id -> this) } diff --git a/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala b/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala index dc26c98c0..746dab6df 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/util/AsciiTreeLayout.scala @@ -13,10 +13,11 @@ object AsciiTreeLayout { // [info] | +-baz // [info] | // [info] +-quux - def toAscii[A](top: A, - children: A ⇒ Seq[A], - display: A ⇒ String, - maxColumn: Int = defaultColumnSize): String = { + def toAscii[A]( + top: A, + children: A ⇒ Seq[A], + display: A ⇒ String, + maxColumn: Int = defaultColumnSize): String = { val twoSpaces = " " + " " // prevent accidentally being converted into a tab def limitLine(s: String): String = if (s.length > maxColumn) s.slice(0, maxColumn - 2) + ".." diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt index 22edf69e4..bb8469447 100644 --- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt +++ b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/build.sbt @@ -5,7 +5,10 @@ import net.virtualvoid.sbt.graph.DependencyGraphKeys.dependencyDot import scala.collection.mutable.ListBuffer def defaultSettings = - Seq(scalaVersion := "2.9.2") + Seq( + scalaVersion := "2.9.2", + version := "0.1-SNAPSHOT" + ) lazy val justATransiviteDependencyEndpointProject = Project("just-a-transitive-dependency-endpoint", file("a"))