-3

Getting the below error while running functional test cases after upgrading to jdk10.

Could not target platform: 'Java SE 10' using tool chain: 'JDK 8 (1.8)'.

build.gradle

import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import java.text.SimpleDateFormat;
import org.apache.tools.ant.taskdefs.condition.Os


buildscript {
    ext {
        springBootVersion = '2.0.1.RELEASE'
    }
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
        url 'https://repo.spring.io/libs-release'
        url 'https://repo.spring.io/release'
        url 'https://repo.spring.io/snapshot'
        url 'https://repo.spring.io/milestone'
        url 'https://repo.spring.io/libs-milestone'
        }

        maven{
            url='https://plugins.gradle.org/m2/'
        }
        mavenLocal()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath ("com.bmuschko:gradle-docker-plugin:3.2.1")
        classpath ("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5")
        classpath "gradle.plugin.au.com.dius:pact-jvm-provider-gradle_2.12:3.6.0-rc.0"
        classpath ("com.moowork.gradle:gradle-node-plugin:1.2.0")

    }
}

plugins {
    id "java"
    id "au.com.dius.pact" version "3.6.0-rc.0"
    id "com.gorylenko.gradle-git-properties" version "1.4.17"
    id "de.undercouch.download" version "3.4.2"

}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'org.sonarqube'
apply plugin: 'au.com.dius.pact'
apply plugin: 'scala'


group = 'com'
sourceCompatibility = 10

ext {
    springCloudVersion = 'Finchley.RELEASE'
}

//start of integration tests changes
sourceSets {
    integrationTest {
        java {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('test/functional-api/java')
        }
        resources.srcDir file('test/functional-api/resources')
    }
}

configurations {
    integrationTestCompile.extendsFrom testCompile
    integrationTestRuntime.extendsFrom testRuntime
}
//end of integration tests changes
dependencies {
    //web (Tomcat, Logging, Rest)
    compile group: 'org.springframework.boot',   name: 'spring-boot-starter-web'
    // Redis
    //compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis'
    //Mongo Starter
    compile group: 'org.springframework.boot', name:'spring-boot-starter-data-mongodb'

    // Configuration processor - To Generate MetaData Files. The files are designed to let  developers offer “code completion� as users are working with application.properties
    compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
    // Actuator - Monitoring
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'

    //Sleuth - Tracing
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-sleuth'
    //Hystrix - Circuit Breaker
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix'
    // Hystrix - Dashboard
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix-dashboard'
    // Thymeleaf
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
    //Voltage
    // Device Detection

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-cassandra', version:'2.0.4.RELEASE'  
    compile group: 'com.google.guava', name: 'guava', version: '23.2-jre'
    compile('com.google.code.gson:gson:2.8.0')
    compile('org.json:json:20170516')

    //Swagger
    compile group: 'io.springfox', name: 'springfox-swagger2', version:'2.8.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version:'2.8.0'

    //jkd10 fixes
    compile group: 'javax.xml.bind',name: 'jaxb-api', version:'2.3.0'
    compile group: 'javax.xml.soap', name: 'javax.xml.soap-api', version:'1.3.5'
    compile group: 'com.sun.xml.messaging.saaj', name: 'saaj-impl', version:'1.4.0'
    compile group: 'javax.activation', name: 'activation', version: '1.1.1'
    compile group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version:'2.3.0.1'

    //Lombok
    compileOnly group: 'org.projectlombok', name: 'lombok',version:'1.18.2'
    //compile group: 'io.smartcat', name: 'cassandra-diagnostics-connector21', version: '1.4.10'
    //Testing
    //Spring  WS Test
    testCompile group: 'org.springframework.ws', name: 'spring-ws-test', version:'2.4.0.RELEASE'

    testCompile('org.springframework.boot:spring-boot-starter-test'){
        exclude group: "com.vaadin.external.google", module:"android-json"
    }
    //Pact
    testCompile group: 'au.com.dius', name: 'pact-jvm-provider-gradle_2.12', version: '3.5.7'
    testCompile group: 'au.com.dius', name:'pact-jvm-provider-junit_2.12',version:'3.5.13'
    testCompile group: 'au.com.dius', name:'pact-jvm-consumer-junit_2.12', version:'3.5.13'

    //Embedded mongo for testing
    testCompile group: 'de.flapdoodle.embed', name:'de.flapdoodle.embed.mongo',version:'2.0.1'
    //testCompile group: 'cz.jirutka.spring', name: 'embedmongo-spring', version: '1.1'

    compile group: 'info.cukes', name: 'cucumber-jvm', version: '1.2.5'
    testCompile group: 'io.cucumber', name: 'cucumber-junit', version: '3.0.2'
    compile group: 'io.cucumber', name: 'cucumber-spring', version: '3.0.2'

    testCompile('org.cassandraunit:cassandra-unit-spring:3.5.0.1'){
        exclude group: 'org.cassandraunit', module: 'cassandra-unit'
    }
    // https://mvnrepository.com/artifact/org.cassandraunit/cassandra-unit-shaded
    compile group: 'org.cassandraunit', name: 'cassandra-unit-shaded', version: '3.5.0.1'
    // https://mvnrepository.com/artifact/org.hectorclient/hector-core
    compile group: 'org.hectorclient', name: 'hector-core', version: '2.0-0'
    compile group: 'org.apache.cassandra', name: 'cassandra-all', version: '3.11.3'
    integrationTestCompile group: 'org.springframework.ws', name: 'spring-ws-test', version:'2.4.0.RELEASE' //changes for integration tests
    integrationTestCompile("org.springframework.boot:spring-boot-starter-test"){ //changes for integration tests
        exclude group: "com.vaadin.external.google", module:"android-json"
    }
    //integrationTestCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5' //changes for integration tests
    //integrationTestCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5' //changes for integration tests

}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }

}

