-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
addSbtPlugin("com.typesafe.play" % "interplay" % "3.1.6") | ||
addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.0-RC4") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") | ||
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") |