From 9cc95c04336fb198df0368ba4867d6bd23555561 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sun, 6 Mar 2016 19:39:15 +0100 Subject: [PATCH] Add project metadata and repositories in resolution cache in SBT plugin Fixes some publish or publishSigned commands failing, for some modules having the same dependencies as others (thus previously the same cache key, so no resolution was done and no Ivy file was generated, which made the publish or publishSigned command complains). --- .../src/main/scala-2.10/coursier/Tasks.scala | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/plugin/src/main/scala-2.10/coursier/Tasks.scala b/plugin/src/main/scala-2.10/coursier/Tasks.scala index fc48b39da..7f8d3a425 100644 --- a/plugin/src/main/scala-2.10/coursier/Tasks.scala +++ b/plugin/src/main/scala-2.10/coursier/Tasks.scala @@ -147,6 +147,8 @@ object Tasks { // FIXME More things should possibly be put here too (resolvers, etc.) private case class CacheKey( + project: Project, + repositories: Seq[Repository], resolution: Resolution, withClassifiers: Boolean, sbtClassifiers: Boolean @@ -250,29 +252,29 @@ object Tasks { Files.write(cacheIvyPropertiesFile.toPath, "".getBytes("UTF-8")) } + if (verbosity >= 2) { + println("InterProjectRepository") + for (p <- projects) + println(s" ${p.module}:${p.version}") + } + + val globalPluginsRepo = IvyRepository( + new File(sys.props("user.home") + "/.sbt/0.13/plugins/target/resolution-cache/").toURI.toString + + "[organization]/[module](/scala_[scalaVersion])(/sbt_[sbtVersion])/[revision]/resolved.xml.[ext]", + withChecksums = false, + withSignatures = false, + withArtifacts = false + ) + + val interProjectRepo = InterProjectRepository(projects) + + val ivyProperties = Map( + "ivy.home" -> (new File(sys.props("user.home")).toURI.getPath + ".ivy2") + ) ++ sys.props + + val repositories = Seq(globalPluginsRepo, interProjectRepo) ++ resolvers.flatMap(FromSbt.repository(_, ivyProperties)) + def report = { - if (verbosity >= 2) { - println("InterProjectRepository") - for (p <- projects) - println(s" ${p.module}:${p.version}") - } - - val globalPluginsRepo = IvyRepository( - new File(sys.props("user.home") + "/.sbt/0.13/plugins/target/resolution-cache/").toURI.toString + - "[organization]/[module](/scala_[scalaVersion])(/sbt_[sbtVersion])/[revision]/resolved.xml.[ext]", - withChecksums = false, - withSignatures = false, - withArtifacts = false - ) - - val interProjectRepo = InterProjectRepository(projects) - - val ivyProperties = Map( - "ivy.home" -> (new File(sys.props("user.home")).toURI.getPath + ".ivy2") - ) ++ sys.props - - val repositories = Seq(globalPluginsRepo, interProjectRepo) ++ resolvers.flatMap(FromSbt.repository(_, ivyProperties)) - val pool = Executors.newFixedThreadPool(parallelDownloads, Strategy.DefaultDaemonThreadFactory) def createLogger() = new TermDisplay(new OutputStreamWriter(System.err)) @@ -452,7 +454,13 @@ object Tasks { } resolutionsCache.getOrElseUpdate( - CacheKey(startRes.copy(filter = None), withClassifiers, sbtClassifiers), + CacheKey( + currentProject, + repositories, + startRes.copy(filter = None), + withClassifiers, + sbtClassifiers + ), report ) }