Skip to content

Commit 9735b14

Browse files
committed
Merge branch 'main' into 2.2.x
2 parents 297e950 + 52954b4 commit 9735b14

File tree

3 files changed

+79
-7
lines changed

3 files changed

+79
-7
lines changed

build.sbt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import interplay.ScalaVersions._
2-
31
// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
42
(ThisBuild / dynverVTagPrefix) := false
53

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

1311
lazy val `play-doc` = (project in file("."))
14-
.enablePlugins(PlayLibrary, SbtTwirl)
12+
.enablePlugins(Omnidoc, SbtTwirl)
1513
.settings(
16-
crossScalaVersions := Seq(scala212, scala213, scala3),
14+
organization := "com.typesafe.play",
15+
organizationName := "The Play Framework Project",
16+
organizationHomepage := Some(url("https://playframework.com")),
17+
homepage := Some(url(s"https://github.com/playframework/${Omnidoc.repoName}")),
18+
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
19+
crossScalaVersions := Seq("2.12.18", "2.13.12", "3.3.1"),
20+
developers += Developer(
21+
"playframework",
22+
"The Play Framework Contributors",
23+
24+
url("https://github.com/playframework")
25+
),
26+
pomIncludeRepository := { _ => false },
1727
scalacOptions ++= {
1828
CrossVersion.partialVersion(scalaVersion.value) match {
1929
case Some((2, _)) =>
@@ -23,6 +33,7 @@ lazy val `play-doc` = (project in file("."))
2333
"-Xlint:nullary-unit",
2434
"-Ywarn-dead-code",
2535
"-Xsource:3",
36+
"-Xmigration",
2637
)
2738
case _ => Nil
2839
}
@@ -41,15 +52,22 @@ javacOptions ++= Seq(
4152
"11",
4253
"-Xlint:deprecation",
4354
"-Xlint:unchecked",
55+
"-Xlint:-options",
56+
"-encoding",
57+
"UTF-8",
4458
)
59+
doc / javacOptions := Seq("-source", "11")
4560

4661
scalacOptions ++= Seq(
4762
"-release",
4863
"11",
64+
"-deprecation",
65+
"-feature",
66+
"-unchecked",
67+
"-encoding",
68+
"utf8"
4969
)
5070

51-
(ThisBuild / playBuildRepoName) := "play-doc"
52-
5371
addCommandAlias(
5472
"validateCode",
5573
List(

project/Omnidoc.scala

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import sbt._
2+
import sbt.Keys._
3+
import sbt.Package.ManifestAttributes
4+
5+
/**
6+
* This AutoPlugin adds the `Omnidoc-Source-URL` key on the MANIFEST.MF of artifact-sources.jar so later Omnidoc can use
7+
* that value to link scaladocs to GitHub sources.
8+
*/
9+
object Omnidoc extends AutoPlugin {
10+
11+
object autoImport {
12+
lazy val omnidocSnapshotBranch = settingKey[String]("Git branch for development versions")
13+
lazy val omnidocPathPrefix = settingKey[String]("Prefix before source directory paths")
14+
lazy val omnidocSourceUrl = settingKey[Option[String]]("Source URL for scaladoc linking")
15+
}
16+
17+
val repoName = "play-doc"
18+
19+
val omnidocGithubRepo: Option[String] = Some(s"playframework/${repoName}")
20+
21+
val omnidocTagPrefix: Option[String] = Some("")
22+
23+
val SourceUrlKey = "Omnidoc-Source-URL"
24+
25+
override def requires = sbt.plugins.JvmPlugin
26+
27+
override def trigger = noTrigger
28+
29+
import autoImport.*
30+
31+
override def projectSettings = Seq(
32+
omnidocSourceUrl := omnidocGithubRepo.map { repo =>
33+
val development: String = (omnidocSnapshotBranch ?? "main").value
34+
val tagged: String = omnidocTagPrefix.getOrElse("v") + version.value
35+
val tree: String = if (isSnapshot.value) development else tagged
36+
val prefix: String = "/" + (omnidocPathPrefix ?? "").value
37+
val path: String = {
38+
val buildDir: File = (ThisBuild / baseDirectory).value
39+
val projDir: File = baseDirectory.value
40+
val rel: Option[String] = IO.relativize(buildDir, projDir)
41+
rel match {
42+
case None if buildDir == projDir => "" // Same dir (sbt 0.13)
43+
case Some("") => "" // Same dir (sbt 1.0)
44+
case Some(childDir) => prefix + childDir // Child dir
45+
case None => "" // Disjoint dirs (Rich: I'm not sure if this can happen)
46+
}
47+
}
48+
s"https://github.com/${repo}/tree/${tree}${path}"
49+
},
50+
Compile / packageSrc / packageOptions ++= omnidocSourceUrl.value.toSeq.map { url =>
51+
ManifestAttributes(SourceUrlKey -> url)
52+
}
53+
)
54+
55+
}

project/plugins.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
addSbtPlugin("com.typesafe.play" % "interplay" % "3.1.7")
21
addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.1")
32
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
43
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")

0 commit comments

Comments
 (0)