Skip to content

Use install-jdk.sh for AdoptOpenJDK #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
language: scala

# This sets $TRAVIS_JDK_VERSION which is used, in turn, to get a
# version of AdoptOpenJDK with the install-jdk.sh command.
jdk:
- openjdk8
- openjdk11

scala:
- 0.18.1-RC1
- 2.12.10
- 2.13.1

env:
- SCALAJS_VERSION= ADOPTOPENJDK=8
- SCALAJS_VERSION=0.6.31 ADOPTOPENJDK=8
- SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8
- SCALAJS_VERSION= ADOPTOPENJDK=11
# The empty SCALAJS_VERSION will only compile for the JVM
- SCALAJS_VERSION=
- SCALAJS_VERSION=0.6.31
- SCALAJS_VERSION=1.0.0-M8

matrix:
exclude:
- jdk: openjdk11
env: SCALAJS_VERSION=0.6.29
- jdk: openjdk11
env: SCALAJS_VERSION=1.0.0-M8
- scala: 0.18.1-RC1
env: SCALAJS_VERSION=0.6.31 ADOPTOPENJDK=8
env: SCALAJS_VERSION=0.6.31
- scala: 0.18.1-RC1
env: SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8

before_install:
# adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation
- "[[ -d $HOME/.sdkman/bin ]] || rm -rf $HOME/.sdkman/"
- curl -sL https://get.sdkman.io | bash
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
- source "$HOME/.sdkman/bin/sdkman-init.sh"
env: SCALAJS_VERSION=1.0.0-M8

install:
- sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1)
- unset JAVA_HOME
- export JAVA_HOME=$HOME/$TRAVIS_JDK_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is JAVA_HOME necessary here? I avoid it because having JAVA_HOME causes subtle difference in the way sbt behaves with Java code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm just following directions:

https://docs.travis-ci.com/user/languages/java/#switching-jdks-to-java-10-and-up-within-one-job

I presume these incantations are needed because how install-jdk.sh works, but I don't know.

- install-jdk.sh --url "https://api.adoptopenjdk.net/v2/binary/releases/$TRAVIS_JDK_VERSION?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&heap_size=normal&type=jdk" --target $JAVA_HOME
- export PATH=$JAVA_HOME/bin:$PATH
- java -Xmx32m -version
- git fetch --tags # get all tags for sbt-dynver

Expand All @@ -42,5 +46,4 @@ cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt
- $HOME/.sdkman
- $HOME/.cache/coursier
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e

# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
isReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.1[234]\..*$ ]]; then
if [[ "$TRAVIS_JDK_VERSION" == "openjdk8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.1[234]\..*$ ]]; then
true
else
false
Expand All @@ -25,7 +25,7 @@ isReleaseJob() {

# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases
isTagScalaReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
if [[ "$TRAVIS_JDK_VERSION" == "openjdk8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
true
else
false
Expand All @@ -46,7 +46,7 @@ if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
if [[ "$tagScalaVer" == "" ]]; then
if ! isReleaseJob; then
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
echo "Not releasing on Java ${TRAVIS_JDK_VERSION#openjdk} with Scala $TRAVIS_SCALA_VERSION"
exit 0
fi
else
Expand Down