Skip to content

Commit

Permalink
Merge pull request #233 from kailuowang/master
Browse files Browse the repository at this point in the history
make master play 2.6
  • Loading branch information
kailuowang authored Nov 16, 2018
2 parents 15a0a93 + 8c2b7cd commit 79dc84d
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
- docker

scala:
- 2.11.12
- 2.12.2

jdk:
- oraclejdk8
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ You can find the setup in the example project as well.


#### Step 1
For play2.6 add Swagger sbt plugin dependency to your plugins.sbt
```scala
addSbtPlugin("com.iheart" % "sbt-play-swagger" % "0.6.1-PLAY2.6")
```

For play2.5 add Swagger sbt plugin dependency to your plugins.sbt (see [the releases tab](https://github.com/iheartradio/play-swagger/releases) for the latest versions)

For Play 2.5
Expand Down
17 changes: 11 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@ lazy val playSwagger = project.in(file("core"))
Dependencies.playJson ++
Dependencies.test ++
Dependencies.yaml,
scalaVersion := "2.11.12"
scalaVersion := "2.12.4"
)

lazy val sbtPlaySwagger = project.in(file("sbtPlugin"))
.settings(Publish.sbtPluginSettings ++ Format.settings ++ ScriptedTesting.settings)
.settings(Publish.sbtPluginSettings ++ Format.settings)
.settings(
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6" % Provided),
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.3.0" % Provided))
addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.3.1" % Provided),
addSbtPlugin("com.typesafe.sbt" %% "sbt-web" % "1.4.3" % Provided))
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version),
buildInfoPackage := "com.iheart.playSwagger",
name := "sbt-play-swagger",
description := "sbt plugin for play swagger spec generation",
sbtPlugin := true,
scalaVersion := "2.10.7",
scripted := scripted.dependsOn(publishLocal in playSwagger).evaluated
scalaVersion := "2.12.4",
scripted := scripted.dependsOn(publishLocal in playSwagger).evaluated,
scriptedLaunchOpts := { scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false
)

