mirror of https://github.com/sbt/sbt.git
first step at integrating documentation into build
This commit is contained in:
parent
2ef0fcae6a
commit
369655391f
|
|
@ -0,0 +1,49 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Status.{isSnapshot, publishStatus}
|
||||
import com.jsuereth.sbtsite.{SitePlugin, SiteKeys}
|
||||
import SitePlugin.site
|
||||
import SiteKeys.{makeSite,siteMappings}
|
||||
import Sxr.sxr
|
||||
|
||||
object Docs
|
||||
{
|
||||
def settings: Seq[Setting[_]] =
|
||||
site.settings ++
|
||||
site.sphinxSupport("manual") ++
|
||||
site.jekyllSupport() ++
|
||||
site.includeScaladoc("api") ++
|
||||
siteIncludeSxr ++
|
||||
sitePrefixVersion
|
||||
|
||||
def siteIncludeSxr = Seq(
|
||||
mappings in sxr <<= sxr.map(dir => Path.allSubpaths(dir).toSeq),
|
||||
site.addMappingsToSiteDir(mappings in sxr, "sxr")
|
||||
)
|
||||
|
||||
def sitePrefixVersion =
|
||||
siteMappings <<= (siteMappings, version) map { (ms, v) =>
|
||||
ms.map { case (src, path) => (src, v + "/" + path) }
|
||||
}
|
||||
|
||||
def siteLinkLatest =
|
||||
makeSite <<= (makeSite, version, streams, isSnapshot) map { (dir, v, s, snap) =>
|
||||
linkSite(dir, v, if(snap) "snapshot" else "stable", s.log)
|
||||
dir
|
||||
}
|
||||
|
||||
def linkSite(base: File, to: String, from: String, log: Logger) {
|
||||
val current = base / to
|
||||
assert(current.isDirectory, "Versioned site not present at " + current.getAbsolutePath)
|
||||
val symlinkFile = base / from
|
||||
symlinkFile.delete()
|
||||
symlink(to = current, from = symlinkFile, log = log)
|
||||
}
|
||||
|
||||
// TODO: platform independence/use symlink from Java 7
|
||||
def symlink(to: File, from: File, log: Logger): Unit =
|
||||
"ln" :: "-s" :: to.getAbsolutePath :: from.getAbsolutePath :: Nil ! log match {
|
||||
case 0 => ()
|
||||
case code => error("Could not create symbolic link from " + from + " to " + " to.")
|
||||
}
|
||||
}
|
||||
|
|
@ -14,16 +14,8 @@ object Release extends Build
|
|||
lazy val fullRelease = TaskKey[Unit]("full-release")
|
||||
lazy val prerelease = TaskKey[Unit]("prerelease")
|
||||
|
||||
lazy val wikiRepository = SettingKey[File]("wiki-repository")
|
||||
lazy val pagesRepository = SettingKey[File]("pages-repository")
|
||||
lazy val updatedPagesRepository = TaskKey[File]("updated-pages-repository")
|
||||
lazy val updatedWikiRepository = TaskKey[File]("updated-wiki-repository")
|
||||
lazy val copyAPIDoc = TaskKey[File]("copy-api-doc")
|
||||
lazy val pushAPIDoc = TaskKey[Unit]("push-api-doc")
|
||||
lazy val pushWiki = TaskKey[Unit]("push-wiki")
|
||||
lazy val pushMain = TaskKey[Unit]("push-main")
|
||||
lazy val sbtRemoteRepo = SettingKey[String]("sbt-remote-repo")
|
||||
lazy val wikiRemoteRepo = SettingKey[String]("wiki-remote-repo")
|
||||
|
||||
def settings(nonRoots: => Seq[ProjectReference], launcher: ScopedTask[File]): Seq[Setting[_]] =
|
||||
(if(CredentialsFile.exists) releaseSettings(nonRoots, launcher) else Nil) ++
|
||||
|
|
@ -40,16 +32,9 @@ object Release extends Build
|
|||
launcherRemotePath <<= (organization, version) { (org, v) => List(org, LaunchJarName, v, LaunchJarName + ".jar").mkString("/") }
|
||||
)
|
||||
def fullReleaseSettings: Seq[Setting[_]] = Seq(
|
||||
pushAPIDoc <<= pushAPIDoc0,
|
||||
copyAPIDoc <<= copyAPIDoc0,
|
||||
pushWiki <<= pushWiki0,
|
||||
pushMain <<= pushMain0,
|
||||
prerelease := println(Prerelease),
|
||||
fullRelease <<= fullRelease0,
|
||||
sbtRemoteRepo := "git@github.com:harrah/xsbt.git",
|
||||
wikiRemoteRepo := "git@github.com:harrah/xsbt.wiki.git",
|
||||
updatedPagesRepository <<= updatedRepo(pagesRepository, sbtRemoteRepo, Some("gh-pages")),
|
||||
updatedWikiRepository <<= updatedRepo(wikiRepository, wikiRemoteRepo, None)
|
||||
fullRelease <<= fullRelease0
|
||||
)
|
||||
def deployLauncher(launcher: ScopedTask[File]) =
|
||||
(launcher, launcherRemotePath, credentials, remoteBase, streams) map { (launchJar, remotePath, creds, base, s) =>
|
||||
|
|
@ -71,16 +56,8 @@ object Release extends Build
|
|||
def updatedRepo(repo: SettingKey[File], remote: SettingKey[String], branch: Option[String]) =
|
||||
(repo, remote, streams) map { (local, uri, s) => updated(remote = uri, cwd = local, branch = branch, log = s.log); local }
|
||||
|
||||
def copyAPIDoc0 = (updatedPagesRepository, doc, Sxr.sxr, streams) map { (repo, newAPI, newSXR, s) =>
|
||||
git("rm", "-r", "latest")(repo, s.log)
|
||||
IO.copyDirectory(newAPI, repo / "latest" / "api")
|
||||
IO.copyDirectory(newSXR, repo / "latest" / "sxr")
|
||||
repo
|
||||
}
|
||||
def fullRelease0 = Seq(pushWiki, pushMain, pushAPIDoc, publishRelease).dependOn
|
||||
def fullRelease0 = Seq(pushMain, publishRelease).dependOn
|
||||
def pushMain0 = (baseDirectory, version, streams) map { (repo, v, s) => commitAndPush(v, tag = Some("v" + v))(repo, s.log) }
|
||||
def pushWiki0 = (wikiRepository, streams) map { (repo, s) => commitAndPush("updated for release")(repo, s.log) }
|
||||
def pushAPIDoc0 = (copyAPIDoc, streams) map { (repo, s) => commitAndPush("updated api and sxr documentation")(repo, s.log) }
|
||||
def commitAndPush(msg: String, tag: Option[String] = None)(repo: File, log: Logger)
|
||||
{
|
||||
git("add", ".")(repo, log)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,9 @@ object Sbt extends Build
|
|||
|
||||
import Sxr.sxr
|
||||
def releaseSettings = Release.settings(nonRoots, proguard in Proguard)
|
||||
def rootSettings = releaseSettings ++ LaunchProguard.settings ++ LaunchProguard.specific(launchSub) ++ Sxr.settings ++ docSetting ++ Util.publishPomSettings ++ Seq(
|
||||
def rootSettings = releaseSettings ++ Docs.settings ++ LaunchProguard.settings ++ LaunchProguard.specific(launchSub) ++
|
||||
Sxr.settings ++ docSetting ++ Util.publishPomSettings ++ otherRootSettings
|
||||
def otherRootSettings = Seq(
|
||||
scriptedScalaVersion <<= scalaVersion.identity,
|
||||
scripted <<= scriptedTask,
|
||||
scriptedSource <<= (sourceDirectory in sbtSub) / "sbt-test",
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.8"
|
||||
libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.8"
|
||||
|
||||
addSbtPlugin("com.jsuereth" % "sbt-site-plugin" % "0.5.0")
|
||||
Loading…
Reference in New Issue