Skip to content

Commit

Permalink
Restore java 8 support (#759)
Browse files Browse the repository at this point in the history
* restore java 8 support

* revert logback version

* fix publishing

* fix upload to s3

* cleanup

* add comment about native-server subproject
  • Loading branch information
micossow authored Nov 9, 2022
1 parent 0dbe63a commit 9efe330
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 32 deletions.
65 changes: 42 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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 }}
Expand All @@ -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"
20 changes: 12 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -70,7 +70,7 @@ val buildSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq(
ScmInfo(url("https://github.com/softwaremill/elasticmq"), "scm:[email protected]:softwaremill/elasticmq.git")
),
scalaVersion := resolvedScalaVersion,
scalacOptions += "-Xasync",
scalacOptions ++= Seq("-Xasync", "-target:jvm-1.8"),
libraryDependencies += scalaXml,
dependencyOverrides := akka25Overrides,
parallelExecution := false,
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/elasticmq/NodeAddress.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 9efe330

Please sign in to comment.