Skip to content
Browse files

closes #49: Add unmanaged library dependencies

  • Loading branch information...
1 parent faadd52 commit 8e3e7b34105823087f26d939898f6d5c6091f4cd Heiko Seeberger committed
View
11 README.textile
@@ -4,13 +4,10 @@ This project is a plugin for "sbt 0.11.x":http://github.com/harrah/xsbt/ providi
h2. Latest changes
-* #46: Add managed source directories
-* #44: Dependency on scala compiler should be treated in special way
-* #37: Use workspace default JRE
-* #31: Reference to scalaVersion is ambiguous
-* #28: Add skip-parents option
-* #27: Add info message "This might take some time ..." when command starts
-* #24: Switch to sbt 0.11
+#31: Reference to scalaVersion is ambiguous
+#28: Add skip-parents option
+#27: Add info message "This might take some time ..." when command starts
+#24: Switch to sbt 0.11
h2. Installing sbteclipse as a sbt plugin
View
1 src/main/resources/RELEASE-NOTES.txt
@@ -5,6 +5,7 @@ sbteclipse
v1.5
====
+#49: Add unmanaged library dependencies
#46: Add managed source directories
#44: Dependency on scala compiler should be treated in special way
#37: Use workspace default JRE (contribution of Jarod Liu <liuyuanzhi@gmail.com>)
View
25 src/main/scala/com/typesafe/sbteclipse/SbtEclipsePlugin.scala
@@ -116,21 +116,35 @@ private object SbtEclipse {
setting(Keys.classDirectory, "Missing test class directory for %s!" format ref.project, ref, Configurations.Test))(Directories)
def libraries(ref: ProjectRef, withSources: Boolean)(implicit state: State): ValidationNELString[Iterable[Library]] = {
- (libraryBinaries(ref) |@| librarySources(ref, withSources)) { (binaries, sources) =>
- binaries map { case (moduleId, binaryFile) => Library(binaryFile, sources get moduleId) }
+ (libraryFiles(ref) |@| libraryBinaries(ref) |@| librarySources(ref, withSources)) { (files, binaries, sources) =>
+ val binaryFilesToSourceFiles =
+ for {
+ (moduleId, binaryFile) <- binaries
+ sourceFile <- sources get moduleId
+ } yield binaryFile -> sourceFile
+ files map { file => Library(file, binaryFilesToSourceFiles get file) }
}
}
+ def libraryFiles(ref: ProjectRef)(implicit state: State): ValidationNELString[Seq[File]] =
+ evaluateTask(Keys.externalDependencyClasspath in Configurations.Test, ref) match {
+ case Some(Value(attributedLibs)) =>
+ (attributedLibs.files collect {
+ case file if !(file.getAbsolutePath contains "scala-library.jar") => file
+ }).success
+ case _ => ("Error running externalDependencyClasspath task for %s" format ref.project).failNel
+ }
+
def libraryBinaries(ref: ProjectRef)(implicit state: State): ValidationNELString[Map[ModuleID, File]] =
- modules(ref, Keys.update, (_, file) => !(file.getName endsWith "scala-library.jar"))
+ modules(ref, Keys.update)
def librarySources(ref: ProjectRef, withSources: Boolean)(implicit state: State): ValidationNELString[Map[ModuleID, File]] =
if (withSources)
- modules(ref, Keys.updateClassifiers, (artifact, file) => !(file.getName endsWith "scala-library.jar") && artifact.classifier == Some("sources"))
+ modules(ref, Keys.updateClassifiers, (artifact, _) => artifact.classifier == Some("sources"))
else
Map.empty.success
- def modules(ref: ProjectRef, key: TaskKey[UpdateReport], p: (Artifact, File) => Boolean)(implicit state: State): ValidationNELString[Map[ModuleID, File]] =
+ def modules(ref: ProjectRef, key: TaskKey[UpdateReport], p: (Artifact, File) => Boolean = (_, _) => true)(implicit state: State): ValidationNELString[Map[ModuleID, File]] =
evaluateTask(key in Configurations.Test, ref) match {
case Some(Value(updateReport)) =>
(for {
@@ -249,6 +263,7 @@ private object SbtEclipse {
}
private object Path {
+
def unapply(file: File): Option[String] =
Some(file.getAbsolutePath)
}
View
BIN src/sbt-test/sbteclipse/default/lib/bndlib-1.43.0.jar
Binary file not shown.
View
2 src/sbt-test/sbteclipse/default/project/Build.scala
@@ -76,6 +76,8 @@ object Build extends Build {
}
// root
verifyCommonEntries(classpathXml(root))
+ assertContains(classpathXml(root),
+ <classpathentry path={ file(".").getCanonicalPath + "/lib/bndlib-1.43.0.jar" } kind="lib"/>)
// sub1
verifyCommonEntries(classpathXml(sub1))
assertContains(classpathXml(sub1),

0 comments on commit 8e3e7b3

Please sign in to comment.
Something went wrong with that request. Please try again.