From efc12bf5d8f8540e329c261c650daeb89f39f0c9 Mon Sep 17 00:00:00 2001 From: Sergey Morgunov Date: Thu, 14 Sep 2023 19:08:04 +0300 Subject: [PATCH 1/3] Drop interplay --- build.sbt | 13 +++++----- project/Omnidoc.scala | 55 +++++++++++++++++++++++++++++++++++++++++++ project/plugins.sbt | 1 - 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 project/Omnidoc.scala diff --git a/build.sbt b/build.sbt index c4c99e5..e495b45 100644 --- a/build.sbt +++ b/build.sbt @@ -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 @@ -11,9 +9,14 @@ 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"), scalacOptions ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, _)) => @@ -48,8 +51,6 @@ scalacOptions ++= Seq( "11", ) -(ThisBuild / playBuildRepoName) := "play-doc" - addCommandAlias( "validateCode", List( diff --git a/project/Omnidoc.scala b/project/Omnidoc.scala new file mode 100644 index 0000000..afe6ad1 --- /dev/null +++ b/project/Omnidoc.scala @@ -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) + } + ) + +} diff --git a/project/plugins.sbt b/project/plugins.sbt index e4bd9a6..fa061c3 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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") From 28d691f4d3a78c02d62c6de6303a5767f8834efc Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Wed, 4 Oct 2023 23:01:10 +0200 Subject: [PATCH 2/3] Keep Scala 2 style --- project/Omnidoc.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Omnidoc.scala b/project/Omnidoc.scala index afe6ad1..1ee7e79 100644 --- a/project/Omnidoc.scala +++ b/project/Omnidoc.scala @@ -1,5 +1,5 @@ -import sbt.* -import sbt.Keys.* +import sbt._ +import sbt.Keys._ import sbt.Package.ManifestAttributes /** From d4f7d20054eb0ffdb5c8916b3a8cd0329f4c118c Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Wed, 4 Oct 2023 23:32:52 +0200 Subject: [PATCH 3/3] developers and some flags were missing --- build.sbt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build.sbt b/build.sbt index e495b45..368f96d 100644 --- a/build.sbt +++ b/build.sbt @@ -17,6 +17,13 @@ lazy val `play-doc` = (project in file(".")) 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, _)) => @@ -26,6 +33,7 @@ lazy val `play-doc` = (project in file(".")) "-Xlint:nullary-unit", "-Ywarn-dead-code", "-Xsource:3", + "-Xmigration", ) case _ => Nil } @@ -44,11 +52,19 @@ javacOptions ++= Seq( "11", "-Xlint:deprecation", "-Xlint:unchecked", + "-Xlint:-options", + "-encoding", + "UTF-8", ) scalacOptions ++= Seq( "-release", "11", + "-deprecation", + "-feature", + "-unchecked", + "-encoding", + "utf8" ) addCommandAlias(