Hi, I get this error when i run gradlew (gradle ve...
# kotest
t
Hi, I get this error when i run gradlew (gradle version 6.6.1) using io.kotestkotest runner junit5 jvm4.2.3. But it does work with kotest 4.2.0.RC2.
Running the the test in Intellij (no kotest plugin) works with 4.2.3 of kotest but not with gradle…
l
Interesting
How did you setup your gradle?
t
Copy code
plugins {
    id 'org.springframework.boot' version '2.3.3.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'org.jetbrains.kotlin.jvm' version  '1.4.0'
    id "org.jetbrains.kotlin.plugin.allopen" version "1.4.0"
    id 'org.jetbrains.kotlin.plugin.spring' version '1.4.0'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.0'
}

repositories {

    mavenLocal()
    mavenCentral()
    jcenter()

}



version = System.getenv('version') ?: "$project.version"

springBoot {

    mainClassName = 'infotorg.consumer.cnr.AppKt'

}

compileKotlin {

    kotlinOptions {

        freeCompilerArgs = ["-Xjsr305=strict", "-Xopt-in=kotlin.RequiresOptIn"]
        jvmTarget = "11"

    }

}

compileTestKotlin {

    kotlinOptions {

        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "11"

    }

}

test {

    useJUnitPlatform()

}


// This is so we only publish our stubs to artifactory when master is build
tasks.withType(PublishToMavenRepository) {

    onlyIf {
        System.getenv('branchName') == 'master'
    }

}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-configuration-processor'
    implementation 'org.springframework.kafka:spring-kafka'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive:2.3.3.RELEASE'
    implementation 'org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE'

    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC'
    implementation 'org.jetbrains.kotlin:kotlin-reflect'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'

    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.11.2'

    implementation 'com.jayway.jsonpath:json-path:2.4.0'

    implementation 'com.bisnode.response:responsekt:2.0.0'

    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude module: 'junit-vintage-engine'
        exclude module: 'mockito-core'
    }

    testImplementation 'io.kotest:kotest-runner-junit5-jvm:4.2.4'

    testImplementation 'com.ninja-squad:springmockk:2.0.3'
    testImplementation 'io.mockk:mockk:1.10.0'
    testImplementation 'io.rest-assured:spring-mock-mvc:3.3.0'
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.kafka:spring-kafka-test'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9'
    testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo'

}
Just tested with kotest 4.2.4 but the same error…
l
Could you try to invalidate and restart? It seems to me that your gradle is not configuring the
junit5-jvm
bit correctly
Also, could you check your gradle version?
t
Gradlew is 6.6.1 and we have tried it on 3 developer machines and our build server and the all get the same error.
Just did a gradlew -version and got this: ------------------------------------------------------------ Gradle 6.6.1 ------------------------------------------------------------ Build time: 2020-08-25 162912 UTC Revision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3 Kotlin: 1.3.72 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020 JVM: 11.0.2 (Oracle Corporation 11.0.2+9-LTS) OS: Mac OS X 10.15.6 x86_64
Could it be that it’s using Kotlin 1.3.72?
l
Gradle uses that version, I don't believe that's the issue
It still didn't update
I believe it might be the Java version
Could you try using jdk 8 instead of 11?
t
One of our lib is build with jdk 11. But I will try to build a version of that lib with jdk 8. I also think it has to do with java version some how.
l
just to eliminate this possibility. Kotest itself is built with JDK 11
t
Ok. I trying to set our lib to JDK 8 but when i do that and use it from the other project that has kotest it now complains that my lib is still jdk 11…
This is the gradle file for that project:
Copy code
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {

    id("org.jetbrains.kotlin.jvm") version "1.4.0"
    kotlin("plugin.serialization") version "1.4.0-rc"

    // Apply the java-library plugin for API and implementation separation.
    // `java-library`
}

java {

    targetCompatibility = JavaVersion.VERSION_1_8

}


