简体   繁体   中英

How I can specify the version of JDK for travis CI

I have the file .travis.yml generated by JHipster and I would like to use adopt open jdk 12 for travis, but I can not set it.

os:
  - linux
services:
  - docker
language: java
matrix:
  include:
    - env:
        - TRAVIS_JDK=adopt@1.12
        - NODE_VERSION=12.13.1
cache:
  directories:
    - node
    - node_modules
    - $HOME/.m2
env:
  global:
    - SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
    - SPRING_JPA_SHOW_SQL=false
    - JHI_DISABLE_WEBPACK_LOGS=true
    - NG_CLI_ANALYTICS="false"
    - MAVEN_USER_HOME=$HOME/.m2/repository/
script:
  - chmod +x mvnw
  - java -version
  - ./mvnw -ntp checkstyle:check
  - ./mvnw -ntp clean verify
  - ./mvnw -ntp verify -Pprod -DskipTests
  - ./mvnw -ntp com.heroku.sdk:heroku-maven-plugin:2.0.5:deploy -DskipTests -Pprod -Dheroku.buildpacks=heroku/jvm -Dheroku.appName=kacetal-library-stock
notifications:
  webhooks:
    on_success: change  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: false     # default: false

Update alternative doesn't work, I always see error: resetting java alternatives and second error update-alternatives: error: no alternatives for mozilla-javaplugin.so

And jdk is always OpenJDK 11 openjdk version "11.0.2" 2019-01-15

Add below matrix with adopt version, also add JAVA_HOME correctly.

os:
  - linux
services:
  - docker
language: java

cache:
  directories:
    - node
    - node_modules
    - $HOME/.m2
env:
  global:
    - SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
    - SPRING_JPA_SHOW_SQL=false
    - JHI_DISABLE_WEBPACK_LOGS=true
    - NG_CLI_ANALYTICS="false"
    - MAVEN_USER_HOME=$HOME/.m2/repository/
    - NODE_VERSION=12.13.1
  matrix:
  - TRAVIS_JDK=adopt-openj9@1.12
  - TRAVIS_JDK=adopt-openj9@1.11.0-4

script:
  - chmod +x mvnw
  - java -version
  - ./mvnw -ntp checkstyle:check
  - ./mvnw -ntp clean verify
  - ./mvnw -ntp verify -Pprod -DskipTests
  - ./mvnw -ntp com.heroku.sdk:heroku-maven-plugin:2.0.5:deploy -DskipTests -Pprod -Dheroku.buildpacks=heroku/jvm -Dheroku.appName=kacetal-library-stock
notifications:
  webhooks:
    on_success: change  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: false     # default: false

This helped me:

https://docs.travis-ci.com/user/languages/java/#using-java-10-and-later

Looks like you can specify 1 or more JDK versions in the .travis.yml file:

jdk:
  - oraclejdk8
  - oraclejdk11
  - openjdk10
  - openjdk11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM