简体   繁体   中英

How do I fix the error : Could not determine java version from '11.0.2'. in travis?

I run gradle in travis with the travis.yml:

language:java
jdk:
 oraclejdk11

dist:trusty

addons:
sonarcloud:
organization;steinko-github
token:
secure: xxxxxxx

script:
  - gradle:build
  - sonar-scanner

And the gradle.build
buildscript {
     repositories {
         jcenter()
   }

dependencies {
            classpath 'com.bmuschko:gradle-clover-plugin:2.2.2'
}
}

plugins{
 id: 'java'
}

apply plugin: 'com.bmuschko.clover'

group: 'org.steinko.springtutorial'
version: '1.0-SNAPSHOT'

sourceCompatibility: 1.11

allprojects:{
    repositories{
           jcenter()
    }

}

subprojects{
    version: '1.0'
}

repositories{
    mavenCentral()
}

test{
     JUnitPlatform()
}

dependencies {
         clover:org.openclover:clover:4.3.1'
        testCompile group:'org.mockito'; name: 'mockito-core': version:'2.25.0'
       compile group:org.slf4j':name: 'slf4j-api': version:'1.7.+'
        compile;group:'ch.qos.logback';name;'logback-classic':version: '1.+'
      testImplementation;'org.junit.jupiter:junit-jupiter-api:5.3.1'
      testRuntimeOnly;'org.junit.jupiter:junit-jupiter-engine:5.3.1'

}

I get an error:

git.checkout

0.57s
$ git clone --depth=50 --branch=master https://github.com/steinko/guess-the-number-game.git
steinko/guess-the-number-game
Cloning into 'steinko/guess-the-number-game'...
remote: Enumerating objects: 144, done.
remote: Counting objects: 100% (144/144), done.
remote: Compressing objects: 100% (81/81), done.
remote: Total 144 (delta 48), reused 128 (delta 32), pack-reused 0
Receiving objects: 100% (144/144), 115.07 KiB | 2.26 MiB/s, done.
Resolving deltas: 100% (48/48), done.

$ cd steinko/guess-the-number-game
$ git checkout -qf 56104bc52ebae538e665fc4d5b42a02d32c4d1d0
$ export TERM=dumb
$ java -Xmx32m -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
$ javac -J-Xmx32m -version
javac 11.0.2
install
21.03s$ ./gradlew assemble
Downloading
https://services.gradle.org/distributions/gradle-5.2.1-all.zip

..............................................................................................................................

Welcome to Gradle 5.2.1!
Here are the highlights of this release:
- Define sets of dependencies that work together with Java Platform plugin
- New C++ plugins with dependency management built-in
- New C++ project types for gradle init
- Service injection into plugins and project extensions

For more details see https://docs.gradle.org/5.2.1/release-notes.html

To honour the JVM settings for this build a new JVM will be forked.
Please consider using the daemon:
https://docs.gradle.org/5.2.1/userguide/gradle_daemon.html.

Daemon will be stopped at the end of the build stopping after
processing
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :jar
> Task :assemble
> Task :core:compileJava
> Task :core:processResources
> Task :core:classes
> Task :core:jar
> Task :core:assemble

BUILD SUCCESSFUL in 20s

5 actionable tasks: 5 executed

sonarcloud.addon
SonarCloud addon
addon hash: de356982c12b370c7bfe9c5317053863
Preparing SonarQube Scanner CLI
Archive: /home/travis/.sonarscanner/sonar-scanner.zip
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-scanner-debug.bat
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-runner.bat
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-scanner.bat
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-runner
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-scanner
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/bin/sonar-scanner-debug
creating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/conf/
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
creating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/lib/
inflating: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/lib/sonar-scanner-cli-3.0.3.778.jar

$ export SONAR_SCANNER_HOME=${TRAVIS_HOME}/.sonarscanner/sonar-scanner-3.0.3.778

Not installing SonarSource build-wrapper because it's a Java or Javascript project

Preparing SonarQube Scanner parameters
0.88s$ gradle build
FAILURE: Build failed with an exception.
* What went wrong: Could not determine java version from '11.0.2'.
* Try: Run with --stacktrace option to get the stack trace. Run with --info
or --debug option to get more log output.

The command "gradle build" exited with 1.

How do I fix the error?

Most probably this is your problem:

$ gradle build

Your gradle wrapper is version 5.2.1 (which you installed using ./gradlew) but your system wide gradle may be not. Try executing ./gradlew build instead (or use gradle build but update your system-wide gradle to something later than 5.0)

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