Skip to content

Commit

Permalink
Total makeover: split into modules per generator (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru authored Jan 11, 2023
1 parent 09daa23 commit 5ebc21d
Show file tree
Hide file tree
Showing 221 changed files with 301 additions and 324 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 @@ -64,4 +64,4 @@ jobs:
# chmod +x ${PWD}/bin/hugo

- name: sbt runScriptedTest
run: sbt ";^^${{ matrix.sbtCrossVersion }}; compile; runScriptedTest; makeSite"
run: sbt ";^^${{ matrix.sbtCrossVersion }}; test; scripted; makeSite"
57 changes: 29 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
release:
name: Release to Sonatype
if: github.repository == 'sbt/sbt-site'
if: github.event.repository.fork == false
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -35,30 +35,31 @@ jobs:
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

documentation:
name: Release Documentation
if: github.repository == 'sbt/sbt-site'
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Cache Coursier cache
uses: coursier/[email protected]

- name: Set up JDK 11
uses: coursier/[email protected]
with:
jvm: temurin:1.11.0.17

- name: sbt ghpages
run: |-
git config --global user.name "sbt-site bot"
git config --global user.email "[email protected]"
sbt ghpagesPushSite
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/sbt/sbt-site/issues/200
# documentation:
# name: Release Documentation
# if: github.event.repository.fork == false
# runs-on: ubuntu-22.04
# permissions:
# contents: write
# steps:
# - name: Checkout
# uses: actions/[email protected]
# with:
# fetch-depth: 0
#
# - name: Cache Coursier cache
# uses: coursier/[email protected]
#
# - name: Set up JDK 11
# uses: coursier/[email protected]
# with:
# jvm: temurin:1.11.0.17
#
# - name: sbt ghpages
# run: |-
# git config --global user.name "sbt-site bot"
# git config --global user.email "[email protected]"
# sbt ghpagesPushSite
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# sbt-site

This sbt plugin generates project websites from static content, [Jekyll], [Sphinx], [Pamflet], [Nanoc], [GitBook], [Paradox], [Hugo], [Laika] and/or [Asciidoctor], and can optionally include generated Scaladoc. It is designed to work hand-in-hand with publishing plugins like [sbt-ghpages].
This sbt plugin generates project websites from static content, [GitBook], [Paradox], and/or [Asciidoctor], and can optionally include generated Scaladoc. It is designed to work hand-in-hand with publishing plugins like [sbt-ghpages].

For version 1.5.0 we removed the integrations with [Jekyll], [Sphinx], [Pamflet], [Nanoc], [Hugo], and [Laika] as they require updates. Please see the ["revive" issues](https://github.com/sbt/sbt-site/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+revive).

## Documentation

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-asciidoctor" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := "test"

//#enablePlugin
enablePlugins(AsciidoctorPlugin)
enablePlugins(SitePreviewPlugin, AsciidoctorPlugin)
//#enablePlugin

//#siteSubdirName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-asciidoctor" % sys.props("project.version"))
232 changes: 135 additions & 97 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,110 +1,148 @@
sbtPlugin := true
enablePlugins(SbtPlugin)

name := "sbt-site"

organization := "com.github.sbt"
organizationName := "sbt"
organizationHomepage := Some(url("https://www.scala-sbt.org/"))

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

crossSbtVersions := List("1.4.9")

licenses += ("BSD 3-Clause", url("https://opensource.org/licenses/BSD-3-Clause"))
//#scm-info
scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-site"), "scm:git:[email protected]:sbt/sbt-site.git"))
//#scm-info

developers += Developer(
"contributors",
"Contributors",
"https://gitter.im/sbt/sbt-site",
url("https://github.com/sbt/sbt-site/graphs/contributors")
inThisBuild(Seq(
organization := "com.github.sbt",
organizationName := "sbt",
organizationHomepage := Some(url("https://www.scala-sbt.org/")),

homepage := Some(url("https://www.scala-sbt.org/sbt-site/")),
licenses += ("BSD 3-Clause", url("https://opensource.org/licenses/BSD-3-Clause")),
//#scm-info
scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-site"), "scm:git:[email protected]:sbt/sbt-site.git")),
//#scm-info
developers += Developer(
"contributors",
"Contributors",
"https://gitter.im/sbt/sbt-site",
url("https://github.com/sbt/sbt-site/graphs/contributors")
),
resolvers ++= Resolver.sonatypeOssRepos("releases")
))

val pluginSettings = Seq(
sbtPlugin := true,
crossSbtVersions := List("1.4.9"),
scriptedLaunchOpts += "-Dproject.version=" + version.value
// scriptedBufferLog := false
)

scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-encoding",
"UTF-8",
"-release",
"11")
resolvers ++= Resolver.sonatypeOssRepos("releases")
val commonSettings = Seq(
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-encoding",
"UTF-8",
"-release",
"11"
)
)

val unfilteredVersion = "0.10.4"

libraryDependencies ++= Seq(
"ws.unfiltered" %% "unfiltered-directives" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-filter" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-jetty" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-specs2" % unfilteredVersion % Test,
"org.foundweekends" %% "pamflet-library" % "0.10.0",
).map(
// Force sbt-site to Scala XML 2.1
_.exclude("org.scala-lang.modules", "scala-xml_2.12")
) ++ Seq(
"org.scala-lang.modules" %% "scala-xml" % "2.1.0",
"org.yaml" % "snakeyaml" % "1.33",
"com.typesafe" % "config" % "1.4.2",
"org.asciidoctor" % "asciidoctorj" % "2.1.0",
"org.asciidoctor" % "asciidoctorj-diagram" % "1.5.18"
)

addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.3")
lazy val root = project
.in(file("."))
.settings(
publish / skip := true,
Compile / publishArtifact := false
)
.settings(
name := "sbt-site-root",
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo"))),
Compile / paradoxMaterialTheme ~= {
_.withFavicon("img/favicon.png")
.withLogo("img/sbt-logo.svg")
.withRepository(uri("https://github.com/sbt/sbt-site"))
}
)
.aggregate(core, asciidoctor, gitbook, paradox)
.enablePlugins(SitePreviewPlugin, ParadoxSitePlugin, ParadoxMaterialThemePlugin)

lazy val core = project
.in(file("core"))
.enablePlugins(SbtPlugin)
.settings(pluginSettings)
.settings(commonSettings)
.settings(
name := "sbt-site",
libraryDependencies ++= Seq(
"ws.unfiltered" %% "unfiltered-directives" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-filter" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-jetty" % unfilteredVersion,
"ws.unfiltered" %% "unfiltered-specs2" % unfilteredVersion % Test,
).map(
// Force sbt-site to Scala XML 2.1
_.exclude("org.scala-lang.modules", "scala-xml_2.12")
) ++ Seq(
"org.scala-lang.modules" %% "scala-xml" % "2.1.0"
)
)

libraryDependencies +=
Defaults.sbtPluginExtra(
"org.planet42" % "laika-sbt" % "0.8.0",
(pluginCrossBuild / sbtBinaryVersion).value,
(pluginCrossBuild / scalaBinaryVersion).value
lazy val asciidoctor = project
.in(file("asciidoctor"))
.settings(
name := "sbt-site-asciidoctor",
libraryDependencies ++= Seq(
"org.asciidoctor" % "asciidoctorj" % "2.1.0",
"org.asciidoctor" % "asciidoctorj-diagram" % "1.5.18"
)
)
.dependsOn(core)
.enablePlugins(SbtPlugin)
.settings(pluginSettings)
.settings(commonSettings)

lazy val gitbook = project
.in(file("gitbook"))
.settings(
name := "sbt-site-gitbook",
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.2"
)
)
.dependsOn(core)
.enablePlugins(SbtPlugin)
.settings(pluginSettings)
.settings(commonSettings)

// https://github.com/sbt/sbt-site/issues/182
// lazy val hugo = project...

// https://github.com/sbt/sbt-site/issues/183
// lazy val jekyll = project...

// https://github.com/sbt/sbt-site/issues/204
// lazy val laika = project...
//libraryDependencies +=
// Defaults.sbtPluginExtra(
// "org.planet42" % "laika-sbt" % "0.8.0",
// (pluginCrossBuild / sbtBinaryVersion).value,
// (pluginCrossBuild / scalaBinaryVersion).value
// )

// https://github.com/sbt/sbt-site/issues/205
// lazy val nanoc = project...

// https://github.com/sbt/sbt-site/issues/206
// lazy val pamflet = project...
//val pamfletDependencies = Seq(
// "org.foundweekends" %% "pamflet-library" % "0.10.0",
// "org.scala-lang.modules" %% "scala-xml" % "2.1.0",
// "org.yaml" % "snakeyaml" % "1.33",
//)

lazy val paradox = project
.in(file("paradox"))
.settings(
name := "sbt-site-paradox",
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.3")
)
.dependsOn(core)
.enablePlugins(SbtPlugin)
.settings(pluginSettings)
.settings(commonSettings)

enablePlugins(ParadoxSitePlugin, ParadoxMaterialThemePlugin)
Compile / paradoxMaterialTheme ~= {
_.withFavicon("img/favicon.png")
.withLogo("img/sbt-logo.svg")
.withRepository(uri("https://github.com/sbt/sbt-site"))
}
// https://github.com/sbt/sbt-site/issues/186
//lazy val sphinx = project...

//#ghpages-publish
enablePlugins(GhpagesPlugin)
git.remoteRepo := scmInfo.value.get.connection.replace("scm:git:", "")
//#ghpages-publish

TaskKey[Unit]("runScriptedTest") := Def.taskDyn {
val sbtBinVersion = (pluginCrossBuild / sbtBinaryVersion).value
val base = sbtTestDirectory.value

def isCompatible(directory: File): Boolean = {
val buildProps = new java.util.Properties()
IO.load(buildProps, directory / "project" / "build.properties")
Option(buildProps.getProperty("sbt.version"))
.map { version =>
val requiredBinVersion = CrossVersion.binarySbtVersion(version)
val compatible = requiredBinVersion == sbtBinVersion
if (!compatible) {
val testName = directory.relativeTo(base).getOrElse(directory)
streams.value.log.warn(s"Skipping $testName since it requires sbt $requiredBinVersion")
}
compatible
}
.getOrElse(true)
}

val testDirectoryFinder = base * AllPassFilter * AllPassFilter filter { _.isDirectory }
val tests = for {
test <- testDirectoryFinder.get
if isCompatible(test)
path <- Path.relativeTo(base)(test)
} yield path.replace('\\', '/')

if (tests.nonEmpty)
Def.task(scripted.toTask(tests.mkString(" ", " ", "")).value)
else
Def.task(streams.value.log.warn("No tests can be run for this sbt version"))
}.value

scriptedLaunchOpts += "-Dproject.version="+version.value

// scriptedBufferLog := false
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import unfiltered.util._
object SitePreviewPlugin extends AutoPlugin {
override def requires = SitePlugin

override def trigger = allRequirements
override def trigger = noTrigger

object autoImport {
val previewSite = TaskKey[Unit]("previewSite", "Launches a jetty server that serves your generated site from the target directory")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version := "0.0-ABCD"
enablePlugins(ScalaUnidocPlugin)

//#mappings
mappings in makeSite ++= Seq(
makeSite / mappings ++= Seq(
file("LICENSE") -> "LICENSE",
file("src/assets/favicon.ico") -> "favicon.ico"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-paradox" % sys.props("project.version"))
File renamed without changes.
1 change: 1 addition & 0 deletions core/src/sbt-test/site/minimum-sbt-1.0/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-paradox" % sys.props("project.version"))
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
addSbtPlugin("com.github.sbt" % "sbt-site" % sys.props("project.version"))

resolvers += "jgit-repo" at "https://download.eclipse.org/jgit/maven"

addSbtPlugin(
("com.github.sbt" % "sbt-ghpages" % "0.7.0")
// sbt-ghpages depends on sbt-site 1.4.1, which pulls Scala XML 1.x
.exclude("org.scala-lang.modules", "scala-xml_2.12")
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-gitbook" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-gitbook" % sys.props("project.version"))
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := "test"

//#enablePlugin
enablePlugins(GitBookPlugin)
enablePlugins(SitePreviewPlugin, GitBookPlugin)
//#enablePlugin

GitBook / sourceDirectory := baseDirectory.value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-site-gitbook" % sys.props("project.version"))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.typesafe.sbt.site.paradox
import com.typesafe.sbt.site.SitePlugin.autoImport.siteSubdirName
import com.typesafe.sbt.site.SitePlugin
import com.typesafe.sbt.site.util.SiteHelpers
import sbt.Keys._
import sbt._
import com.lightbend.paradox.sbt.ParadoxPlugin
import com.typesafe.sbt.web.SbtWeb
Expand Down
Loading

0 comments on commit 5ebc21d

Please sign in to comment.