diff --git a/build.sbt b/build.sbt index 82a27d6..f1bdef3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,10 @@ +import PlayAxis.RichProjectMatrix + ThisBuild / organization := "com.github.dwickern" -lazy val play27 = ConfigAxis("play27", "play2.7") -lazy val play28 = ConfigAxis("play28", "play2.8") -lazy val play288 = ConfigAxis("play288", "play2.8.8") +lazy val play27 = PlayAxis("2.7.9") +lazy val play28 = PlayAxis("2.8.7") +lazy val play288 = PlayAxis("2.8.8") lazy val scala212 = "2.12.13" lazy val scala213 = "2.13.4" @@ -10,38 +12,39 @@ lazy val scala213 = "2.13.4" lazy val swaggerPlayVersion = "3.1.0" lazy val root = (project in file(".")) - .aggregate(plugin, testPlugin) + .aggregate(plugin.projectRefs: _*) .aggregate(runner.projectRefs: _*) + .aggregate(testPlugin) .settings( name := "sbt-swagger-play", publish / skip := true ) -lazy val plugin = (project in file("sbt-plugin")) - .enablePlugins(BuildInfoPlugin) - .enablePlugins(ScriptedPlugin) +lazy val plugin = (projectMatrix in file("sbt-plugin")) + .customRow( + autoScalaLibrary = false, + axisValues = Seq(VirtualAxis.jvm), + _.enablePlugins(BuildInfoPlugin).settings( + publishSettings, + name := "sbt-swagger-play", + sbtPlugin := true, + addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.9" % Provided), + buildInfoKeys := Seq[BuildInfoKey](version), + buildInfoPackage := "com.github.dwickern.sbt", + ) + ) .settings( - publishSettings, - name := "sbt-swagger-play", - sbtPlugin := true, - addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.9" % Provided), - buildInfoKeys := Seq[BuildInfoKey](version), - buildInfoPackage := "com.github.dwickern.sbt", - scriptedLaunchOpts ++= Seq( - "-Xmx1024M", - s"-Dplugin.version=${version.value}", - "-Dplay.version=2.8.8", - "-Dscala.version=2.13.3" - ), - scriptedDependencies := { - def use(@deprecated("unused", "") x: Any*): Unit = () // avoid unused warnings - use( - scriptedDependencies.value, - (testPlugin / publishLocal).value, - runner.projectRefs.map(_ / publishLocal).join.value - ) - }, + scriptedDependencies := Def.task(()) + .dependsOn(testPlugin / publishLocal) + .dependsOn(runner.projectRefs.map(_ / publishLocal).join) + .value ) + .scriptedTests(play288, scala213) + .scriptedTests(play288, scala212) + .scriptedTests(play28, scala213) + .scriptedTests(play28, scala212) + .scriptedTests(play27, scala213) + .scriptedTests(play27, scala212) lazy val testPlugin = (project in file("test-plugin")) .settings( diff --git a/project/ConfigAxis.scala b/project/ConfigAxis.scala deleted file mode 100644 index bdabcb7..0000000 --- a/project/ConfigAxis.scala +++ /dev/null @@ -1,3 +0,0 @@ -import sbt._ - -case class ConfigAxis(idSuffix: String, directorySuffix: String) extends VirtualAxis.WeakAxis diff --git a/project/PlayAxis.scala b/project/PlayAxis.scala new file mode 100644 index 0000000..846fb7a --- /dev/null +++ b/project/PlayAxis.scala @@ -0,0 +1,32 @@ +import sbtide.Keys.ideSkipProject +import sbt.Keys._ +import sbt.ScriptedPlugin.autoImport._ +import sbt._ +import sbt.internal.ProjectMatrix + +case class PlayAxis(version: String, idSuffix: String, directorySuffix: String) extends VirtualAxis.WeakAxis + +object PlayAxis { + def apply(version: String): PlayAxis = + PlayAxis(version, "-play" + version.replace('.', '_'), "-play" + version) + + implicit class RichProjectMatrix(val matrix: ProjectMatrix) extends AnyVal { + def scriptedTests(playAxis: PlayAxis, scalaVersion: String): ProjectMatrix = matrix.customRow( + autoScalaLibrary = false, + axisValues = Seq(playAxis, VirtualAxis.scalaPartialVersion(scalaVersion), VirtualAxis.jvm), + _.enablePlugins(ScriptedPlugin).settings( + compile / skip := true, + publish / skip := true, + ideSkipProject := true, + moduleName := s"${moduleName.value}-test-${playAxis.version}-$scalaVersion", + scriptedLaunchOpts ++= Seq( + "-Xmx1024M", + s"-Dplugin.version=${version.value}", + s"-Dscala.version=$scalaVersion", + s"-Dplay.version=${playAxis.version}" + ), + scriptedBufferLog := true + ) + ) + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 71f542d..5b7e597 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,5 +3,6 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2") +addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0") libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value