Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

closes #89: Duplicate external dependencies

  • Loading branch information...
commit 57e750007bbc1a628f3139f494d2bb1ee7919bf9 1 parent 1f6ab6c
Heiko Seeberger authored
View
36 sbteclipse-core/src/main/scala/com/typesafe/sbteclipse/core/Eclipse.scala
@@ -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)
@@ -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,
@@ -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(
@@ -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
@@ -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])
View
7 sbteclipse-core/src/main/scala/com/typesafe/sbteclipse/core/package.scala
@@ -25,6 +25,7 @@ import sbt.{
Extracted,
EvaluateConfig,
EvaluateTask,
+ File,
Inc,
Incomplete,
Project,
@@ -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)] = {
View
4 sbteclipse-plugin/src/sbt-test/sbteclipse/02-contents/project/Build.scala
@@ -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),
Please sign in to comment.
Something went wrong with that request. Please try again.