diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2016-09-14 14:58:53 +0100 |
---|---|---|
committer | Stefan Zeiger <szeiger@novocode.com> | 2016-09-14 14:58:53 +0100 |
commit | f44bbd8a07f359eb5ffaad84e6d4ce8ebaed6c11 (patch) | |
tree | 5fe473c528a6cb523b933c5d67de168e7dd1e0fb /build.sbt | |
parent | 05016d9035ab9b1c866bd9f12fdd0491f1ea0cbb (diff) | |
download | scala-f44bbd8a07f359eb5ffaad84e6d4ce8ebaed6c11.tar.gz scala-f44bbd8a07f359eb5ffaad84e6d4ce8ebaed6c11.tar.bz2 scala-f44bbd8a07f359eb5ffaad84e6d4ce8ebaed6c11.zip |
Only compare group ID and artifact ID when looking for JLine JAR
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.
Diffstat (limited to 'build.sbt')
-rw-r--r-- | build.sbt | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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))) +} |