From e55f99b2d7a2e2c4f5d7f541464c5556c59d3ff0 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:34:30 -0400 Subject: [PATCH 1/8] java17 From 5339508ae68f6a2bd52480bced004c5f5836d5ad Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:34:33 -0400 Subject: [PATCH 2/8] wip --- Dockerfile | 4 ++-- build.sbt | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 085f3b739..8e1104bb3 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 48185a304..23787d55e 100644 --- a/build.sbt +++ b/build.sbt @@ -6,6 +6,8 @@ organization := "io.apibuilder.generator" ThisBuild / scalaVersion := "2.13.8" +ThisBuild / javacOptions ++= Seq("-source", "17", "-target", "17") + lazy val allScalacOptions = Seq( "-deprecation", "-feature", @@ -36,6 +38,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 @@ -63,6 +69,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 @@ -209,6 +219,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, ) From 11c8ec780dc96455b2da145586e71966c7115363 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:44:43 -0400 Subject: [PATCH 3/8] update --- build.sbt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 23787d55e..b43ae9a1d 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ name := "apibuilder-generator" organization := "io.apibuilder.generator" -ThisBuild / scalaVersion := "2.13.8" +ThisBuild / scalaVersion := "2.13.11" ThisBuild / javacOptions ++= Seq("-source", "17", "-target", "17") @@ -54,8 +54,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: _*) @@ -96,7 +96,7 @@ lazy val scalaGenerator = project .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" ) ) @@ -107,7 +107,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" ) ) From c973f79a1b75bbdb24a8d7649007495cf52c5725 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:47:16 -0400 Subject: [PATCH 4/8] wip --- go-generator/src/main/scala/models/ImportBuilder.scala | 2 +- .../src/main/scala/models/generator/JavaDatatype.scala | 9 ++++----- lib/src/main/scala/VersionTag.scala | 2 +- .../scala/models/generator/ScalaClientMethodConfig.scala | 6 ++---- .../src/main/scala/models/generator/ScalaDatatype.scala | 3 +-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/go-generator/src/main/scala/models/ImportBuilder.scala b/go-generator/src/main/scala/models/ImportBuilder.scala index 1a396767d..38f3d176c 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 eb15d22fb..d3215b4f5 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 599eed0f1..68c8713e2 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/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala b/scala-generator/src/main/scala/models/generator/ScalaClientMethodConfig.scala index ebba0f5e2..0fce34a4b 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 33907e299..7780cb74c 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}") } From f7800750341765e69469713e9c7be7a163c85641 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:52:23 -0400 Subject: [PATCH 5/8] wip --- .github/workflows/ci.yml | 4 ++-- .../src/test/scala/models/play/Play26GeneratorSpec.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aff3535b2..2f1de63ac 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 diff --git a/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala b/scala-generator/src/test/scala/models/play/Play26GeneratorSpec.scala index 541550dfb..0d843996d 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) => From 59a5175ba50d2925cf7f400796b814742bec26eb Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:52:34 -0400 Subject: [PATCH 6/8] wip --- examples/union-of-unions/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/union-of-unions/build.sbt b/examples/union-of-unions/build.sbt index 1a1947823..0b64d38d4 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")) From 0ee953f0df948b2f64429fd4bdc9b1ecd344ce5d Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 09:59:33 -0400 Subject: [PATCH 7/8] wip --- build.sbt | 11 ----------- project/plugins.sbt | 2 -- 2 files changed, 13 deletions(-) diff --git a/build.sbt b/build.sbt index b43ae9a1d..45a809bed 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,3 @@ -import scoverage.ScoverageKeys - name := "apibuilder-generator" organization := "io.apibuilder.generator" @@ -80,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", @@ -94,7 +91,6 @@ lazy val scalaGenerator = project .dependsOn(lib, lib % "test->test") .settings(commonSettings: _*) .settings( - Seq(ScoverageKeys.coverageMinimumStmtTotal := 85.4), libraryDependencies ++= Seq( "org.typelevel" %% "cats-core" % "2.10.0", "org.scalameta" %% "scalafmt-core" % "2.3.2" @@ -125,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")) @@ -144,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", @@ -186,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")) @@ -198,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")) @@ -213,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", diff --git a/project/plugins.sbt b/project/plugins.sbt index 2f8ea100b..f33bd14cb 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") From eecda65e2c8d245159b47b81c99388b3ac4d5b1f Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Sun, 8 Oct 2023 10:03:01 -0400 Subject: [PATCH 8/8] wip --- .github/workflows/ci.yml | 2 +- .travis.yml | 2 +- DEVELOPER.md | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f1de63ac..ecf9316f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 77366fb57..847a9c2c6 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 9741960f8..318d69dc7 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -3,7 +3,3 @@ Running sbt > project generator > run - -Code coverage -============= - sbt clean coverage test coverageReport