test {
    //ignoreFailures = true
    reports.junitXml.enabled = false
    reports.html.enabled = true
    testLogging {
        exceptionFormat = 'full'
    }
    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        maxHeapSize = '2048m'
        minHeapSize = '1024m'
        //classDumpDir = file("$buildDir/jacoco/classpathdumps")
    }
}
jacocoTestReport {
    group = "Reporting"
    reports {
        xml.enabled true
        csv.enabled false
        html.destination "${buildDir}/reports/coverage"
    }
    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it,
                    exclude: [
                                '**/config*',
                                '**/coupons/TextToClipApplication*',
                                '**/bean/*Request*',
                                '**/bean/*Response*',
                    ])
        })
    }
}
test.finalizedBy jacocoTestReport

jacoco {
    toolVersion = "0.8.2"
    reportsDir = file("$buildDir/customJacocoReportDir")
}

//start of changes for integration tests
task apifunctionaltest(type: Test) {
    systemProperty "integrationurl", System.getProperty("integrationurl")
    reports.junitXml.enabled = false
    reports.html.enabled = true
    testLogging {
        exceptionFormat = 'full'
    }
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
    outputs.upToDateWhen { false }
    reports.html.destination = file("${reporting.baseDir}/${name}")
}
//end of changes for integration tests

We are using cucumber to test it. Same code is working in local using gradle, but not working in server. Anyone faced the same problem ?

Parthiban
  • 527
  • 2
  • 13
  • 24
  • 1
    You need to add details. What tool is giving you this error? What tools are you using to run your test cases? – Erwin Bolwidt Sep 26 '18 at 08:20
  • From what I can see, it is the version issue. (Your framework and Java 10 compatibility issue). You need to upgrade the wrapper of your framework: upgrade version of your framework – Afaq Ahmed Khan Sep 26 '18 at 08:24
  • 2
    20 fps: no point in laughing at the OP. Downvote, close vote, give a helpful comment. Anything else is no longer *welcome* here. – GhostCat Sep 26 '18 at 08:33
  • Please read [mcve] and enhance your question accordingly. – GhostCat Sep 26 '18 at 08:34
  • Thanks everyone for suggestions. Added more details to the question. – Parthiban Sep 26 '18 at 08:46
  • 1
    We do already have [Could not target platform: 'Java SE 9' using tool chain: 'JDK 8 (1.8)'](https://stackoverflow.com/q/47500674/2711488) and [Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7)'](https://stackoverflow.com/q/43995886/2711488) and the answer each time is “`JAVA_HOME`”. Did you check `JAVA_HOME`? – Holger Sep 26 '18 at 09:33

1 Answers1

0

Thanks everyone. Issue for us is build server has been using jdk8. Now it is resolved after changing the build template to jdk10.

Parthiban
  • 527
  • 2
  • 13
  • 24