From 9efe33048d1a1ad37eafd895d5a38ac2e5fb1b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ossowski?= <623488+micossow@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:33:03 +0100 Subject: [PATCH] Restore java 8 support (#759) * restore java 8 support * revert logback version * fix publishing * fix upload to s3 * cleanup * add comment about native-server subproject --- .github/workflows/ci.yml | 65 ++++++++++++------- build.sbt | 20 +++--- .../scala/org/elasticmq/NodeAddress.scala | 2 +- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1d0cb678..f48c8a5ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: 11 + java-version: 8 - name: Cache SBT id: cache-sbt @@ -35,7 +35,7 @@ jobs: - name: Run tests id: run-tests - run: SCALA_MAJOR_VERSION=${{ env.scala }} sbt test + run: SCALA_MAJOR_VERSION=${{ env.scala }} sbt root/test ci-2-13: # run on external PRs, but not on internal PRs since those will be run by push to branch @@ -52,7 +52,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: 11 + java-version: 8 - name: Cache SBT id: cache-sbt @@ -66,7 +66,7 @@ jobs: - name: Run tests id: run-tests - run: SCALA_MAJOR_VERSION=${{ env.scala }} sbt test + run: SCALA_MAJOR_VERSION=${{ env.scala }} sbt root/test ci-docker: # run on external PRs, but not on internal PRs since those will be run by push to branch @@ -104,8 +104,7 @@ jobs: - name: Build native docker image run: sbt "project nativeServer; assembly; GraalVMNativeImage / packageBin; Docker / publishLocal" - publish: - name: Publish release + publish-jar: needs: [ci-2-12, ci-2-13, ci-docker] if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-20.04 @@ -117,7 +116,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: 11 + java-version: 8 - name: Cache sbt uses: actions/cache@v2 @@ -128,9 +127,6 @@ jobs: ~/.coursier key: ${{ runner.os }}-sbt-release-${{ hashFiles('**/build.sbt') }} - - name: Compile - run: sbt compile - - name: Publish artifacts run: sbt ci-release env: @@ -139,20 +135,8 @@ jobs: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Publish JVM docker image - run: sbt "project server; assembly; Docker / publish" - - - name: Publish JVM native docker image - run: sbt "project nativeServer; assembly; GraalVMNativeImage / packageBin; Docker / publish" - - name: Upload to S3 - run: sbt "server / s3Upload" + run: sbt "project server; assembly; s3Upload" env: S3_USER: ${{ secrets.S3_USER }} S3_PASSWORD: ${{ secrets.S3_PASSWORD }} @@ -174,3 +158,38 @@ jobs: version: "v${{ env.VERSION }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-docker: + needs: [ci-2-12, ci-2-13, ci-docker] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 11 + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier + key: ${{ runner.os }}-sbt-release-${{ hashFiles('**/build.sbt') }} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish JVM docker image + run: sbt "project server; assembly; Docker / publish" + + - name: Publish JVM native docker image + run: sbt "project nativeServer; assembly; GraalVMNativeImage / packageBin; Docker / publish" diff --git a/build.sbt b/build.sbt index 965cbb3ba..503d3cdd7 100644 --- a/build.sbt +++ b/build.sbt @@ -32,7 +32,7 @@ val pureConfig = "com.github.pureconfig" %% "pureconfig" % "0.17.2" val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "2.1.0" val scalalogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5" -val logback = "ch.qos.logback" % "logback-classic" % "1.4.4" +val logback = "ch.qos.logback" % "logback-classic" % "1.3.4" val jclOverSlf4j = "org.slf4j" % "jcl-over-slf4j" % "2.0.3" // needed form amazon java sdk val scalatest = "org.scalatest" %% "scalatest" % "3.2.14" @@ -70,7 +70,7 @@ val buildSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq( ScmInfo(url("https://github.com/softwaremill/elasticmq"), "scm:git@github.com:softwaremill/elasticmq.git") ), scalaVersion := resolvedScalaVersion, - scalacOptions += "-Xasync", + scalacOptions ++= Seq("-Xasync", "-target:jvm-1.8"), libraryDependencies += scalaXml, dependencyOverrides := akka25Overrides, parallelExecution := false, @@ -89,13 +89,15 @@ val s3Upload = TaskKey[PutObjectResult]("s3-upload", "Uploads files to an S3 buc lazy val root: Project = (project in file(".")) .enablePlugins(GitVersioning) .settings(buildSettings) - .settings(name := "elasticmq-root", publishArtifact := false) - .aggregate(commonTest, core, rest, persistence, server, nativeServer, ui) + .settings(name := "elasticmq-root", publish / skip := true) + // we want to build the main jar using java 8, but native-server requires java 11, so it's built separately + // native-server project is only used for building docker with graalvm native image + .aggregate(commonTest, core, rest, persistence, server, ui) lazy val commonTest: Project = (project in file("common-test")) .settings(buildSettings) .settings(name := "elasticmq-common-test") - .settings(Seq(libraryDependencies ++= Seq(scalatest, awaitility, logback), publishArtifact := false)) + .settings(Seq(libraryDependencies ++= Seq(scalatest, awaitility, logback), publish / skip := true)) lazy val core: Project = (project in file("core")) .settings(buildSettings) @@ -185,7 +187,7 @@ lazy val restSqsTestingAmazonJavaSdk: Project = Seq( name := "elasticmq-rest-sqs-testing-amazon-java-sdk", libraryDependencies ++= Seq(amazonJavaSdkSqs, jclOverSlf4j) ++ common, - publishArtifact := false + publish / skip := true ) ) .dependsOn(restSqs % "test->test", persistenceFile % "test", persistenceSql % "test") @@ -268,6 +270,7 @@ lazy val nativeServer: Project = (project in file("native-server")) libraryDependencies ++= Seq( "org.graalvm.nativeimage" % "svm" % graalVmVersion % "compile-internal" ), + publish / skip := true, // configures sbt-native-packager to build app using dockerized graalvm // docker image source: https://github.com/graalvm/container/pkgs/container/graalvm-ce/versions (GraalVMNativeImage / containerBuildImage) := GraalVMNativeImagePlugin @@ -344,7 +347,7 @@ lazy val performanceTests: Project = (project in file("performance-tests")) Seq( name := "elasticmq-performance-tests", libraryDependencies ++= Seq(amazonJavaSdkSqs, jclOverSlf4j, logback) ++ common, - publishArtifact := false + publish / skip := true ) ) .dependsOn(core, restSqs, commonTest % "test") @@ -407,7 +410,8 @@ lazy val ui = (project in file("ui")) (Compile / compile).value }, cleanFiles += baseDirectory.value / "build", - Compile / unmanagedResourceDirectories += baseDirectory.value / "build" + Compile / unmanagedResourceDirectories += baseDirectory.value / "build", + publish / skip := true ) def haltOnCmdResultError(result: Int) { diff --git a/core/src/main/scala/org/elasticmq/NodeAddress.scala b/core/src/main/scala/org/elasticmq/NodeAddress.scala index 334e0dae5..860dcab93 100644 --- a/core/src/main/scala/org/elasticmq/NodeAddress.scala +++ b/core/src/main/scala/org/elasticmq/NodeAddress.scala @@ -10,5 +10,5 @@ case class NodeAddress( def fullAddress: String = protocol + "://" + hostAndPort + suffix def isWildcard: Boolean = host == "*" def contextPathStripped: String = contextPath.stripPrefix("/").stripSuffix("/") - def suffix = if (contextPath.isBlank) "" else "/" + contextPathStripped + def suffix: String = if (contextPath.trim.isEmpty) "" else "/" + contextPathStripped }