Skip to content

Commit

Permalink
modern sbt 1.8.0 (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru authored Dec 19, 2022
1 parent 5b10e54 commit 24d13db
Show file tree
Hide file tree
Showing 29 changed files with 70 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
include:
- { sbtCrossVersion: "1.1.6", jvmName: "temurin:1.8.0" }
- { sbtCrossVersion: "1.4.9", jvmName: "temurin:1.8.0" }
# { jvmName: "temurin:1.11.0" }
# { jvmName: "temurin:1.17.0" }
steps:
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ organizationHomepage := Some(url("https://www.scala-sbt.org/"))

homepage := Some(url("https://www.scala-sbt.org/sbt-site/"))

crossSbtVersions := List("1.1.6")
crossSbtVersions := List("1.4.9")

licenses += ("BSD 3-Clause", url("https://opensource.org/licenses/BSD-3-Clause"))
//#scm-info
Expand All @@ -18,7 +18,7 @@ scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-site"), "scm:git:git@git

scalacOptions ++= Seq("-deprecation", "-unchecked")

resolvers += Resolver.sonatypeRepo("releases")
resolvers ++= Resolver.sonatypeOssRepos("releases")

val unfilteredVersion = "0.9.1"

Expand All @@ -39,8 +39,8 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.5.5")
libraryDependencies +=
Defaults.sbtPluginExtra(
"org.planet42" % "laika-sbt" % "0.8.0",
(sbtBinaryVersion in pluginCrossBuild).value,
(scalaBinaryVersion in pluginCrossBuild).value
(pluginCrossBuild / sbtBinaryVersion).value,
(pluginCrossBuild / scalaBinaryVersion).value
)

enablePlugins(ParadoxSitePlugin, ParadoxMaterialThemePlugin)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.8.0
1 change: 1 addition & 0 deletions src/main/paradox/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Before upgrading please consult the @github:[release notes](/notes/). Instructio

@@@ note

* Version 1.5+ is published for sbt >= 1.4.9.
* Version 1.4+ is published for sbt 1.2.x.
* Version 1.3+ is cross published to both sbt 0.13 and sbt 1.x.
* As of sbt-site version 1.x.x, sbt version 0.13.10+ or 1.0.0-RC2+ is supported.
Expand Down
2 changes: 1 addition & 1 deletion src/main/paradox/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Therefore when upgrading remove the `Paradox` configuration scope from all of th
Note that sbt-site setting `siteSubdirName` is still configured under the `Paradox` configuration scope.

The default Paradox source directory has been changed to match the one defined in the `sbt-paradox`, which is `src/main/paradox`.
To keep the previous default, add the following to the build: `sourceDirectory in paradox := sourceDirectory.value`
To keep the previous default, add the following to the build: `paradox / sourceDirectory := sourceDirectory.value`

<a id="from-version-0.x.x-to-1.x.x" />
## Migrating from version 0.x.x to 1.x.x
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/typesafe/sbt/SbtSite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sbt.Keys
/** Shim for backwards compatibility in `sbt-ghpages`*/
object SbtSite {
object SiteKeys {
@deprecated("Please upgrade to AutoPlugin and use `mappings in makeSite`", "1.0")
val siteMappings = Keys.mappings in SitePlugin.autoImport.makeSite
@deprecated("Please upgrade to AutoPlugin and use `makeSite / mappings`", "1.0")
val siteMappings = SitePlugin.autoImport.makeSite / Keys.mappings
}
}
6 changes: 3 additions & 3 deletions src/main/scala/com/typesafe/sbt/site/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ object Compat {
def watchSettings(scope: Scope): Seq[Setting[_]] =
Seq(
ConfigGlobal / watchSources += new Source(
base = (sourceDirectory in scope).value,
includeFilter = (includeFilter in scope).value,
excludeFilter = (excludeFilter in scope).value
base = (scope / sourceDirectory).value,
includeFilter = (scope / includeFilter).value,
excludeFilter = (scope / excludeFilter).value
)
)

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/com/typesafe/sbt/site/SiteKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ trait SiteKeys {
val packageSite = TaskKey[File]("package-site", "Create a zip file of the website.")
val siteSubdirName = SettingKey[String]("siteSubdirName",
"Name of subdirectory in site target directory to put generator plugin content. Defaults to empty string.")
val siteMappings = mappings in makeSite
val siteDirectory = target in makeSite
val siteSources = sources in makeSite
val siteSourceDirectory = sourceDirectory in makeSite
val siteMappings = makeSite / mappings
val siteDirectory = makeSite / target
val siteSources = makeSite / sources
val siteSourceDirectory = makeSite / sourceDirectory
}
12 changes: 6 additions & 6 deletions src/main/scala/com/typesafe/sbt/site/SitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sbt._
object SitePlugin extends AutoPlugin {
override def trigger = allRequirements
object autoImport extends SiteKeys {
def publishSite(): SettingsDefinition = addArtifact(artifact in packageSite, packageSite)
def publishSite(): SettingsDefinition = addArtifact(packageSite / artifact, packageSite)
val addMappingsToSiteDir = com.typesafe.sbt.site.util.SiteHelpers.addMappingsToSiteDir _
}
import autoImport._
Expand All @@ -18,11 +18,11 @@ object SitePlugin extends AutoPlugin {
siteMappings := (siteMappings ?? Seq.empty).value,
siteDirectory := target.value / "site",
siteSourceDirectory := sourceDirectory.value / "site",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf",
siteMappings ++= SiteHelpers.selectSubpaths(siteSourceDirectory.value, (includeFilter in makeSite).value),
makeSite / includeFilter := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf",
siteMappings ++= SiteHelpers.selectSubpaths(siteSourceDirectory.value, (makeSite / includeFilter).value),
makeSite := SiteHelpers.copySite(siteDirectory.value, streams.value.cacheDirectory, siteMappings.value),
artifact in packageSite := SiteHelpers.siteArtifact(moduleName.value),
artifactPath in packageSite := Defaults.artifactPathSetting(artifact in packageSite).value,
packageSite := SiteHelpers.createSiteZip(makeSite.value, (artifactPath in packageSite).value, streams.value)
packageSite / artifact := SiteHelpers.siteArtifact(moduleName.value),
packageSite / artifactPath := Defaults.artifactPathSetting(packageSite / artifact).value,
packageSite := SiteHelpers.createSiteZip(makeSite.value, (packageSite / artifactPath).value, streams.value)
)
}
10 changes: 5 additions & 5 deletions src/main/scala/com/typesafe/sbt/site/SitePreviewPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ object SitePreviewPlugin extends AutoPlugin {
object autoImport {
val previewSite = TaskKey[Unit]("previewSite", "Launches a jetty server that serves your generated site from the target directory")
val previewAuto = TaskKey[Unit]("previewAuto", "Launches an automatic jetty server that serves your generated site from the target directory")
val previewFixedPort = SettingKey[Option[Int]]("previewFixedPort") in previewSite
val previewLaunchBrowser = SettingKey[Boolean]("previewLaunchBrowser") in previewSite
val previewPath = SettingKey[String]("previewPath", "path to open on `previewSite` and `previewAuto`") in previewSite
val previewFixedPort = previewSite / SettingKey[Option[Int]]("previewFixedPort")
val previewLaunchBrowser = previewSite / SettingKey[Boolean]("previewLaunchBrowser")
val previewPath = previewSite / SettingKey[String]("previewPath", "path to open on `previewSite` and `previewAuto`")
}

import SitePlugin.autoImport._
Expand Down Expand Up @@ -44,15 +44,15 @@ object SitePreviewPlugin extends AutoPlugin {
val browser = previewLaunchBrowser.value
val path = previewPath.value

Preview(port, (target in previewAuto).value, (thisProjectRef.value / makeSite), Compat.genSources, state.value).run { server =>
Preview(port, (previewAuto / target).value, (thisProjectRef.value / makeSite), Compat.genSources, state.value).run { server =>
if (browser)
Browser.open(server.portBindings.head.url + "/" + path)
}
},
previewFixedPort := Some(4000),
previewLaunchBrowser := true,
previewPath := "",
target in previewAuto := siteDirectory.value
previewAuto / target := siteDirectory.value
)

def createServer(siteTarget: File, port: Int) =
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/typesafe/sbt/site/SiteScaladocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object SiteScaladocPlugin extends AutoPlugin {

def scaladocSettings(
config: Configuration,
scaladocMappings: TaskKey[Seq[(File, String)]] = (mappings in (Compile, packageDoc)),
scaladocMappings: TaskKey[Seq[(File, String)]] = Compile / packageDoc / mappings,
scaladocDir: String = "latest/api"
): Seq[Setting[_]] =
inConfig(config)(
Expand All @@ -27,5 +27,5 @@ object SiteScaladocPlugin extends AutoPlugin {
mappings := scaladocMappings.value
)
) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object AsciidoctorPlugin extends AutoPlugin {
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run asciidoctor in new ClassLoader. */
private[sbt] def generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object GitBookPlugin extends AutoPlugin {
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run gitbook commands. */
private[sbt] def generate(src: File, target: File, inc: FileFilter, exc: FileFilter, installDir: Option[File], s: TaskStreams): Seq[(File, String)] = {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/typesafe/sbt/site/hugo/HugoPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object HugoPlugin extends AutoPlugin {
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run hugo via fork. */
private[sbt] def generate(
Expand Down Expand Up @@ -74,4 +74,4 @@ object HugoPlugin extends AutoPlugin {
} yield ()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object JekyllPlugin extends AutoPlugin {
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run jekyll via fork. TODO - Add command line args and the like. */
private[sbt] def generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ object LaikaSitePlugin extends AutoPlugin {
inConfig(config)(
Def.settings(
LaikaPlugin.projectSettings,
target in laikaSite := target.value,
laikaSite / target := target.value,
includeFilter := AllPassFilter,
excludeFilter := HiddenFileFilter,
mappings := {
generate(laikaSite.value, includeFilter.value, excludeFilter.value)
},
siteSubdirName := "",
sourceDirectories in Laika := Seq(sourceDirectory.value)
Laika / sourceDirectories := Seq(sourceDirectory.value)
)
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

private def generate(target: File, inc: FileFilter, exc: FileFilter): Seq[(File, String)] = {
// Figure out what was generated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object NanocPlugin extends AutoPlugin {
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run nanoc via fork. TODO - Add command line args and the like. */
private[sbt] def generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ object PamfletPlugin extends AutoPlugin {
inConfig(config)(
Seq(
includeFilter := AllPassFilter,
pamfletFencePlugins := (pamfletFencePlugins in config).?.value.getOrElse(Nil),
pamfletFencePlugins := (config / pamfletFencePlugins).?.value.getOrElse(Nil),
mappings := generate(sourceDirectory.value, target.value, includeFilter.value, pamfletFencePlugins.value),
siteSubdirName := ""
)
) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/** Run pamflet in sbt's JVM. */
private[sbt] def generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ object ParadoxSitePlugin extends AutoPlugin {
def paradoxSettings(config: Configuration): Seq[Setting[_]] = {
val siteNameConfig = if (config == Compile) Paradox else config
List(
siteSubdirName in siteNameConfig := ""
siteNameConfig / siteSubdirName := ""
) ++
SiteHelpers.watchSettings(ThisScope.in(config, paradox.key)) ++
SiteHelpers.addMappingsToSiteDir((paradox in config).map(SiteHelpers.selectSubpaths(_, AllPassFilter)), siteSubdirName in siteNameConfig)
SiteHelpers.addMappingsToSiteDir((config / paradox).map(SiteHelpers.selectSubpaths(_, AllPassFilter)), siteNameConfig / siteSubdirName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object PreprocessPlugin extends AutoPlugin {
,
preprocessVars := Map("VERSION" -> version.value),
preprocessRules := Seq.empty,
includeFilter in Preprocess := AllPassFilter,
Preprocess / includeFilter := AllPassFilter,
sourceDirectory := sourceDirectory.value / "site-preprocess",
target := target.value / Preprocess.name,
preprocess := simplePreprocess(
Expand All @@ -47,7 +47,7 @@ object PreprocessPlugin extends AutoPlugin {
)
) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

/**
* Simple preprocessing of all files in a directory using `@variable@` replacements.
Expand Down
26 changes: 13 additions & 13 deletions src/main/scala/com/typesafe/sbt/site/sphinx/SphinxPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ object SphinxPlugin extends AutoPlugin {
sphinxProperties := Map.empty,
sphinxEnv := Map.empty,
sphinxIncremental := false,
includeFilter in generate := AllPassFilter,
excludeFilter in generate := HiddenFileFilter,
generate / includeFilter := AllPassFilter,
generate / excludeFilter := HiddenFileFilter,
sphinxInputs := combineSphinxInputs.value,
sphinxRunner := SphinxRunner(),
installPackages := installPackagesTask.value,
enableOutput in generateHtml := true,
enableOutput in generatePdf := false,
enableOutput in generateEpub := false,
generateHtml / enableOutput := true,
generatePdf / enableOutput := false,
generateEpub / enableOutput := false,
generateHtml := generateHtmlTask.value,
generatePdf := generatePdfTask.value,
generateEpub := generateEpubTask.value,
generatedHtml := ifEnabled(generateHtml).value,
generatedPdf := seqIfEnabled(generatePdf).value,
generatedEpub := ifEnabled(generateEpub).value,
generate := generateTask.value,
includeFilter in Sphinx := AllPassFilter,
Sphinx / includeFilter := AllPassFilter,
mappings := mappingsTask.value,
version := SiteHelpers.shortVersion(version.value),
sphinxEnv := defaultEnvTask.value,
Expand All @@ -50,16 +50,16 @@ object SphinxPlugin extends AutoPlugin {
propertiesSettings(config) ++
SiteHelpers.directorySettings(config) ++
SiteHelpers.watchSettings(config) ++
SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
SiteHelpers.addMappingsToSiteDir(config / mappings, config / siteSubdirName)

def defaultEnvTask = installPackages map {
pkgs => Map("PYTHONPATH" -> Path.makeString(pkgs))
}

// For now, we default to passing the version in as a property.
def propertiesSettings(config: Configuration) = Seq(
sphinxProperties in config ++= Map(
"version" (version in config).value,
config / sphinxProperties ++= Map(
"version" (config / version).value,
"release" version.value
)
)
Expand All @@ -75,8 +75,8 @@ object SphinxPlugin extends AutoPlugin {
def combineSphinxInputs = Def.task {
SphinxInputs(
sourceDirectory.value,
(includeFilter in generate).value,
(excludeFilter in generate).value,
(generate / includeFilter).value,
(generate / excludeFilter).value,
sphinxIncremental.value,
sphinxTags.value,
sphinxProperties.value,
Expand Down Expand Up @@ -118,7 +118,7 @@ object SphinxPlugin extends AutoPlugin {
f: Task[S] => Task[T],
nil: T): Def.Initialize[Task[T]] = Def.task{
val t = key.taskValue
if ((enableOutput in key in key.scope).value) f(t) else task {nil}
if ((key.scope / key / enableOutput).value) f(t) else task {nil}
}.flatMap(identity(_))

def generateTask = Def.task {
Expand All @@ -137,7 +137,7 @@ object SphinxPlugin extends AutoPlugin {
(epub ** "*.epub").get pair Path.rebase(epub, t)
}
val mapping = htmlMapping ++ pdfMapping ++ epubMapping
Sync(CacheStore(cache))(mapping)
Sync.sync(CacheStore(cache))(mapping)
s.log.info("Sphinx documentation generated: %s" format t)
t
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/typesafe/sbt/site/util/SiteHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ object SiteHelpers {

def copySite(dir: File, cacheDir: File, maps: Seq[(File, String)]): File = {
val concrete = maps map { case (file, dest) => (file, dir / dest) }
Sync(CacheStore(cacheDir / "make-site"))(concrete)
Sync.sync(CacheStore(cacheDir / "make-site"))(concrete)
dir
}

def siteArtifact(name: String) = Artifact(name, Artifact.DocType, "zip", "site")

def createSiteZip(siteDir: File, zipPath: File, s: TaskStreams): File = {
IO.zip(Path.allSubpaths(siteDir), zipPath)
IO.zip(Path.allSubpaths(siteDir), zipPath, Some(System.currentTimeMillis()))
s.log.info("Site packaged: " + zipPath)
zipPath
}
Expand Down
Loading

0 comments on commit 24d13db

Please sign in to comment.