Emil Kantis
06/29/2022, 10:30 PMEmil Kantis
06/29/2022, 10:35 PMjvm {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
but it doesn't seem to set the java target of the outgoing variant (at least not when it's used in a composite build)Emil Kantis
06/29/2022, 10:41 PMapiElements
and jvmApiElements
due to:
> The consumer was configured to find an API of a library compatible with Java 17, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kotest:kotest-framework:kotest-framework-api:
- apiElements
- jvmApiElements
All of them match the consumer attributes:
- Variant 'apiElements' capability io.kotest:kotest-framework-api:5.4.0-LOCAL declares an API of a library compatible with Java 17, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
- Variant 'jvmApiElements' capability io.kotest:kotest-framework-api:5.4.0-LOCAL declares an API of a library, packaged as a jar, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 17)
Emil Kantis
06/29/2022, 10:44 PMruntimeElements
vs jvmRuntimeElements
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
> The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kotest:kotest-runner:kotest-runner-junit5:
- jvmRuntimeElements
- runtimeElements
All of them match the consumer attributes:
- Variant 'jvmRuntimeElements' capability io.kotest:kotest-runner-junit5:5.4.0-LOCAL declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Variant 'runtimeElements' capability io.kotest:kotest-runner-junit5:5.4.0-LOCAL declares a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
tapchicoma
06/30/2022, 7:34 AMEmil Kantis
06/30/2022, 7:39 AMkotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
}
}
Could not determine the dependencies of task ':kotest-extensions-spring:compileJava'.
> Could not resolve all task dependencies for configuration ':kotest-extensions-spring:compileClasspath'.
> Could not resolve io.kotest:kotest-framework-api:5.3.1.
Required by:
project :kotest-extensions-spring
> The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kotest:kotest-framework:kotest-framework-api:
- apiElements
- jvmApiElements
All of them match the consumer attributes:
- Variant 'apiElements' capability io.kotest:kotest-framework-api:5.4.0-LOCAL declares an API of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
- Variant 'jvmApiElements' capability io.kotest:kotest-framework-api:5.4.0-LOCAL declares an API of a library, packaged as a jar, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
I think this only occurs when using gradle's included builds. I'm trying build kotest-examples-spring-webflux
which include kotest-extensions-spring
and kotest
. kotest-extensions-spring
depends on kotest
as well, and this happens on the outgoing variants from kotest
when kotest-extensions-spring
tries to resolve themtapchicoma
06/30/2022, 7:41 AMEmil Kantis
06/30/2022, 7:43 AMtapchicoma
06/30/2022, 7:46 AMapiElements
variant in kotest-framework-api
published version. And JVM one is named jvmApiElements-published
Emil Kantis
06/30/2022, 7:53 AMEmil Kantis
06/30/2022, 7:53 AMtapchicoma
06/30/2022, 7:55 AMapiElements
should not be present in MPP case and jvmApiElements
should also contain org.gradle.jvm.version = 11
. To workaround it - in kotest-framework-api
you need to add bundling and jvm version attributes to jvmApiElements
configuration:
configurations["jvmApiElements"].attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling, Bundling.EXTERNAL)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11)
}
Emil Kantis
06/30/2022, 8:07 AMkotest
fails to resolves one anotherEmil Kantis
06/30/2022, 8:07 AMtapchicoma
06/30/2022, 8:09 AMkotest-assertions-shared:jvmApiElements
configuration. Probably you could just add this attributes into all kotest projects jvmApiElements
configurationsEmil Kantis
06/30/2022, 8:09 AMjvmApiElements
. Perhaps I should just do it to do framework-apiEmil Kantis
06/30/2022, 8:11 AMtapchicoma
06/30/2022, 8:17 AMEmil Kantis
06/30/2022, 9:27 AMAnton Lakotka [JB]
06/30/2022, 2:50 PMjava-library
plugin applied?
Is it only for javadoc
generation? But I don't see any java code in kotest 🤔
Basically applying java-library
or any java-related plugins with Kotlin Gradle Plugin is not recommended. Due to such reasons that you are experiencing right now 🙂
If you really need java alongside kotlin and javadoc generation then you can use following:
kotlin {
jvm {
withJava() // <-- this will enabled Java compilation and other tooling around it. such as javadoc.
}
}
Emil Kantis
06/30/2022, 2:53 PMEmil Kantis
06/30/2022, 2:53 PMAnton Lakotka [JB]
06/30/2022, 2:55 PMjavadoc
tasks are always executed with NO-SOURCE status.
> Task :kotest-framework:kotest-framework-api:javadoc NO-SOURCE
Even without applying withJava()
. So I was wondering why would you need that?Emil Kantis
06/30/2022, 2:58 PMAnton Lakotka [JB]
06/30/2022, 2:59 PMjava-library
application. Together with javadoc
publication. since it is always empty.