2014-05-01 18:50:07 +02:00
|
|
|
import sbt._
|
|
|
|
|
import Keys._
|
2015-02-15 04:29:24 +01:00
|
|
|
import StatusPlugin.autoImport._
|
2017-05-08 15:34:41 +02:00
|
|
|
import com.typesafe.sbt.site.SitePlugin.autoImport._
|
|
|
|
|
import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._
|
|
|
|
|
import com.typesafe.sbt.{ SbtGhPages, SbtGit }
|
2014-08-07 18:54:00 +02:00
|
|
|
import SbtGhPages.{ ghpages, GhPagesKeys => ghkeys }
|
|
|
|
|
import SbtGit.{ git, GitKeys }
|
2017-05-08 15:34:41 +02:00
|
|
|
import Sxr.{ sxr, sxrConf }
|
2014-05-01 18:50:07 +02:00
|
|
|
import SiteMap.Entry
|
|
|
|
|
|
|
|
|
|
object Docs {
|
|
|
|
|
val siteExcludes = Set(".buildinfo", "objects.inv")
|
|
|
|
|
def siteInclude(f: File) = !siteExcludes.contains(f.getName)
|
|
|
|
|
|
2017-05-08 15:34:41 +02:00
|
|
|
def settings: Seq[Setting[_]] = Def settings (
|
|
|
|
|
siteSubdirName in SiteScaladoc := "api",
|
|
|
|
|
siteIncludeSxr("sxr"),
|
|
|
|
|
ghPagesSettings
|
|
|
|
|
)
|
2014-05-01 18:50:07 +02:00
|
|
|
|
|
|
|
|
def ghPagesSettings = ghpages.settings ++ Seq(
|
|
|
|
|
git.remoteRepo := "git@github.com:sbt/sbt.github.com.git",
|
|
|
|
|
localRepoDirectory,
|
2017-03-29 15:43:38 +02:00
|
|
|
ghkeys.synchLocal := synchLocalImpl.value,
|
2014-05-01 18:50:07 +02:00
|
|
|
GitKeys.gitBranch in ghkeys.updatedRepository := Some("master")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def localRepoDirectory = ghkeys.repository := {
|
2017-04-21 09:14:31 +02:00
|
|
|
// distinguish between building to update the site or not so that CI jobs
|
2014-05-01 18:50:07 +02:00
|
|
|
// that don't commit+publish don't leave uncommitted changes in the working directory
|
2014-08-07 18:54:00 +02:00
|
|
|
val status = if (isSnapshot.value) "snapshot" else "public"
|
2014-05-01 18:50:07 +02:00
|
|
|
Path.userHome / ".sbt" / "ghpages" / status / organization.value / name.value
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 15:34:41 +02:00
|
|
|
def siteIncludeSxr(prefix: String) = Def settings (
|
|
|
|
|
mappings in sxr := Path.allSubpaths(sxr.value).toSeq,
|
|
|
|
|
siteSubdirName in sxrConf := prefix,
|
|
|
|
|
addMappingsToSiteDir(mappings in sxr, siteSubdirName in sxrConf)
|
|
|
|
|
)
|
2014-05-01 18:50:07 +02:00
|
|
|
|
2017-03-29 15:43:38 +02:00
|
|
|
def synchLocalImpl = Def task {
|
2017-04-21 09:14:31 +02:00
|
|
|
val repo = ghkeys.updatedRepository.value
|
|
|
|
|
val versioned = repo / version.value
|
|
|
|
|
IO.delete(versioned / "sxr")
|
|
|
|
|
IO.delete(versioned / "api")
|
|
|
|
|
val mappings = ghkeys.privateMappings.value
|
|
|
|
|
val toCopy = for ((file, target) <- mappings if siteInclude(file))
|
|
|
|
|
yield (file, versioned / target)
|
|
|
|
|
IO.copy(toCopy)
|
|
|
|
|
repo
|
2014-05-01 18:50:07 +02:00
|
|
|
}
|
2012-10-16 21:01:58 +02:00
|
|
|
}
|