From 28416776f62d7457cf90f93f71a7479a54430923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Becker?= Date: Fri, 23 Mar 2018 14:21:44 +0100 Subject: [PATCH 1/2] fixed Java version check in bash template and added test --- .../packager/archetypes/scripts/bash-template | 26 ++++++++++------ src/sbt-test/docker/jdk-versions/build.sbt | 31 +++++++++++++++++++ .../jdk10/src/main/scala/Hello.scala | 3 ++ .../jdk8/src/main/scala/Hello.scala | 3 ++ .../jdk9/src/main/scala/Hello.scala | 3 ++ .../docker/jdk-versions/project/plugins.sbt | 2 ++ src/sbt-test/docker/jdk-versions/test | 9 ++++++ 7 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 src/sbt-test/docker/jdk-versions/build.sbt create mode 100644 src/sbt-test/docker/jdk-versions/jdk10/src/main/scala/Hello.scala create mode 100644 src/sbt-test/docker/jdk-versions/jdk8/src/main/scala/Hello.scala create mode 100644 src/sbt-test/docker/jdk-versions/jdk9/src/main/scala/Hello.scala create mode 100644 src/sbt-test/docker/jdk-versions/project/plugins.sbt create mode 100644 src/sbt-test/docker/jdk-versions/test diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template index 72fe27b24..a8c448b25 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template @@ -276,16 +276,22 @@ java_version_check() { echo Please go to http://www.java.com/getjava/ and download echo exit 1 - elif [[ ! "$java_version" > "1.6" ]]; then - echo - echo The java installation you have is not up to date - echo $app_name requires at least version 1.6+, you have - echo version $java_version - echo - echo Please go to http://www.java.com/getjava/ and download - echo a valid Java Runtime and install before running $app_name. - echo - exit 1 + else + local major=$(echo "$java_version" | cut -d'.' -f1) + if [[ "$major" -eq "1" ]]; then + local major=$(echo "$java_version" | cut -d'.' -f2) + fi + if [[ "$major" -lt "6" ]]; then + echo + echo The java installation you have is not up to date + echo $app_name requires at least version 1.6+, you have + echo version $java_version + echo + echo Please go to http://www.java.com/getjava/ and download + echo a valid Java Runtime and install before running $app_name. + echo + exit 1 + fi fi } diff --git a/src/sbt-test/docker/jdk-versions/build.sbt b/src/sbt-test/docker/jdk-versions/build.sbt new file mode 100644 index 000000000..f2aff0a8b --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/build.sbt @@ -0,0 +1,31 @@ +val basename = "jdk-versions" + +scalacOptions in ThisBuild := Seq("-target:jvm-1.8") + +lazy val `jdk8` = project + .in(file("jdk8")) + .enablePlugins(JavaAppPackaging) + .settings( + name := basename + "-8", + dockerBaseImage := "openjdk:8u162-jre", + dockerBuildOptions := dockerBuildOptions.value ++ Seq("-t", "jdk-versions:8") + ) + +lazy val `jdk9` = project + .in(file("jdk9")) + .enablePlugins(JavaAppPackaging) + .settings( + name := basename + "-9", + dockerBaseImage := "openjdk:9.0.4-jre", + dockerBuildOptions := dockerBuildOptions.value ++ Seq("-t", "jdk-versions:9") + ) + +lazy val `jdk10` = project + .in(file("jdk10")) + .enablePlugins(JavaAppPackaging) + .settings( + name := basename + "-10", + dockerBaseImage := "openjdk:10-jre", + dockerBuildOptions := dockerBuildOptions.value ++ Seq("-t", "jdk-versions:10") + ) + diff --git a/src/sbt-test/docker/jdk-versions/jdk10/src/main/scala/Hello.scala b/src/sbt-test/docker/jdk-versions/jdk10/src/main/scala/Hello.scala new file mode 100644 index 000000000..acd57d1be --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/jdk10/src/main/scala/Hello.scala @@ -0,0 +1,3 @@ +object Hello extends App { + println("Hello JDK10!") +} diff --git a/src/sbt-test/docker/jdk-versions/jdk8/src/main/scala/Hello.scala b/src/sbt-test/docker/jdk-versions/jdk8/src/main/scala/Hello.scala new file mode 100644 index 000000000..31ab48c39 --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/jdk8/src/main/scala/Hello.scala @@ -0,0 +1,3 @@ +object Hello extends App { + println("Hello JDK8!") +} diff --git a/src/sbt-test/docker/jdk-versions/jdk9/src/main/scala/Hello.scala b/src/sbt-test/docker/jdk-versions/jdk9/src/main/scala/Hello.scala new file mode 100644 index 000000000..d79f58471 --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/jdk9/src/main/scala/Hello.scala @@ -0,0 +1,3 @@ +object Hello extends App { + println("Hello JDK9!") +} diff --git a/src/sbt-test/docker/jdk-versions/project/plugins.sbt b/src/sbt-test/docker/jdk-versions/project/plugins.sbt new file mode 100644 index 000000000..16c9ff010 --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) + diff --git a/src/sbt-test/docker/jdk-versions/test b/src/sbt-test/docker/jdk-versions/test new file mode 100644 index 000000000..b15c9f7e5 --- /dev/null +++ b/src/sbt-test/docker/jdk-versions/test @@ -0,0 +1,9 @@ +> project jdk8 +> docker:publishLocal +$ exec bash -c 'docker run --rm jdk-versions:8 | grep -q "Hello JDK8!"' +> project jdk9 +> docker:publishLocal +$ exec bash -c 'docker run --rm jdk-versions:9 | grep -q "Hello JDK9!"' +> project jdk10 +> docker:publishLocal +$ exec bash -c 'docker run --rm jdk-versions:10 | grep -q "Hello JDK10!"' From a39af3147b3c3be9acaeaa2dfe7d670501a39fdf Mon Sep 17 00:00:00 2001 From: Juergen Becker Date: Fri, 23 Mar 2018 20:36:11 +0100 Subject: [PATCH 2/2] fixed scalacOptions scoping for scaladoc --- src/sbt-test/docker/jdk-versions/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbt-test/docker/jdk-versions/build.sbt b/src/sbt-test/docker/jdk-versions/build.sbt index f2aff0a8b..acee20045 100644 --- a/src/sbt-test/docker/jdk-versions/build.sbt +++ b/src/sbt-test/docker/jdk-versions/build.sbt @@ -1,6 +1,6 @@ val basename = "jdk-versions" -scalacOptions in ThisBuild := Seq("-target:jvm-1.8") +scalacOptions in ThisBuild in (Compile, compile) := Seq("-target:jvm-1.8") lazy val `jdk8` = project .in(file("jdk8"))