diff --git a/build.sbt b/build.sbt index e70073e3..106041e8 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,6 @@ import com.typesafe.tools.mima.core._ import sbt.util.{ Level => _, _ } import sbt.io.Path._ -import interplay.ScalaVersions._ val SeleniumVersion = "4.12.1" val SeleniumHtmlunitVersion = "4.12.0" @@ -27,7 +26,6 @@ val ScalatestVersion = "3.2.17" val ScalatestSeleniumVersion = ScalatestVersion + ".0" val ScalatestMockitoVersion = ScalatestVersion + ".0" -ThisBuild / playBuildRepoName := "scalatestplus-play" ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("releases") // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed @@ -49,8 +47,8 @@ lazy val mimaSettings = Seq( ) lazy val commonSettings = Seq( - scalaVersion := scala213, - crossScalaVersions := Seq(scala213, scala3), + scalaVersion := "2.13.12", + crossScalaVersions := Seq("2.13.12", "3.3.1"), Test / parallelExecution := false, Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oTK"), headerLicense := Some( @@ -75,22 +73,26 @@ lazy val commonSettings = Seq( lazy val `scalatestplus-play-root` = project .in(file(".")) - .enablePlugins(PlayRootProject) .aggregate(`scalatestplus-play`) .settings(commonSettings) .settings( sonatypeProfileName := "org.scalatestplus.play", - mimaPreviousArtifacts := Set.empty + mimaPreviousArtifacts := Set.empty, + publish / skip := true ) lazy val `scalatestplus-play` = project .in(file("module")) - .enablePlugins(Playdoc, PlayLibrary) + .enablePlugins(Omnidoc, Playdoc) .configs(Docs) .settings( commonSettings, mimaSettings, organization := "org.scalatestplus.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")), libraryDependencies ++= Seq( ws, nettyServer % Test, // Using netty for now, we can switch back to akkaHttpServer when it has Scala 3 artifacts @@ -111,10 +113,11 @@ lazy val `scalatestplus-play` = project lazy val docs = project .in(file("docs")) - .enablePlugins(PlayDocsPlugin, PlayNoPublish) + .enablePlugins(PlayDocsPlugin) .configs(Docs) .settings( commonSettings, + publish / skip := true, libraryDependencies ++= Seq( "org.mockito" % "mockito-core" % MockitoVersion % Test, ), diff --git a/project/Omnidoc.scala b/project/Omnidoc.scala new file mode 100644 index 00000000..3a2fe45e --- /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 = "scalatestplus-play" + + 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/Playdoc.scala b/project/Playdoc.scala new file mode 100644 index 00000000..9c55220e --- /dev/null +++ b/project/Playdoc.scala @@ -0,0 +1,32 @@ +import sbt.* +import sbt.Keys.* +import sbt.io.IO + +object Playdoc extends AutoPlugin { + + object autoImport { + final val Docs = config("docs") + val playdocDirectory = settingKey[File]("Base directory of play documentation") + val playdocPackage = taskKey[File]("Package play documentation") + } + + import autoImport.* + + override def requires = sbt.plugins.JvmPlugin + + override def trigger = noTrigger + + override def projectSettings = + Defaults.packageTaskSettings(playdocPackage, playdocPackage / mappings) ++ + Seq( + playdocDirectory := (ThisBuild / baseDirectory).value / "docs" / "manual", + playdocPackage / mappings := { + val base: File = playdocDirectory.value + base.allPaths.pair(IO.relativize(base.getParentFile(), _)) + }, + playdocPackage / artifactClassifier := Some("playdoc"), + playdocPackage / artifact ~= { _.withConfigurations(Vector(Docs)) } + ) ++ + addArtifact(playdocPackage / artifact, playdocPackage) + +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 4599a192..cf4df429 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,14 +1,12 @@ resolvers ++= DefaultOptions.resolvers(snapshot = true) -resolvers ++= Seq( - Resolver.typesafeRepo("releases"), - Resolver.sonatypeRepo("releases"), - Resolver.sonatypeRepo("snapshots"), // used by deploy nightlies, which publish here & use -Dplay.version -) +resolvers ++= Resolver + .sonatypeOssRepos("snapshots") // used by deploy nightlies, which publish here & use -Dplay.version -addSbtPlugin("com.typesafe.play" % "interplay" % sys.props.getOrElse("interplay.version", "3.1.7")) addSbtPlugin("com.typesafe.play" % "sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-RC2")) addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % sys.props.getOrElse("play.version", "2.9.0-RC2")) addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") + +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")