Skip to content

Commit

Permalink
Build: don't depend on Interplay (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru authored May 26, 2020
1 parent 50d38f3 commit 9462d1c
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 49 deletions.
66 changes: 22 additions & 44 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import sbt._
import sbt.util._
import sbt.io.Path._

import interplay.ScalaVersions

import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
import com.typesafe.tools.mima.plugin.MimaKeys.mimaPreviousArtifacts

import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossType

resolvers ++= DefaultOptions.resolvers(snapshot = true)

playBuildRepoName in ThisBuild := "play-json"
publishTo in ThisBuild := sonatypePublishToBundle.value

val specs2 = Seq(
"org.specs2" %% "specs2-core" % "4.9.4" % Test,
"org.specs2" %% "specs2-junit" % "4.9.4" % Test,
Expand Down Expand Up @@ -46,13 +40,13 @@ def jsonDependencies(scalaVersion: String) = Seq(

// Common settings

val previousVersion = Some("2.8.1")

ThisBuild / mimaFailOnNoPrevious := false

def playJsonMimaSettings = mimaDefaultSettings ++ Seq(
mimaPreviousArtifacts := previousVersion.map(organization.value %%% moduleName.value % _).toSet
)
def playJsonMimaSettings =
Seq(
mimaPreviousArtifacts := Set(
(organization.value %%% moduleName.value % previousStableVersion.value
.getOrElse(throw new Error("Unable to determine previous version")))
)
)

// Workaround for https://github.com/scala-js/scala-js/issues/2378
// Use "sbt -DscalaJSStage=full" in .travis.yml
Expand Down Expand Up @@ -108,15 +102,9 @@ lazy val commonSettings = Def.settings(
// Filtering tests that are not stable in Scala 2.13 yet.
Tests.Argument(TestFrameworks.ScalaTest, "-l", "play.api.libs.json.UnstableInScala213")
),
headerLicense := {
Some(
HeaderLicense.Custom(
s"Copyright (C) 2009-2020 Lightbend Inc. <https://www.lightbend.com>"
)
)
},
scalaVersion := ScalaVersions.scala212,
crossScalaVersions := Seq(ScalaVersions.scala212, ScalaVersions.scala213),
headerLicense := Some(HeaderLicense.Custom(s"Copyright (C) 2009-2020 Lightbend Inc. <https://www.lightbend.com>")),
scalaVersion := Dependencies.Scala212,
crossScalaVersions := Seq(Dependencies.Scala212, Dependencies.Scala213),
javacOptions in Compile ++= javacSettings,
javacOptions in Test ++= javacSettings,
javacOptions in (Compile, compile) ++= Seq("-target", "1.8"), // sbt #1785, avoids passing to javadoc
Expand All @@ -129,7 +117,8 @@ lazy val commonSettings = Def.settings(

lazy val root = project
.in(file("."))
.enablePlugins(PlayRootProject, ScalaJSPlugin)
.enablePlugins(ScalaJSPlugin)
.disablePlugins(MimaPlugin)
.aggregate(
`play-jsonJS`,
`play-jsonJVM`,
Expand All @@ -138,27 +127,12 @@ lazy val root = project
`play-json-joda`
)
.settings(commonSettings)
.settings(
Seq(
// this overrides releaseProcess to make it work with sbt-dynver
releaseProcess := {
import ReleaseTransformations._
Seq[ReleaseStep](
checkSnapshotDependencies,
runClean,
releaseStepCommandAndRemaining("+test"), // <- this needs to be removed when releasing from Travis
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
pushChanges // <- this needs to be removed when releasing from tag
)
}
)
)
.settings(publish / skip := true)

lazy val `play-json` = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Full)
.in(file("play-json"))
.enablePlugins(PlayLibrary, Playdoc)
.enablePlugins(Omnidoc, Publish, Playdoc)
.configs(Docs)
.settings(
commonSettings ++ playJsonMimaSettings ++ Seq(
Expand Down Expand Up @@ -251,7 +225,7 @@ lazy val `play-jsonJVM` = `play-json`.jvm.settings(

lazy val `play-json-joda` = project
.in(file("play-json-joda"))
.enablePlugins(PlayLibrary)
.enablePlugins(Omnidoc, Publish)
.settings(
commonSettings ++ playJsonMimaSettings ++ Seq(
libraryDependencies ++= joda ++ specs2
Expand All @@ -265,22 +239,26 @@ lazy val `play-functional` = crossProject(JVMPlatform, JSPlatform)
.settings(
commonSettings ++ playJsonMimaSettings
)
.enablePlugins(PlayLibrary)
.enablePlugins(Omnidoc, Publish)

lazy val `play-functionalJVM` = `play-functional`.jvm
lazy val `play-functionalJS` = `play-functional`.js

lazy val benchmarks = project
.in(file("benchmarks"))
.enablePlugins(JmhPlugin, PlayNoPublish)
.enablePlugins(JmhPlugin)
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(publish / skip := true)
.dependsOn(`play-jsonJVM`)

lazy val docs = project
.in(file("docs"))
.enablePlugins(PlayDocsPlugin, PlayNoPublish)
.enablePlugins(PlayDocsPlugin)
.disablePlugins(MimaPlugin)
.configs(Docs)
.settings(
publish / skip := true,
libraryDependencies ++= specs2,
PlayDocsKeys.scalaManualSourceDirectories := (baseDirectory.value / "manual" / "working" / "scalaGuide" ** "code").get,
PlayDocsKeys.resources += {
Expand Down
35 changes: 35 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin

object Common extends AutoPlugin {
override def trigger = allRequirements

override def requires = JvmPlugin

val repoName = "play-json"

override def globalSettings =
Seq(
organization := "com.typesafe.play",
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("https://www.lightbend.com/")),
homepage := Some(url(s"https://github.com/playframework/${repoName}")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8"),
javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:-options"),
scmInfo := Some(
ScmInfo(
url(s"https://github.com/playframework/${repoName}"),
s"scm:git:git@github.com:playframework/${repoName}.git"
)
),
developers += Developer(
"contributors",
"Contributors",
"https://gitter.im/playframework/contributors",
url("https://github.com/playframework")
),
description := "Play JSON"
)
}
5 changes: 5 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object Dependencies {
// scalaVersion needs to be kept in sync with travis-ci
val Scala212 = "2.12.10"
val Scala213 = "2.13.1"
}
57 changes: 57 additions & 0 deletions project/Omnidoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import sbt.Keys._
import sbt.Package.ManifestAttributes
import sbt._

/**
* Copied in from
* https://github.com/playframework/interplay/blob/master/src/main/scala/interplay/Omnidoc.scala
*
* 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 omnidocGithubRepo = settingKey[String]("Github repository for source URL")
lazy val omnidocSnapshotBranch = settingKey[String]("Git branch for development versions")
// lazy val omnidocTagPrefix = settingKey[String]("Prefix before git tagged versions")
lazy val omnidocPathPrefix = settingKey[String]("Prefix before source directory paths")
lazy val omnidocSourceUrl = settingKey[Option[String]]("Source URL for scaladoc linking")
}

val omnidocGithubRepo = Some(s"playframework/${Common.repoName}")
val omnidocTagPrefix = 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 ?? "master").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 = (baseDirectory in ThisBuild).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}"
},
packageOptions in (Compile, packageSrc) ++= omnidocSourceUrl.value.toSeq.map { url =>
ManifestAttributes(SourceUrlKey -> url)
}
)

}
32 changes: 32 additions & 0 deletions project/Playdoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sbt.Keys._
import sbt._
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, mappings in playdocPackage) ++
Seq(
playdocDirectory := (baseDirectory in ThisBuild).value / "docs" / "manual",
mappings in playdocPackage := {
val base: File = playdocDirectory.value
base.allPaths.pair(IO.relativize(base.getParentFile(), _))
},
artifactClassifier in playdocPackage := Some("playdoc"),
artifact in playdocPackage ~= { _.withConfigurations(Vector(Docs)) }
) ++
addArtifact(artifact in playdocPackage, playdocPackage)

}
22 changes: 22 additions & 0 deletions project/Publish.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sbt._
import Keys._

object Publish extends AutoPlugin {

import bintray.BintrayPlugin
import bintray.BintrayPlugin.autoImport._

override def trigger = noTrigger

override def requires = BintrayPlugin

override def projectSettings =
Seq(
bintrayOrganization := Some("playframework"),
bintrayRepository := (if (isSnapshot.value) "snapshots" else "maven"),
bintrayPackage := "play-json",
bintrayReleaseOnPublish := false,
publishMavenStyle := true,
bintrayPackageLabels := Seq("playframework", "JSON", "Scala.js")
)
}
6 changes: 1 addition & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
resolvers ++= DefaultOptions.resolvers(snapshot = true)
resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("com.typesafe.play" % "interplay" % sys.props.get("interplay.version").getOrElse("3.0.0"))
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")

addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % sys.props.getOrElse("play.version", "2.8.2"))

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.33")
Expand Down

0 comments on commit 9462d1c

Please sign in to comment.