From d27c0ee46eeb9573403262d5ee9556aa99cf8d6c Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Fri, 27 Oct 2017 16:13:10 +0200 Subject: [PATCH 1/3] Quick hack to make publishSigned work again with sbt 1.0.2 Ideally, the scripted tests should still be run with sbt 1.0.1 too, to ensure there are no regression with it, but the current setup doesn't make that easy. --- project/Settings.scala | 2 +- .../coursier/SbtCompatibility.scala | 4 +-- .../coursier/SbtCompatibility.scala | 25 +++++++++++++++++-- .../main/scala/coursier/CoursierPlugin.scala | 5 ++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/project/Settings.scala b/project/Settings.scala index bff1b25e3..81d4d332d 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -206,7 +206,7 @@ object Settings { sbtVersion := { scalaBinaryVersion.value match { case "2.10" => "0.13.8" - case "2.12" => "1.0.1" + case "2.12" => "1.0.2" case _ => sbtVersion.value } }, diff --git a/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala index 6923d7538..a71ec59fb 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala +++ b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala @@ -137,7 +137,7 @@ object SbtCompatibility { def dependencies = module.modules } - def needsIvyXmlLocal = sbt.Keys.deliverLocalConfiguration - def needsIvyXml = sbt.Keys.deliverConfiguration + def needsIvyXmlLocal = List(sbt.Keys.deliverLocalConfiguration) + def needsIvyXml = List(sbt.Keys.deliverConfiguration) } diff --git a/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala b/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala index 03bc05553..22f70aaed 100644 --- a/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala +++ b/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala @@ -16,7 +16,28 @@ object SbtCompatibility { type IvySbt = sbt.internal.librarymanagement.IvySbt - def needsIvyXmlLocal = sbt.Keys.publishLocalConfiguration - def needsIvyXml = sbt.Keys.publishConfiguration + lazy val needsIvyXmlLocal = Seq(sbt.Keys.publishLocalConfiguration) ++ { + try { + val cls = sbt.Keys.getClass + val m = cls.getMethod("makeIvyXmlLocalConfiguration") + val task = m.invoke(sbt.Keys).asInstanceOf[sbt.TaskKey[sbt.PublishConfiguration]] + List(task) + } catch { + case _: Throwable => // FIXME Too wide + Nil + } + } + + lazy val needsIvyXml = Seq(sbt.Keys.publishConfiguration) ++ { + try { + val cls = sbt.Keys.getClass + val m = cls.getMethod("makeIvyXmlConfiguration") + val task = m.invoke(sbt.Keys).asInstanceOf[sbt.TaskKey[sbt.PublishConfiguration]] + List(task) + } catch { + case _: Throwable => // FIXME Too wide + Nil + } + } } diff --git a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala index 9b8892502..29bcb36ea 100644 --- a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala +++ b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala @@ -196,8 +196,6 @@ object CoursierPlugin extends AutoPlugin { withClassifiers = true, sbtClassifiers = true ).value, - makeIvyXmlBefore(needsIvyXmlLocal, shadedConfigOpt), - makeIvyXmlBefore(needsIvyXml, shadedConfigOpt), update := Tasks.updateTask( shadedConfigOpt, withClassifiers = false @@ -280,7 +278,8 @@ object CoursierPlugin extends AutoPlugin { // Tests artifacts from Maven repositories are given this type. // Adding it here so that these work straightaway. classpathTypes += "test-jar" - ) + ) ++ + (needsIvyXml ++ needsIvyXmlLocal).map(makeIvyXmlBefore(_, shadedConfigOpt)) override lazy val buildSettings = super.buildSettings ++ Seq( coursierParallelDownloads := 6, From 07ad16da717c0f16d3795709e6b24b31a0ff4b83 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Fri, 27 Oct 2017 16:23:07 +0200 Subject: [PATCH 2/3] Tweak v1 component handling in cache path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Up to coursier 1.0.0-RC12, setting COURSIER_CACHE=foo makes files land in e.g. foo/https/repo1.maven.org/…. https://github.com/coursier/coursier/pull/676 changed that to foo/v1/https/…. This commit reverts things back to what they were before that. In the long term, it would be better to keep the v1 component there, but I'd prefer not to change that behavior right now. --- paths/src/main/java/coursier/CachePath.java | 2 +- paths/src/main/java/coursier/CoursierPaths.java | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/paths/src/main/java/coursier/CachePath.java b/paths/src/main/java/coursier/CachePath.java index 40f884347..3d47122b6 100644 --- a/paths/src/main/java/coursier/CachePath.java +++ b/paths/src/main/java/coursier/CachePath.java @@ -85,7 +85,7 @@ public class CachePath { } public static File defaultCacheDirectory() { - return new File(CoursierPaths.cacheDirectory(), "v1"); + return CoursierPaths.cacheDirectory(); } private static ConcurrentHashMap processStructureLocks = new ConcurrentHashMap(); diff --git a/paths/src/main/java/coursier/CoursierPaths.java b/paths/src/main/java/coursier/CoursierPaths.java index 2f313cbc1..096cfcf24 100644 --- a/paths/src/main/java/coursier/CoursierPaths.java +++ b/paths/src/main/java/coursier/CoursierPaths.java @@ -30,18 +30,19 @@ public final class CoursierPaths { if (path == null) path = System.getProperty("coursier.cache"); - String xdgPath = coursierDirectories.projectCacheDir; - File xdgDir = new File(xdgPath); + File baseXdgDir = new File(coursierDirectories.projectCacheDir); + File xdgDir = new File(baseXdgDir, "v1"); + String xdgPath = xdgDir.getAbsolutePath(); if (path == null) { - if (xdgDir.isDirectory()) + if (baseXdgDir.isDirectory()) path = xdgPath; } if (path == null) { File coursierDotFile = new File(System.getProperty("user.home") + "/.coursier"); if (coursierDotFile.isDirectory()) - path = System.getProperty("user.home") + "/.coursier/cache/"; + path = System.getProperty("user.home") + "/.coursier/cache/v1/"; } if (path == null) { @@ -49,12 +50,7 @@ public final class CoursierPaths { xdgDir.mkdirs(); } - File coursierCacheDirectory = new File(path).getAbsoluteFile(); - - if (coursierCacheDirectory.getName().equals("v1")) - coursierCacheDirectory = coursierCacheDirectory.getParentFile(); - - return coursierCacheDirectory; + return new File(path).getAbsoluteFile(); } public static File cacheDirectory() { From 50277d91f323d850e24fd3b4f30a00b42f977501 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Fri, 27 Oct 2017 17:10:05 +0200 Subject: [PATCH 3/3] Clean-up --- sbt-shading/src/main/scala/coursier/ShadingPlugin.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala b/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala index 5647c0764..c42b50489 100644 --- a/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala +++ b/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala @@ -34,10 +34,8 @@ object ShadingPlugin extends AutoPlugin { transitive = true ) - // make that a setting? val shadingNamespace = SettingKey[String]("shading-namespace") - // make that a setting? val shadeNamespaces = SettingKey[Set[String]]("shade-namespaces") val toShadeJars = TaskKey[Seq[File]]("to-shade-jars")