Skip to content

Commit

Permalink
closes #89: Duplicate external dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Seeberger committed Feb 3, 2012
1 parent 1f6ab6c commit 57e7500
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Expand Up @@ -211,7 +211,7 @@ private object Eclipse {
def libEntry(buildDirectory: File, baseDirectory: File)(lib: Lib)(implicit state: State) = {
def path(file: File) = {
val relativizedBase =
if (buildDirectory == baseDirectory) Some(".") else IO.relativize(buildDirectory, baseDirectory)
if (buildDirectory === baseDirectory) Some(".") else IO.relativize(buildDirectory, baseDirectory)
val relativizedFile = IO.relativize(buildDirectory, file)
val relativized = (relativizedBase |@| relativizedFile)((base, file) =>
"%s/%s".format(base split FileSepPattern map (part => if (part != ".") ".." else part) mkString FileSep, file)
Expand Down Expand Up @@ -280,19 +280,6 @@ private object Eclipse {
}
}
)
/*
def values(value: String) =
value split "," map (_.trim) filterNot (_ contains "org.scala-lang.plugins/continuations")
options collect {
case SettingFormat(key, value) if key == "Xplugin" && !values(value).isEmpty =>
key -> (values(value) mkString ",")
case SettingFormat(key, value) if key != "Xplugin" =>
key -> (if (!value.isEmpty) value else "true")
} match {
case Nil => Nil
case os => ("scala.compiler.useProjectSettings" -> "true") +: os
}
*/

def externalDependencies(
ref: ProjectRef,
Expand All @@ -309,22 +296,25 @@ private object Eclipse {
} yield moduleReport.module -> file
moduleToFile.toMap
}
def lib(files: Seq[Attributed[File]], binaries: Map[ModuleID, File], sources: Map[ModuleID, File]) = {
def libs(files: Seq[Attributed[File]], binaries: Map[ModuleID, File], sources: Map[ModuleID, File]) = {
val binaryFilesToSourceFiles =
for {
(moduleId, binaryFile) <- binaries
sourceFile <- sources get moduleId
} yield binaryFile -> sourceFile
files.files map { file => Lib(file, binaryFilesToSourceFiles get file) }
val libs = files.files map { file => Lib(file)(binaryFilesToSourceFiles get file) }
libs
}
val libs = evaluateTask(Keys.externalDependencyClasspath in configuration, ref)
val externalDependencyClasspath = evaluateTask(Keys.externalDependencyClasspath in configuration, ref)
val binaryModuleToFile = moduleToFile(Keys.update)
val sourceModuleToFile =
if (withSource)
moduleToFile(Keys.updateClassifiers, (artifact, _) => artifact.classifier == Some("sources"))
moduleToFile(Keys.updateClassifiers, (artifact, _) => artifact.classifier === Some("sources"))
else
Map[ModuleID, File]().success
(libs |@| binaryModuleToFile |@| sourceModuleToFile)(lib)
val externalDependencies = (externalDependencyClasspath |@| binaryModuleToFile |@| sourceModuleToFile)(libs)
logger(state).debug("External dependencies for configuration '%s' and withSource '%s': %s".format(configuration, withSource, externalDependencies))
externalDependencies
}

def projectDependencies(
Expand All @@ -333,10 +323,12 @@ private object Eclipse {
configuration: Configuration)(
implicit state: State) = {
val projectDependencies = project.dependencies collect {
case dependency if dependency.configuration map (_ == configuration) getOrElse true =>
case dependency if dependency.configuration map (_ == configuration) getOrElse true => // TODO Use === instead of ==!
setting(Keys.name in dependency.project)
}
projectDependencies.sequence
val projectDependenciesSeq = projectDependencies.sequence
logger(state).debug("Project dependencies for configuration '%s': %s".format(configuration, projectDependenciesSeq))
projectDependenciesSeq
}

// Getting and transforming optional settings and task results
Expand Down Expand Up @@ -403,4 +395,4 @@ private case class Content(
classpath: Elem,
scalacOptions: Seq[(String, String)])

private case class Lib(binary: File, source: Option[File])
private case class Lib(binary: File)(val source: Option[File])
Expand Up @@ -25,6 +25,7 @@ import sbt.{
Extracted,
EvaluateConfig,
EvaluateTask,
File,
Inc,
Incomplete,
Project,
Expand All @@ -39,11 +40,15 @@ import sbt.{
}
import sbt.Load.BuildStructure
import sbt.complete.Parser
import scalaz.{ NonEmptyList, Validation }
import scalaz.{ Equal, NonEmptyList, Validation }
import scalaz.Scalaz._

package object core {

implicit val fileEqual = new Equal[File] {
def equal(file1: File, file2: File): Boolean = file1 == file2
}

def id[A](a: A): A = a

def boolOpt(key: String): Parser[(String, Boolean)] = {
Expand Down
Expand Up @@ -24,7 +24,9 @@ object Build extends Build {
new File("sub"),
settings = Project.defaultSettings ++ Seq(
libraryDependencies ++= Seq(
"biz.aQute" % "bndlib" % "1.50.0"
"biz.aQute" % "bndlib" % "1.50.0",
"javax.servlet" % "servlet-api" % "2.5",
"javax.servlet" % "servlet-api" % "2.5" % "provided"
),
retrieveManaged := true,
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE16),
Expand Down

0 comments on commit 57e7500

Please sign in to comment.