Skip to content

Commit

Permalink
Upgrade to Java 17 (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek authored Oct 8, 2023
1 parent da7e63a commit 96bd1c3
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ Running
sbt
> project generator
> run

Code coverage
=============
sbt clean coverage test coverageReport
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
45 changes: 29 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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: _*)
Expand All @@ -63,14 +67,17 @@ 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
.in(file("java-aws-lambda-pojos"))
.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",
Expand All @@ -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"
)
)
Expand All @@ -97,21 +103,29 @@ 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"
)
)

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"))
Expand All @@ -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",
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand All @@ -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",
Expand All @@ -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,
)
2 changes: 1 addition & 1 deletion examples/union-of-unions/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion go-generator/src/main/scala/models/ImportBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/scala/VersionTag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package scala.generator

import scala.annotation.nowarn

import scala.models.{Attributes, ResponseConfig}

sealed trait ScalaClientMethodConfig {
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 96bd1c3

Please sign in to comment.