Skip to content

Commit

Permalink
Merge pull request #5399 from szeiger/wip/ignore-jline-configs
Browse files Browse the repository at this point in the history
Only compare group ID and artifact ID when looking for JLine JAR
  • Loading branch information
szeiger committed Sep 21, 2016
2 parents 05016d9 + f44bbd8 commit 63f5eb5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)))
}

0 comments on commit 63f5eb5

Please sign in to comment.