mirror of https://github.com/sbt/sbt.git
some cleanup and added trait for sxr to build
This commit is contained in:
parent
3076ca3e4b
commit
5909728299
|
|
@ -6,7 +6,7 @@ import sbt._
|
|||
import java.io.File
|
||||
import java.net.URL
|
||||
|
||||
abstract class SbtProject(info: ProjectInfo) extends DefaultProject(info) with test.SbtScripted with posterous.Publish
|
||||
abstract class SbtProject(info: ProjectInfo) extends DefaultProject(info) with test.SbtScripted with posterous.Publish with Sxr
|
||||
{
|
||||
/* Additional resources to include in the produced jar.*/
|
||||
def extraResources = descendents(info.projectPath / "licenses", "*") +++ "LICENSE" +++ "NOTICE"
|
||||
|
|
@ -46,7 +46,6 @@ abstract class SbtProject(info: ProjectInfo) extends DefaultProject(info) with t
|
|||
|
||||
val testInterface = "org.scala-tools.testing" % "test-interface" % "0.5"
|
||||
|
||||
def deepSources = Path.finder { topologicalSort.flatMap { case p: ScalaPaths => p.mainSources.getFiles } }
|
||||
lazy val sbtDoc = scaladocTask("sbt", deepSources, docPath, docClasspath, documentOptions)
|
||||
|
||||
/* For generating JettyRun for Jetty 6 and 7. The only difference is the imports, but the file has to be compiled against each set of imports. */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
import sbt._
|
||||
|
||||
trait Sxr extends BasicScalaProject
|
||||
{
|
||||
val sxrConf = config("sxr") hide
|
||||
val sxrDep = "org.scala-tools.sxr" %% "sxr" % "0.2.4" % sxrConf.name
|
||||
|
||||
def deepSources: PathFinder
|
||||
def deepBaseDirectories = Path.finder { topologicalSort.flatMap { case p: ScalaPaths => p.mainSourceRoots.getFiles } }
|
||||
def sxrBaseDirs = "-P:sxr:base-directory:" + deepBaseDirectories.absString
|
||||
def sxrLocation = "-Xplugin:" + managedClasspath(sxrConf).absString
|
||||
def sxrDirName = "browse"
|
||||
def sxrOutput = outputPath / (sxrDirName + ".sxr")
|
||||
def sxrClassesOutput = outputPath / sxrDirName // isn't actually written to, since compiler stops before writing classes
|
||||
def sxrOptions = compileOptions.map(_.asString) ++ Seq(sxrBaseDirs, sxrLocation, "-Ystop:superaccessors")
|
||||
|
||||
lazy val sxr = task {
|
||||
xsbt.FileUtilities.delete(sxrOutput +++ sxrClassesOutput getFiles)
|
||||
xsbt.FileUtilities.createDirectory(sxrClassesOutput asFile)
|
||||
val compiler = new xsbt.RawCompiler(buildScalaInstance, true, true, log)
|
||||
// `Set() ++` is temporary. getFiles returns immutable.Set in sbt 0.7.3.
|
||||
compiler(Set() ++ deepSources.getFiles, Set() ++ compileClasspath.getFiles, sxrClassesOutput asFile, sxrOptions)
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@ import Path._
|
|||
import FileUtilities.wrapNull
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import scala.collection.mutable.{Set, HashSet}
|
||||
import scala.collection.{immutable, mutable}
|
||||
import mutable.{Set, HashSet}
|
||||
|
||||
/** A Path represents a file in a project.
|
||||
* @see sbt.PathFinder*/
|
||||
|
|
@ -243,9 +244,9 @@ object Path
|
|||
def fromFiles(files: Iterable[File]): Iterable[Path] = files.map(fromFile)
|
||||
|
||||
// done this way because collection.Set.map returns Iterable that is Set underneath, so no need to create a new set
|
||||
def mapSet[T](files: Iterable[Path])(f: Path => T): scala.collection.immutable.Set[T] =
|
||||
files.map(f) match { case s: scala.collection.immutable.Set[T] => s; case x => scala.collection.immutable.Set() ++ x }
|
||||
def getFiles(files: Iterable[Path]): scala.collection.immutable.Set[File] = mapSet(files)(_.asFile)
|
||||
def mapSet[T](files: Iterable[Path])(f: Path => T): immutable.Set[T] =
|
||||
files.map(f) match { case s: immutable.Set[T] => s; case x => immutable.Set() ++ x }
|
||||
def getFiles(files: Iterable[Path]): immutable.Set[File] = mapSet(files)(_.asFile)
|
||||
def getURLs(files: Iterable[Path]): Array[URL] = files.map(_.asURL).toSeq.toArray
|
||||
}
|
||||
|
||||
|
|
@ -295,10 +296,10 @@ sealed abstract class PathFinder extends NotNull
|
|||
final def filter(f: Path => Boolean): PathFinder = Path.lazyPathFinder(get.filter(f))
|
||||
final def flatMap(f: Path => PathFinder): PathFinder = Path.lazyPathFinder(get.flatMap(p => f(p).get))
|
||||
final def getURLs: Array[URL] = Path.getURLs(get)
|
||||
final def getFiles: scala.collection.immutable.Set[File] = Path.getFiles(get)
|
||||
final def getPaths: scala.collection.immutable.Set[String] = strictMap(_.absolutePath)
|
||||
final def getRelativePaths: scala.collection.immutable.Set[String] = strictMap(_.relativePath)
|
||||
final def strictMap[T](f: Path => T): scala.collection.immutable.Set[T] = Path.mapSet(get)(f)
|
||||
final def getFiles: immutable.Set[File] = Path.getFiles(get)
|
||||
final def getPaths: immutable.Set[String] = strictMap(_.absolutePath)
|
||||
final def getRelativePaths: immutable.Set[String] = strictMap(_.relativePath)
|
||||
final def strictMap[T](f: Path => T): immutable.Set[T] = Path.mapSet(get)(f)
|
||||
private[sbt] def addTo(pathSet: Set[Path])
|
||||
|
||||
final def absString = Path.makeString(get)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ trait SimpleScalaProject extends ExecProject with Cleanable
|
|||
case class CompileOption(val asString: String) extends ActionOption
|
||||
case class JavaCompileOption(val asString: String) extends ActionOption
|
||||
|
||||
def compileOptions(asString: String*): Seq[CompileOption] = asString.map(CompileOption.apply)
|
||||
|
||||
val Deprecation = CompileOption(CompileOptions.Deprecation)
|
||||
val ExplainTypes = CompileOption("-explaintypes")
|
||||
val Optimize = CompileOption("-optimise")
|
||||
|
|
|
|||
Loading…
Reference in New Issue