Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Cross-compile for Play 2.8 #120

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codacy: codacy/base@10.1.0
codacy: codacy/base@10.9.0

workflows:
version: 2
Expand All @@ -27,7 +27,7 @@ workflows:
command: sbt scalafmtSbtCheck
- run:
name: Run tests
command: sbt test
command: sbt crossTest
- run:
name: Generate coverage report
command: sbt coverageReport
Expand Down Expand Up @@ -58,7 +58,7 @@ workflows:
command: sbt retrieveGPGKeys
- run:
name: Create publish bundle
command: sbt publishSigned
command: sbt crossPublishSigned
- run:
name: Release bundle to Sonatype
command: sbt sonatypeBundleRelease
Expand All @@ -75,6 +75,6 @@ workflows:
command: echo 'privateMvnPublish' > publishing.sbt
- run:
name: Publish to S3
command: sbt publish
command: sbt crossPublish
requires:
- tag_version
43 changes: 41 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ name := """bitbucket-scala-client"""

val scala212 = "2.12.10"

val play27 = "2.7.4"
val play28 = "2.8.2"

lazy val playJsonVersion = settingKey[String]("The version of play-json used for building.")
ThisBuild / playJsonVersion := play27

scalaVersion := scala212

scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-Ywarn-adapted-args", "-Xlint")

resolvers +=
"Typesafe maven repository" at "https://repo.typesafe.com/typesafe/maven-releases/"

libraryDependencies ++= Dependencies.playJson ++ Seq("org.scalatest" %% "scalatest" % "3.0.8" % Test)
libraryDependencies ++= Dependencies.playJson(playJsonVersion.value) ++ Seq(
"org.scalatest" %% "scalatest" % "3.0.8" % Test
)

organizationName := "Codacy"

Expand All @@ -31,4 +39,35 @@ scmInfo := Some(
pgpPassphrase := Option(System.getenv("SONATYPE_GPG_PASSPHRASE"))
.map(_.toCharArray)

name := s"${name.value}_playjson${Dependencies.playVersion.split('.').take(2).mkString}"
name := s"${name.value}_playjson${playJsonVersion.value.split('.').take(2).mkString}"

/**
* Given a command it creates an alias to run the command
* on the entire matrix of play and scala versions.
* If the command has `:` in it (like test:compile)
* the alias becomes crossTestCompile instead of crossTest:compile
* (which is not an allowed sbt alias name)
*/
def addCrossAlias(command: String) = {
val matrix = Seq(scala212 -> Seq(play27, play28))

addCommandAlias(
s"cross${command.split(':').map(_.capitalize).mkString}",
matrix
.flatMap {
case (scalaV, playVersions) =>
s"""set ThisBuild / scalaVersion := "$scalaV"""" +: playVersions
.flatMap(playV => Seq(s"""set ThisBuild / playJsonVersion := "$playV"""", command))
}
.mkString(";")
)
}

// List of crossX aliases.
// Add a command here if you want to call it for
// the entire playVersion / scalaVersion matrix
addCrossAlias("update")
addCrossAlias("compile")
addCrossAlias("test:compile")
addCrossAlias("test")
addCrossAlias("publishSigned")
17 changes: 11 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import sbt._

object Dependencies {
val playVersion: String = "2.7.4"

val playJson = Seq(
"com.typesafe.play" %% "play-json-joda" % playVersion,
"com.typesafe.play" %% "play-ahc-ws-standalone" % "2.0.8",
"com.typesafe.play" %% "play-ws-standalone-json" % "2.0.8"
)
def playJson(playJsonVersion: String) = {
val playwsVersion =
if (playJsonVersion.startsWith("2.8.")) "2.1.11"
else if (playJsonVersion.startsWith("2.7.")) "2.0.8"
else sys.error("Missing play-ws version. Check the compatible version based on its pom")
Seq(
"com.typesafe.play" %% "play-json-joda" % playJsonVersion,
"com.typesafe.play" %% "play-ahc-ws-standalone" % playwsVersion,
"com.typesafe.play" %% "play-ws-standalone-json" % playwsVersion
)
}

}