tasks.test {
    useJUnitPlatform()
}

repositories {

    mavenCentral()
    jcenter()
    maven("<https://kotlin.bintray.com/kotlinx>")
}

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "1.8"
    kotlinOptions.apiVersion = "1.4"
}

tasks.withType<Test> {
    useJUnitPlatform()
}

dependencies {

    implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC")
    implementation(kotlin("reflect"))

    testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.2")

}
This is the error I get when using it:
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:compileKotlin’.
Could not resolve all files for configuration ‘:compileClasspath’.
> Could not resolve com.bisnode.responseresponsekt2.0.1-SNAPSHOT. Required by: project : > No matching variant of com.bisnode.responseresponsekt2.0.1-SNAPSHOT:20200828.054422-1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, and its dependencies declared externally, as well as attribute ‘org.jetbrains.kotlin.platform.type’ with value ‘jvm’ but: - Variant ‘apiElements’ capability com.bisnode.responseresponsekt2.0.1-SNAPSHOT declares an API of a library, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.jetbrains.kotlin.platform.type’ with value ‘jvm’: - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8 - Variant ‘runtimeElements’ capability com.bisnode.responseresponsekt2.0.1-SNAPSHOT declares a runtime of a library, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.jetbrains.kotlin.platform.type’ with value ‘jvm’: - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
This is the new gradle for the project with Kotest:
Copy code
plugins {
    id 'org.springframework.boot' version '2.3.3.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'org.jetbrains.kotlin.jvm' version  '1.4.0'
    id "org.jetbrains.kotlin.plugin.allopen" version "1.4.0"
    id 'org.jetbrains.kotlin.plugin.spring' version '1.4.0'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.0'
}

repositories {

    mavenLocal()
    mavenCentral()
    jcenter()

}

java {

    targetCompatibility = JavaVersion.VERSION_1_8

}



version = System.getenv('version') ?: "$project.version"

springBoot {

    mainClassName = 'infotorg.consumer.cnr.AppKt'

}

compileKotlin {

    kotlinOptions {

        freeCompilerArgs = ["-Xjsr305=strict", "-Xopt-in=kotlin.RequiresOptIn"]
        jvmTarget = "1.8"

    }

}

compileTestKotlin {

    kotlinOptions {

        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"

    }

}

test {

    useJUnitPlatform()

}