2 changes: 1 addition & 1 deletion example/app/controllers/AsyncController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import scala.concurrent.duration._
* asynchronous code.
*/
@Singleton
class AsyncController @Inject() (actorSystem: ActorSystem)(implicit exec: ExecutionContext) extends Controller {
class AsyncController @Inject() (actorSystem: ActorSystem, components: ControllerComponents)(implicit exec: ExecutionContext) extends AbstractController(components) {
implicit val fmt = Json.format[Message]
/**
* Create an Action that returns a plain text message after a delay
Expand Down
2 changes: 1 addition & 1 deletion example/app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import play.api.mvc._
* application's home page.
*/
@Singleton
class HomeController @Inject() extends Controller {
class HomeController @Inject() (components: ControllerComponents) extends AbstractController(components) {

/**
* Create an Action to render an HTML page with a welcome message.
Expand Down
2 changes: 1 addition & 1 deletion example/app/controllers/math/CountController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import services.Counter
* object is injected by the Guice dependency injection system.
*/
@Singleton
class CountController @Inject() (counter: Counter) extends Controller {
class CountController @Inject() (counter: Counter, components: ControllerComponents) extends AbstractController(components) {

/**
* Create an action that responds with the [[Counter]]'s current
Expand Down
2 changes: 1 addition & 1 deletion example/app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
* Get an `Html` object by calling the built-in Play welcome
* template and passing a `String` message.
*@
@play20.welcome(message, style = "Scala")
@message

}
5 changes: 3 additions & 2 deletions example/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala, SwaggerPlugin) //enable plugin

scalaVersion := "2.11.12"
scalaVersion := "2.12.2"

libraryDependencies ++= Seq(
jdbc,
cache,
ws,
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test,
guice,
"org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test,
"org.webjars" % "swagger-ui" % "2.2.0" //play-swagger ui integration
)

Expand Down
2 changes: 1 addition & 1 deletion example/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ akka {
# The secret key is used to sign Play's session cookie.
# This must be changed for production, but we don't recommend you change it in this file.
# The following is for the convenience of Play-Swagger development, don't use it for your project!
play.crypto.secret = "QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n"
play.http.secret.key = "QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n"


## Modules
Expand Down
2 changes: 1 addition & 1 deletion example/project/build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Activator-generated Properties
#Wed Aug 24 09:12:28 EDT 2016
template.uuid=b0d11fa6-d1b3-4963-94aa-319a15612bf3
sbt.version=0.13.16
sbt.version=1.0.3
19 changes: 2 additions & 17 deletions example/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.6")
addSbtPlugin("com.typesafe.play" %% "sbt-plugin" % "2.6.7")

// web plugins

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2")

// play swagger plugin
addSbtPlugin("com.iheart" % "sbt-play-swagger" % "0.5.3")
addSbtPlugin("com.iheart" %% "sbt-play-swagger" % "0.7.3")


3 changes: 2 additions & 1 deletion example/test/ApplicationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import org.scalatestplus.play._
import play.api.test._
import play.api.test.Helpers._
import org.scalatestplus.play.guice.GuiceOneAppPerTest

/**
* Add your spec here.
* You can mock out a whole application including requests, plugins etc.
* For more information, consult the wiki.
*/
class ApplicationSpec extends PlaySpec with OneAppPerTest {
class ApplicationSpec extends PlaySpec with GuiceOneAppPerTest {

"Routes" should {

Expand Down
3 changes: 2 additions & 1 deletion example/test/IntegrationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import org.scalatestplus.play._
import play.api.test._
import play.api.test.Helpers._
import org.scalatestplus.play.guice.GuiceOneServerPerTest

/**
* add your integration spec here.
* An integration test will fire up a whole play application in a real (or headless) browser
*/
class IntegrationSpec extends PlaySpec with OneServerPerTest with OneBrowserPerTest with HtmlUnitFactory {
class IntegrationSpec extends PlaySpec with GuiceOneServerPerTest with OneBrowserPerTest with HtmlUnitFactory {

"Application" should {

Expand Down
7 changes: 4 additions & 3 deletions project/Dependencies.scala
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import sbt._

object Dependencies {
object Versions {
val play = "2.5.18"
val play = "2.6.13"
val playJson = "2.6.9"
val specs2 = "3.8.9"
}

Expand All @@ -13,10 +14,10 @@ object Dependencies {
"com.typesafe.play" %% "routes-compiler" % Versions.play)

val playJson = Seq(
"com.typesafe.play" %% "play-json" % Versions.play % "provided")
"com.typesafe.play" %% "play-json" % Versions.playJson % "provided")

val yaml = Seq(
"org.yaml" % "snakeyaml" % "1.16")
"org.yaml" % "snakeyaml" % "1.18")

val test = Seq(
"org.specs2" %% "specs2-core" % Versions.specs2 % "test",
Expand Down
14 changes: 0 additions & 14 deletions project/ScriptedTesting.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project/build.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=1.1.5
4 changes: 2 additions & 2 deletions project/plugins.sbt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")

Expand All @@ -8,6 +8,6 @@ addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.2")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
12 changes: 6 additions & 6 deletions sbtPlugin/src/main/scala/com/iheart/sbtPlaySwagger/SwaggerPlugin.scala
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sbt.{ AutoPlugin, _ }
import com.typesafe.sbt.web.Import._

object SwaggerPlugin extends AutoPlugin {
lazy val swaggerConfig = config("play-swagger").hide
lazy val SwaggerConfig = config("play-swagger").hide
lazy val playSwaggerVersion = com.iheart.playSwagger.BuildInfo.version

object autoImport extends SwaggerKeys
Expand All @@ -19,13 +19,13 @@ object SwaggerPlugin extends AutoPlugin {

import autoImport._

override def projectConfigurations: Seq[Configuration] = Seq(swaggerConfig)
override def projectConfigurations: Seq[Configuration] = Seq(SwaggerConfig)

override def projectSettings: Seq[Setting[_]] = Seq(
ivyConfigurations += swaggerConfig,
ivyConfigurations += SwaggerConfig,
resolvers += Resolver.jcenterRepo,
//todo: remove hardcoded org name using BuildInfo
libraryDependencies += "com.iheart" %% "play-swagger" % playSwaggerVersion % swaggerConfig,
libraryDependencies += "com.iheart" %% "play-swagger" % playSwaggerVersion % SwaggerConfig,
swaggerDomainNameSpaces := Seq(),
swaggerV3 := false,
swaggerTarget := target.value / "swagger",
Expand All @@ -45,8 +45,8 @@ object SwaggerPlugin extends AutoPlugin {
swaggerAPIVersion.value ::
swaggerPrettyJson.value.toString ::
Nil
val swaggerClasspath = data((fullClasspath in Runtime).value) ++ update.value.select(configurationFilter(swaggerConfig.name))
toError(runner.value.run("com.iheart.playSwagger.SwaggerSpecRunner", swaggerClasspath, args, streams.value.log))
val swaggerClasspath = data((fullClasspath in Runtime).value) ++ update.value.select(configurationFilter(SwaggerConfig.name))
runner.value.run("com.iheart.playSwagger.SwaggerSpecRunner", swaggerClasspath, args, streams.value.log).failed foreach (sys error _.getMessage)
file
}.value,
unmanagedResourceDirectories in Assets += swaggerTarget.value,
Expand Down
6 changes: 3 additions & 3 deletions sbtPlugin/src/sbt-test/sbt-play-swagger/generate-docs/build.sbt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ enablePlugins(PlayScala, SwaggerPlugin)

name := "app"

scalaVersion := "2.11.12"

version := "1.0.1-BETA1"

scalaVersion := "2.12.2"

swaggerDomainNameSpaces := Seq("namespace1", "namespace2")

swaggerRoutesFile := "my-routes"
Expand Down Expand Up @@ -154,7 +154,7 @@ TaskKey[Unit]("check") := {
}

TaskKey[Unit]("unzip1") := {
val from = new File(s"target/scala-2.11/app_2.11-${version.value}.jar")
val from = new File(s"target/scala-2.12/app_2.12-${version.value}.jar")
val to = new File("target/jar")
IO.unzip(from, to)
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion sbtPlugin/src/sbt-test/sbt-play-swagger/generate-docs/project/build.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.16
sbt.version=1.0.3
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
logLevel in update := sbt.Level.Warn

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.6")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.14")
addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.3.2")
addSbtPlugin("com.typesafe.play" %% "sbt-plugin" % "2.6.7")

{
val pluginVersion = System.getProperty("plugin.version")
if(pluginVersion == null)
throw new RuntimeException("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
else addSbtPlugin("com.iheart" % "sbt-play-swagger" % pluginVersion)
else addSbtPlugin("com.iheart" %% "sbt-play-swagger" % pluginVersion)
}

libraryDependencies += "io.spray" %% "spray-json" % "1.3.3"
Empty file added scripted.sbt
Empty file.
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.6.6-SNAPSHOT"
version in ThisBuild := "0.7.5-SNAPSHOT"

0 comments on commit 79dc84d

Please sign in to comment.