From f44bbd8a07f359eb5ffaad84e6d4ce8ebaed6c11 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 14 Sep 2016 14:58:53 +0100 Subject: Only compare group ID and artifact ID when looking for JLine JAR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the JLine dependency is resolved through Ivy instead of Maven (which can happen with a local proxy setup in sbt that funnels all artifacts through an Ivy repo), the artifact may have a “configuration” set, which prevents a naive comparison of ModuleIDs from finding it. --- build.sbt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index 1105902a9d..30e3894754 100644 --- a/build.sbt +++ b/build.sbt @@ -463,7 +463,7 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" import collection.JavaConverters._ val inputs: Iterator[JarJar.Entry] = { val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1))) - val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data + val jlineJAR = findJar((dependencyClasspath in Compile).value, jlineDep).get.data val jarFile = new JarFile(jlineJAR) val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry)) def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) } @@ -854,7 +854,7 @@ lazy val dist = (project in file("dist")) val extraJars = (externalDependencyClasspath in Compile).value.map(a => (a.get(moduleID.key), a.data)).collect { case (Some(m), f) if extraModules contains uniqueModule(m) => f } - val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data + val jlineJAR = findJar((dependencyClasspath in Compile).value, jlineDep).get.data val mappings = extraJars.map(f => (f, targetDir / f.getName)) :+ ((jlineJAR, targetDir / "jline.jar")) IO.copy(mappings, overwrite = true) targetDir @@ -1126,3 +1126,9 @@ intellijToSample := { } else s.log.info("Aborting.") } + +/** Find a specific module's JAR in a classpath, comparing only organization and name */ +def findJar(files: Seq[Attributed[File]], dep: ModuleID): Option[Attributed[File]] = { + def extract(m: ModuleID) = (m.organization, m.name) + files.find(_.get(moduleID.key).map(extract _) == Some(extract(dep))) +} -- cgit v1.2.3