// This is so we only publish our stubs to artifactory when master is build
tasks.withType(PublishToMavenRepository) {

    onlyIf {
        System.getenv('branchName') == 'master'
    }

}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-configuration-processor'
    implementation 'org.springframework.kafka:spring-kafka'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive:2.3.3.RELEASE'
    implementation 'org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE'

    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC'
    implementation 'org.jetbrains.kotlin:kotlin-reflect'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'

    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.11.2'

    implementation 'com.jayway.jsonpath:json-path:2.4.0'

    implementation 'com.bisnode.response:responsekt:2.0.1-SNAPSHOT'

    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude module: 'junit-vintage-engine'
        exclude module: 'mockito-core'
    }

    testImplementation 'io.kotest:kotest-runner-junit5-jvm:4.2.4'

    testImplementation 'com.ninja-squad:springmockk:2.0.3'
    testImplementation 'io.mockk:mockk:1.10.0'
    testImplementation 'io.rest-assured:spring-mock-mvc:3.3.0'
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.kafka:spring-kafka-test'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9'
    testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo'

}
Thanks very much for helping me with this! 🙂
l
It definitely looks like some JVM shenanigans
Try adding clickt yourself to the build
see if that can clear things up
But I'll drop a ping to @AJ Alt to take a look at this
Maybe that happened to other users of clickt
t
Sorry for the late reply. Yes have tested to add implementation ‘com.github.ajaltclikt2.8.0’ to my project but I still get the same error.
It’s strange that version 4.2.0.RC works but no later versions. And again thanks for looking into this!
If I remember right the 4.2.0.RC uses clikt 2.7.0
l
Ah, I think I got it
It has nothing to do with clikt, it's just unlucky to be the first one declared. Sorry, @AJ Alt
try
Copy code
testImplementation("io.kotest:kotest-runner-junit5:4.2.3")
instead of junit5-jvm
t
Have have done that but the same error.
One observation I tried testImplementation ‘io.kotestkotest runner junit5 jvm4.2.0.RC3’ and that gave me the same error as 4.2.x but in RC3 Gradle complain about “”Could not resolve com.github.ajalt.cliktclikt js2.7.1 but RC2 uses 2.7.0 and everything works.
I tried the testImplementation(“io.kotestkotest runner junit54.2.4”) and running the test from Intellij by right clicking on the test folder. And that works so it just using gradle by it self that does not work.
l
@sam any idea?
s
I have seen it before myself, but cannot remember what it was. Something to do with setting up deps incorrectly.
@thol01 can you list all the deps that have io.kotest in them that are in your gradle files
t
I’ll check.
Used this: gradle -q dependencyInsight --dependency io.kotest --configuration testRuntimeClasspath
s
Did you try adding the non-jvm versions of the deps ?
It's really strange the error you are having, it's gradle saying it can't find a module to match the requirements, but they clearly exist.
t
This is if you run gradle -q dependencyInsight --dependency clikt --configuration testRuntimeClasspath
s
Is this an open source project ?
t
My project? No sorry.
In the clikt.log one can see that clickt is jvm 14. But i think they specified 1.8 compatibility in there build gradle file. Is it that they compiled with 14 but the code is compatible with 1.8?
s
Probably, I mean I have Java 11 and use kotest no problem
Can you post up your current gradle file (as a snippet so it doesn't take up the entire screen) and I will make an empty project with it and see if the same thing happens
t
It work in my project to as long as i stick to 4.2.0.RC2 but later version than that will not work.
One thing that I just saw now is that 4.2.0.RC2 has no dependence on Clikt. Using testImplementation ‘io.kotestkotest runner junit5 jvm4.2.0.RC2’
Found a solution!
Copy code
testImplementation('io.kotest:kotest-runner-junit5-jvm:4.2.4') {
    exclude module: 'clikt'
}
Should have tested this before… sorry!
s
so it is clikt causing the issue ?
If you exclude clikt you won't be able to use the intellij plugin though
t
Yes there is something wrong when clikt is a dependecy. Ahh so I cant use the plugin? The reason I put time into this was that my team what to use the plugin! 😣
s
I've just pushed to master a change that bumps clikt to 3.0.1
they've released a new major version, so hopefully this has "fixed" that issue. we'll find out once it's built and you try the snapshot.
t
I will try that.
s
We'll get it working for you either way 🙂
t
Let me know when I can try.
s
If 3.0.1 of clikt doesn't help, we'll reach out to AJ who writes it. He's a good guy who has contributed to kotest himself.
👍 1
t
BIG thanks for helping me out here! 😀
s
are you on kotlin 1.4 ?
t
Yes
s
clikt 3.0 is 1.4 only so that's ok
What's this
Copy code
com.bisnode.response:responsekt
Also snapshot
4.3.0.664-SNAPSHOT
has been released
t
It our own Kotlin implementation of https://google.github.io/styleguide/jsoncstyleguide.xml we use it as our main payload from all our microservices. It’s Kotlin 1.4 and JDK 11.
s
Ok I can't make it resolve, but I assume it doesn't matter, so I removed it from the thomas project
t
ok
s
So I think we have found the issue, your build file is bringing in 4.1.1 of kotest
I guess something else uses it
Ah yeah you have it twice in your gradle file
t
I do?
s
According to the one you pasted yeah
wait, I think I'm going crazy
t
You are not alone!
s
alright, I've taken your build, added a dummy test, and pushed to that thomas repo
Run
./gradlew check
t
It gives me the same error, but it works for you?
s
yep
actually no, didn't spot this
Copy code
> Task :compileTestKotlin UP-TO-DATE
Errors occurred while build effective model from /home/sam/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-osgi/2.2.10/c926a537af564ec047ec6308df1d0d2a03364a86/jaxb-osgi-2.2.10.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-osgi:2.2.10
t
That error has always been there… not only for this project…
So I get this: Could not resolve com.github.ajalt.cliktclikt js2.8.0. Required by: project : > io.kotestkotest runner junit5 jvm4.2.4 > io.kotestkotest framework engine4.2.4 > io.kotestkotest framework engine jvm4.2.4 > com.github.ajaltclikt2.8.0
My default JDK on my machine is 11.02.
s
then it passes for me
I'm on linux
sam@sam-H310M-A-2-0:~/development/workspace/kotest/thomas$ java -version openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment 18.9 (build 11.0.8+10) OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10, mixed mode)
t
One “big” project I had 2 other developers test it one has windows the other mac (same as me). I also tried it on our build server Bamboo that runs some kind of Linux. All have the same error.
s
I've updated the project to include extra logging
and changed the test to fail so you can see it failing in std out
are you using gradlew ?
or just gradle ?
t
gradlew
Pulled your changes but still the same error.
s
So you've just cloned that project, done gradlew check and it gives you the clikt error ?
t
Yes
s
how strange
t
./gradlew clean build
s
can you nuke your gradle and maven clickt folders
I will do the same
t
Yes
s
It re-downloaded them fine for me
sam@sam-H310M-A-2-0:~/development/workspace/kotest/thomas$ ll ~/.gradle/caches/modules-2/files-2.1/com.github.ajalt/ total 36 drwxrwxr-x 5 sam sam 4096 Sep 10 02:11 ./ drwxrwxr-x 322 sam sam 20480 Sep 10 02:11 ../ drwxrwxr-x 3 sam sam 4096 Sep 10 02:11 clikt/ drwxrwxr-x 3 sam sam 4096 Sep 10 02:11 colormath/ drwxrwxr-x 3 sam sam 4096 Sep 10 02:11 mordant/
I've updated the project to explicitly add the clikt dependency now, to see if that pulls it down
t
I can’t find the clikt lib’s on my computer…
I’ll pull our chanages
s
I guess it makes sense that you can't find it since it won't download for you
👍 1
t
I’ll post the error file, just one minute
Seems like I can’t download the dependency.
s
So it doesn't look like a kotest thing. Lets try one more thing.
can you do a pull and gradlew check
t
Works!
s
that's not good lol
I removed everything but clickt hoping it would still fail and we had the issue narrowed down
t
So just add the dependencies one by one?
s
I guess so. Add them one by one until it fails for you, and then we'll know where to look.
Add kotest first
Copy code
testImplementation 'io.kotest:kotest-runner-junit5-jvm:4.2.4'
t
I’ll do that and let you know
Copy code
testImplementation 'io.kotest:kotest-runner-junit5-jvm:4.2.4'
Works
s
so it's not that then
t
All do the rest and let you know
s
Ok, I'm off to bed, 2:30am here
I'll catch up with you tomorrow to see how things are looking.
t
Sleep well and THANKS!
👍🏻 1
Tested some more and as long as I don’t add any test it will complile BUT when I have a test it gives the error.
Ha a another developer in my team create a super small app as well and as soon as he add a test we get the error. Just to verify that it not my machine.
s
Are you on some weird vpn
Also what's you github username
t
Yes I am on VPN. I will try with it disconnected.
Github username is thol01
Did try without the VPN but the same error. Also upgraded to Kotlin 1.4.10 same error. I tested a project with just testImplementation group: ‘com.github.ajalt’, name: ‘clikt’, version: ‘2.8.0’ and that fails for the same reson.
590 Views