Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jvm version compatibility #2913

Merged
merged 1 commit into from
Jan 28, 2025
Merged

Conversation

Tapchicoma
Copy link
Contributor

Interesting that presence of Kover plugin hides the resolution error and Gradle just silently continue the build. Check this build scan - dependencies tab is empty. I highly suspect due to these additional Kover attributes.

If I remove Kover from this project - I see proper Gradle failure:

Could not determine the dependencies of task ':kotlinx-serialization-protobuf:compileTestKotlinJvm'.
> Could not resolve all task dependencies for configuration ':kotlinx-serialization-protobuf:jvmTestCompileClasspath'.
   > Could not resolve project :kotlinx-serialization-protobuf:proto-test-model.
     Required by:
         project :kotlinx-serialization-protobuf
      > No matching variant of project :kotlinx-serialization-protobuf:proto-test-model was found. The consumer was configured to find a library for use during compile-time, compatible with Java 8, 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' but:
          - Variant 'apiElements' declares a library for use during compile-time, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible 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 'mainSourceElements' declares a component, and its dependencies declared externally:
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its usage (required compile-time)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible 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 'testResultsElementsForTest':
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its usage (required compile-time)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

Main projects, while using default JDK toolchain 11, are configured to
build with JDK release 8. After recent changes in KGP attributes checks
for JVM compatibility is started working and complain about incompatible
JVM target version for 'proto-test-models' project. To avoid this I
downgraded JDK toolchain version in this project to 8.
@Tapchicoma Tapchicoma changed the base branch from master to dev January 27, 2025 19:46
@Tapchicoma Tapchicoma requested a review from shanshin January 27, 2025 19:46
@shanshin
Copy link
Contributor

I highly suspect due to these additional Kover attributes.

That's not quite true.
It's all about the specifics of the dependency resolution in Gradle. If there is no dependency with the requested attributes, then an arbitrary dependency with disjoint attributes is taken.

This is the expected behavior of Gradle, see gradle/gradle#27019.

In recent versions of Kover, an attribute was added that eliminated this "hiding of problems".
See relative issue in Kover: Kotlin/kotlinx-kover#728

@Tapchicoma
Copy link
Contributor Author

Should Kover version in this project be updated to at least 0.9.0?

@Tapchicoma Tapchicoma merged commit 684cbb3 into dev Jan 28, 2025
4 checks passed
@shanshin shanshin deleted the fix-jvm-version-compatibility branch January 28, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants