Permalink
Browse files

closes #28: Add skip-parents option

  • Loading branch information...
1 parent f55aad1 commit f8d0f287b5655bf23f4cadba078968320676b8d0 Heiko Seeberger committed Sep 8, 2011
View
@@ -4,6 +4,7 @@ This project is a plugin for "sbt 0.11.x":http://github.com/harrah/xsbt/ providi
h2. Latest changes
+* #28: Add skip-parents option
* #27: Add info message "This might take some time ..." when command starts
* #24: Switch to sbt 0.11
@@ -15,9 +16,9 @@ h2. Installing sbteclipse as a sbt plugin
* Just add the below lines to your _build.sbt_ file, paying attention to the blank lines:
<pre><code>
-resolvers += Classpaths.typesafeResolver
+resolvers += Classpaths.typesafeSnapshots
-addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.4-RC1")
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.4.0-SNAPSHOT")
</code></pre>
h2. Using sbteclipse to create Eclipse project files
View
@@ -3,7 +3,7 @@ organization := "com.typesafe.sbteclipse"
name := "sbteclipse"
-version := "1.4-SNAPSHOT"
+version := "1.4.0-SNAPSHOT"
sbtPlugin := true
@@ -5,6 +5,7 @@ sbteclipse
v1.4
====
+* #28: Add skip-parents option
* #27: Add info message "This might take some time ..." when command starts
* #24: Switch to sbt 0.11
@@ -29,20 +29,29 @@ object SbtEclipsePlugin extends Plugin {
override def settings = Seq(Keys.commands += eclipseCommand)
- private val (createSrc, sameTargets, skipRoot, withSources) = ("create-src", "same-targets", "skip-root", "with-sources")
+ private val (createSrc, sameTargets, skipParents, skipRoot, withSources) =
+ ("create-src", "same-targets", "skip-parents", "skip-root", "with-sources")
- private val args = (Space ~> createSrc |
- Space ~> sameTargets |
- Space ~> skipRoot |
- Space ~> withSources).*
+ private val parsedArgs = (Space ~> createSrc |
+ Space ~> sameTargets |
+ Space ~> skipParents |
+ Space ~> skipRoot |
+ Space ~> withSources)
- private val eclipseCommand = Command("eclipse")(_ => args) { (state, args) =>
+ private val eclipseCommand = Command("eclipse")(_ => parsedArgs) { (state, args) =>
implicit val implicitState = state
logInfo("About to create an Eclipse project for you.")
logInfo("Please hang on, because it might be necessary to perform an update and this might take some time ...")
- (for (ref <- structure.allProjectRefs if (!(args contains skipRoot) || !isRootProject(ref))) yield {
+ val shouldSkipParents = args contains skipParents
+ val shouldSkipRoot = args contains skipRoot
+
+ (for {
+ ref <- structure.allProjectRefs
+ project <- Project.getProject(ref, structure) // TODO Is it safe to assume that getProject will always return Some?
+ if shouldSkipParents && !isParentProject(project) || shouldSkipRoot && !isRootProject(ref) || !(shouldSkipParents || shouldSkipRoot)
+ } yield {
val projectName = setting(Keys.name, "Missing project name for %s!" format ref.project, ref)
val scalaVersion = setting(Keys.scalaVersion, "Missing Scala version for %s!" format ref.project, ref)
@@ -96,11 +105,8 @@ object SbtEclipsePlugin extends Plugin {
ls map { l => Library(l, bsToSs get l) }
}
}
- val projectDependencies = (Project.getProject(ref, structure) match {
- case None => Seq(("Cannot resolve project for reference %s!" format ref.project).failNel)
- case Some(project) => project.dependencies map { dependency =>
- setting(Keys.name, "Missing project name for %s!" format ref.project, dependency.project)
- }
+ val projectDependencies = (project.dependencies map { dependency =>
+ setting(Keys.name, "Missing project name for %s!" format ref.project, dependency.project)
}).sequence[({type A[B]=Validation[NonEmptyList[String], B]})#A, String]
(projectName |@|
scalaVersion |@|
@@ -45,6 +45,8 @@ package object sbteclipse {
def evaluateTask[A](taskKey: ScopedKey[Task[A]], ref: ProjectRef)(implicit state: State): Option[Result[A]] =
EvaluateTask.evaluateTask(structure, taskKey, state, ref, false, EvaluateTask.SystemProcessors)
+ def isParentProject(project: ResolvedProject): Boolean = !project.aggregate.isEmpty
+
def isRootProject(projectRef: ProjectRef)(implicit state: State): Boolean =
projectRef.project == (extracted rootProject projectRef.build)

0 comments on commit f8d0f28

Please sign in to comment.