diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aff3535b..ecf9316f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '13', '18' ] - scala: [ '2.13.8' ] + java: [ '17' ] + scala: [ '2.13.11' ] steps: - uses: actions/checkout@v2 - name: Set up JDK @@ -25,4 +25,4 @@ jobs: - name: print Java version run: java -version - name: Build - run: sbt ++${{ matrix.scala }} clean coverage test coverageReport + run: sbt ++${{ matrix.scala }} clean test diff --git a/.travis.yml b/.travis.yml index 77366fb5..847a9c2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ cache: - $HOME/.ivy2/cache - $HOME/.sbt/boot/ script: - - sbt clean coverage test coverageReport + - sbt clean test # Tricks to avoid unnecessary cache updates - find $HOME/.sbt -name "*.lock" | xargs rm -f - find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm -f diff --git a/DEVELOPER.md b/DEVELOPER.md index 9741960f..318d69dc 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -3,7 +3,3 @@ Running sbt > project generator > run - -Code coverage -============= - sbt clean coverage test coverageReport diff --git a/Dockerfile b/Dockerfile index 085f3b73..8e1104bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM flowdocker/play_builder:latest-java13 as builder +FROM flowdocker/play_builder:latest-java17 as builder ADD . /opt/play WORKDIR /opt/play RUN sbt 'project generator' clean stage -FROM flowdocker/play:latest-java13 +FROM flowdocker/play:latest-java17 COPY --from=builder /opt/play /opt/play WORKDIR /opt/play/generator/target/universal/stage ENTRYPOINT ["java", "-jar", "/root/environment-provider.jar", "--service", "play", "apibuilder-generator", "bin/apibuilder-generator-generator"] diff --git a/build.sbt b/build.sbt index 48185a30..45a809be 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,10 @@ -import scoverage.ScoverageKeys - name := "apibuilder-generator" organization := "io.apibuilder.generator" -ThisBuild / scalaVersion := "2.13.8" +ThisBuild / scalaVersion := "2.13.11" + +ThisBuild / javacOptions ++= Seq("-source", "17", "-target", "17") lazy val allScalacOptions = Seq( "-deprecation", @@ -36,6 +36,10 @@ lazy val generated = project "org.scalacheck" %% "scalacheck" % "1.15.4" % Test ), scalacOptions ++= allScalacOptions, + Test / javaOptions ++= Seq( + "--add-exports=java.base/sun.security.x509=ALL-UNNAMED", + "--add-opens=java.base/sun.security.ssl=ALL-UNNAMED" + ) ) // TODO: lib will eventually be published as a jar if it turns out @@ -48,8 +52,8 @@ lazy val lib = project lazy val generator = project .in(file("generator")) - .dependsOn(csharpGenerator, scalaGenerator, rubyGenerator, javaGenerator, goGenerator, androidGenerator, kotlinGenerator, graphQLGenerator, javaAwsLambdaPojos, postmanGenerator, csvGenerator) - .aggregate(csharpGenerator, scalaGenerator, rubyGenerator, javaGenerator, goGenerator, androidGenerator, kotlinGenerator, graphQLGenerator, javaAwsLambdaPojos, postmanGenerator, csvGenerator) + .dependsOn(elmGenerator, csharpGenerator, scalaGenerator, rubyGenerator, javaGenerator, goGenerator, androidGenerator, kotlinGenerator, graphQLGenerator, javaAwsLambdaPojos, postmanGenerator, csvGenerator) + .aggregate(elmGenerator, csharpGenerator, scalaGenerator, rubyGenerator, javaGenerator, goGenerator, androidGenerator, kotlinGenerator, graphQLGenerator, javaAwsLambdaPojos, postmanGenerator, csvGenerator) .enablePlugins(PlayScala) .enablePlugins(JavaAgent) .settings(commonSettings: _*) @@ -63,6 +67,10 @@ lazy val generator = project "org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % "test" ), scalacOptions ++= allScalacOptions, + Test / javaOptions ++= Seq( + "--add-exports=java.base/sun.security.x509=ALL-UNNAMED", + "--add-opens=java.base/sun.security.ssl=ALL-UNNAMED" + ) ) lazy val javaAwsLambdaPojos = project @@ -70,7 +78,6 @@ lazy val javaAwsLambdaPojos = project .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) .settings( - Seq(ScoverageKeys.coverageMinimumStmtTotal := 69.5), libraryDependencies ++= Seq( "com.amazonaws" % "aws-java-sdk-dynamodb" % "1.11.461", "me.geso" % "tinyvalidator" % "0.9.1", @@ -84,9 +91,8 @@ lazy val scalaGenerator = project .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) .settings( - Seq(ScoverageKeys.coverageMinimumStmtTotal := 85.4), libraryDependencies ++= Seq( - "org.typelevel" %% "cats-core" % "2.1.1", + "org.typelevel" %% "cats-core" % "2.10.0", "org.scalameta" %% "scalafmt-core" % "2.3.2" ) ) @@ -97,7 +103,17 @@ lazy val csharpGenerator = project .settings(commonSettings: _*) .settings( libraryDependencies ++= Seq( - "org.typelevel" %% "cats-core" % "2.1.1" + "org.typelevel" %% "cats-core" % "2.10.0" + ) + ) + +lazy val elmGenerator = project + .in(file("elm-generator")) + .dependsOn(lib, lib % "test->test") + .settings(commonSettings: _*) + .settings( + libraryDependencies ++= Seq( + "org.typelevel" %% "cats-core" % "2.10.0" ) ) @@ -105,13 +121,11 @@ lazy val rubyGenerator = project .in(file("ruby-generator")) .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 86.5)) lazy val javaGenerator = project .in(file("java-generator")) .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 66.98)) lazy val goGenerator = project .in(file("go-generator")) @@ -124,14 +138,12 @@ lazy val androidGenerator = project .settings( commonSettings: _* ) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 76.90)) lazy val graphQLGenerator = project .in(file("graphql-generator")) .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) .settings(resolversSettings) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 66.98)) .settings( libraryDependencies ++= Seq( "io.apibuilder" %% "apibuilder-graphql" % "0.0.10", @@ -166,7 +178,6 @@ lazy val kotlinGenerator = project "org.mockito" % "mockito-core" % mockitoVersion % "test" ) ) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 94.5, ScoverageKeys.coverageFailOnMinimum := true)) lazy val csvGenerator = project .in(file("csv-generator")) @@ -178,7 +189,6 @@ lazy val csvGenerator = project "org.apache.commons" % "commons-csv" % "1.7" ) ) - .settings(Seq(ScoverageKeys.coverageMinimumStmtTotal := 75.67, ScoverageKeys.coverageFailOnMinimum := true)) lazy val postmanGenerator = project .in(file("postman-generator")) @@ -193,7 +203,6 @@ lazy val postmanGenerator = project lazy val commonSettings: Seq[Setting[_]] = Seq( name ~= ("apibuilder-generator-" + _), organization := "io.apibuilder", - ScoverageKeys.coverageFailOnMinimum := true, testOptions += Tests.Argument("-oF"), libraryDependencies ++= Seq( "org.atteo" % "evo-inflector" % "1.2.2", @@ -209,6 +218,10 @@ lazy val commonSettings: Seq[Setting[_]] = Seq( ), libraryDependencies += guice, scalacOptions ++= allScalacOptions, + Test / javaOptions ++= Seq( + "--add-exports=java.base/sun.security.x509=ALL-UNNAMED", + "--add-opens=java.base/sun.security.ssl=ALL-UNNAMED" + ), Compile / doc / sources := Seq.empty, Compile / packageDoc / publishArtifact := false, ) diff --git a/examples/union-of-unions/build.sbt b/examples/union-of-unions/build.sbt index 1a194782..0b64d38d 100644 --- a/examples/union-of-unions/build.sbt +++ b/examples/union-of-unions/build.sbt @@ -2,7 +2,7 @@ name := "apibuilder-union-of-unions" organization := "io.apibuilder.generator" -ThisBuild / scalaVersion := "2.13.8" +ThisBuild / scalaVersion := "2.13.11" lazy val generated = project .in(file("generated")) diff --git a/go-generator/src/main/scala/models/ImportBuilder.scala b/go-generator/src/main/scala/models/ImportBuilder.scala index 1a396767..38f3d176 100644 --- a/go-generator/src/main/scala/models/ImportBuilder.scala +++ b/go-generator/src/main/scala/models/ImportBuilder.scala @@ -40,7 +40,7 @@ private[models] case class ImportBuilder(importMappings: Option[String]) { // Build a list of go imports as we use them so we only import // libraries we actually use - private[this] var importPaths = mutable.ListBuffer[ImportPath]() + private[this] val importPaths = mutable.ListBuffer[ImportPath]() /** * Ensures that this library is being imported, returning the alias diff --git a/java-generator/src/main/scala/models/generator/JavaDatatype.scala b/java-generator/src/main/scala/models/generator/JavaDatatype.scala index eb15d22f..d3215b4f 100644 --- a/java-generator/src/main/scala/models/generator/JavaDatatype.scala +++ b/java-generator/src/main/scala/models/generator/JavaDatatype.scala @@ -1,11 +1,10 @@ package models.generator -import java.util.UUID - -import scala.annotation.nowarn +import lib.{Datatype, Text} import org.joda.time.format.ISODateTimeFormat.dateTimeParser import play.api.libs.json._ -import lib.{Datatype, Text} + +import java.util.UUID sealed trait JavaDatatype { def apidocType: String @@ -25,7 +24,7 @@ sealed trait JavaDatatype { def valueFromString(value: String): String = valueFromJson(Json.parse(value)) - def valueFromJson(@nowarn json: JsValue): String = { + def valueFromJson(json: JsValue): String = { throw new UnsupportedOperationException(s"Unable to create default value for type $name") } } diff --git a/lib/src/main/scala/VersionTag.scala b/lib/src/main/scala/VersionTag.scala index 599eed0f..68c8713e 100644 --- a/lib/src/main/scala/VersionTag.scala +++ b/lib/src/main/scala/VersionTag.scala @@ -64,7 +64,7 @@ case class VersionTag(version: String) extends Ordered[VersionTag] { case 1 => { val pieces = splitOnDot(version) if (pieces.forall(s => VersionTag.isDigit(s))) { - Some((Seq(pieces.last.toInt + 1) ++ pieces.reverse.drop(1)).reverse.mkString(".")) + Some((Seq(pieces.last.toInt + 1).map(_.toString) ++ pieces.reverse.drop(1)).reverse.mkString(".")) } else { None } diff --git a/project/plugins.sbt b/project/plugins.sbt index 2f8ea100..f33bd14c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,6 +7,4 @@ resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releas // Use the Play sbt plugin for Play projects addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.5") -addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "1.9.3") - addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17") diff --git a/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala b/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala index ebba0f5e..0fce34a4 100644 --- a/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala +++ b/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala @@ -1,7 +1,5 @@ package scala.generator -import scala.annotation.nowarn - import scala.models.{Attributes, ResponseConfig} sealed trait ScalaClientMethodConfig { @@ -102,9 +100,9 @@ sealed trait ScalaClientMethodConfig { def asyncTypeConstraint: String = "Sync" - def asyncTypeParam(@nowarn constraint: Option[String] = None): Option[String] = None + def asyncTypeParam(constraint: Option[String] = None): Option[String] = None - def wrappedAsyncType(@nowarn instance: String = ""): Option[String] = None + def wrappedAsyncType(instance: String = ""): Option[String] = None def asyncSuccessInvoke: String = wrappedAsyncType(asyncTypeConstraint).getOrElse(asyncType) + "." + asyncSuccess diff --git a/scala-generator/src/main/scala/models/generator/ScalaDatatype.scala b/scala-generator/src/main/scala/models/generator/ScalaDatatype.scala index 33907e29..7780cb74 100644 --- a/scala-generator/src/main/scala/models/generator/ScalaDatatype.scala +++ b/scala-generator/src/main/scala/models/generator/ScalaDatatype.scala @@ -6,7 +6,6 @@ import lib.Text.{appendSpace, initLowerCase} import play.api.libs.json._ import java.util.UUID -import scala.annotation.nowarn import scala.util.{Failure, Success, Try} sealed trait ScalaDatatype { @@ -42,7 +41,7 @@ sealed trait ScalaDatatype { } } - protected def default(@nowarn json: JsValue): String = { + protected def default(json: JsValue): String = { throw new UnsupportedOperationException(s"default for type ${name}") } diff --git a/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala b/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala index 541550df..0d843996 100644 --- a/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala +++ b/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala @@ -10,7 +10,7 @@ import scala.models.play.Helpers.compareWithoutWhiteSpaces class Play26GeneratorSpec extends AnyFunSpec with Matchers with ScalaCheckPropertyChecks { - implicit val scalacheckConfig = generatorDrivenConfig.copy(sizeRange = 10) + private implicit val scalacheckConfig: PropertyCheckConfiguration = generatorDrivenConfig.copy(sizeRange = 10) it("prependHeader should prepend a header") { forAll { (header: String, contents: String, form: InvocationForm) =>