Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop interplay #206

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import interplay.ScalaVersions._

// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
(ThisBuild / dynverVTagPrefix) := false

Expand All @@ -11,9 +9,21 @@ Global / onLoad := (Global / onLoad).value.andThen { s =>
}

lazy val `play-doc` = (project in file("."))
.enablePlugins(PlayLibrary, SbtTwirl)
.enablePlugins(Omnidoc, SbtTwirl)
.settings(
crossScalaVersions := Seq(scala212, scala213, scala3),
organization := "com.typesafe.play",
organizationName := "The Play Framework Project",
organizationHomepage := Some(url("https://playframework.com")),
homepage := Some(url(s"https://github.com/playframework/${Omnidoc.repoName}")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
crossScalaVersions := Seq("2.12.18", "2.13.12", "3.3.1"),
developers += Developer(
"playframework",
"The Play Framework Contributors",
"contact@playframework.com",
url("https://github.com/playframework")
),
pomIncludeRepository := { _ => false },
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Expand All @@ -23,6 +33,7 @@ lazy val `play-doc` = (project in file("."))
"-Xlint:nullary-unit",
"-Ywarn-dead-code",
"-Xsource:3",
"-Xmigration",
)
case _ => Nil
}
Expand All @@ -41,15 +52,21 @@ javacOptions ++= Seq(
"11",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-options",
"-encoding",
"UTF-8",
)

scalacOptions ++= Seq(
"-release",
"11",
"-deprecation",
"-feature",
"-unchecked",
"-encoding",
"utf8"
)

(ThisBuild / playBuildRepoName) := "play-doc"

addCommandAlias(
"validateCode",
List(
Expand Down
55 changes: 55 additions & 0 deletions project/Omnidoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import sbt._
import sbt.Keys._
import sbt.Package.ManifestAttributes

/**
* This AutoPlugin adds the `Omnidoc-Source-URL` key on the MANIFEST.MF of artifact-sources.jar so later Omnidoc can use
* that value to link scaladocs to GitHub sources.
*/
object Omnidoc extends AutoPlugin {

object autoImport {
lazy val omnidocSnapshotBranch = settingKey[String]("Git branch for development versions")
lazy val omnidocPathPrefix = settingKey[String]("Prefix before source directory paths")
lazy val omnidocSourceUrl = settingKey[Option[String]]("Source URL for scaladoc linking")
}

val repoName = "play-doc"

val omnidocGithubRepo: Option[String] = Some(s"playframework/${repoName}")

val omnidocTagPrefix: Option[String] = Some("")

val SourceUrlKey = "Omnidoc-Source-URL"

override def requires = sbt.plugins.JvmPlugin

override def trigger = noTrigger

import autoImport.*

override def projectSettings = Seq(
omnidocSourceUrl := omnidocGithubRepo.map { repo =>
val development: String = (omnidocSnapshotBranch ?? "main").value
val tagged: String = omnidocTagPrefix.getOrElse("v") + version.value
val tree: String = if (isSnapshot.value) development else tagged
val prefix: String = "/" + (omnidocPathPrefix ?? "").value
val path: String = {
val buildDir: File = (ThisBuild / baseDirectory).value
val projDir: File = baseDirectory.value
val rel: Option[String] = IO.relativize(buildDir, projDir)
rel match {
case None if buildDir == projDir => "" // Same dir (sbt 0.13)
case Some("") => "" // Same dir (sbt 1.0)
case Some(childDir) => prefix + childDir // Child dir
case None => "" // Disjoint dirs (Rich: I'm not sure if this can happen)
}
}
s"https://github.com/${repo}/tree/${tree}${path}"
},
Compile / packageSrc / packageOptions ++= omnidocSourceUrl.value.toSeq.map { url =>
ManifestAttributes(SourceUrlKey -> url)
}
)

}
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
addSbtPlugin("com.typesafe.play" % "interplay" % "3.1.7")
addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
Loading