Skip to content

Commit

Permalink
Part #1 - add rootProject method. Not complete, this commit shoudl be…
Browse files Browse the repository at this point in the history
… removed.
  • Loading branch information
jsuereth committed Mar 27, 2014
1 parent 9dde1ac commit 2105641
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main/src/main/scala/sbt/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ object Project extends ProjectExtra
val name = c.Expr[String]( Literal(Constant(enclosingValName)) )
reify { Project(name.splice, new File(name.splice)) }
}

def rootProjectMacroImpl(c: Context): c.Expr[Project] =
{
import c.universe._
val enclosingValName = std.KeyMacro.definingValName(c, methodName => s"""$methodName must be directly assigned to a val, such as `val x = $methodName`.""")
val name = c.Expr[String]( Literal(Constant(enclosingValName)) )
reify { Project(name.splice, new File(".")) }
}
}

trait ProjectExtra
Expand Down Expand Up @@ -562,4 +570,7 @@ trait ProjectExtra
/** Creates a new Project. This is a macro that expects to be assigned directly to a val.
* The name of the val is used as the project ID and the name of the base directory of the project. */
def project: Project = macro Project.projectMacroImpl
/** Creates a new Project. This is a macro that expects to be assigned directly to a val.
* The name of the val is used as the project ID and the directory is the base directory. */
def rootProject: Project = macro Project.rootProjectMacroImpl
}

0 comments on commit 2105641

Please sign in to comment.