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

mockk jar 1.12.8 is empty on MavenCentral, Maven does not leverage Kotlin multi platform build #921

Closed
stefanzilske opened this issue Sep 16, 2022 · 4 comments

Comments

@stefanzilske
Copy link

@aSemy, referring to #868 (#868 (comment)) here is a sample project, which uses mockk 1.12.8 with Maven and you can immediately see that it does not compile. If you switch to mockk-jvm it works, but I got that it should work anyway.

https://github.com/stefanzilske/mockk-demo

I couldn't yet reproduce the java.lang.NoSuchMethodError: 'kotlin.reflect.KClass io.mockk.ValueClassSupportKt.boxedClass(kotlin.reflect.KClass)' that I get in my real project when I switch to mockk-jvm while having springmockk as well, but I will keep trying.

@aSemy
Copy link
Contributor

aSemy commented Sep 16, 2022

Some context: The MockK JVM library was renamed when MockK was updated to use the new Kotlin Multiplatform plugin in #855. (MockK was, and is, multiplatform - the update just upgraded the from a deprecated Kotlin Multiplatform plugin)

Before this change the JVM platform library was simply called mockk, while the common library was called mockk-common. When the projects were refactored, the library was renamed - not intentionally, but that's how the Kotlin Multiplatform Plugin conventionally names platform specific libraries. The rename wasn't caught because Gradle publishes additional module metadata, which Maven can't read or use.

I've looked into this further and I think it's quite standard for Kotlin Multiplatform libraries to tell Maven users that they have to explicitly use -jvm variants (Ktor docs example: "for Maven you need to add a platform-specific suffix manually").

I agree that this change shouldn't have been in a patch release (although I'm not a strong advocate of semantic versioning), and ideally MockK should have snapshot releases to catch issues sooner #910.

Some projects seem to do some manual Maven config to work around this (for example Kotlinx Serialization has some Gradle config, although I don't quite understand it, or its purpose).

Possibly MockK can apply such a workaround, although I'm wary of introducing more issues by hacking around, especially since I think the 'best' solution is to

  • stop releasing 1.12.*,
  • bump MockK to 1.13.0
  • with release notes detailing that Maven users need to add -jvm to any MockK dependencies,
  • and update the documentation on mockk.io.

(reminder, I'm a contributor, these are just my thoughts 🙂)

@Raibaz
Copy link
Collaborator

Raibaz commented Sep 19, 2022

I agree with your "best" solution @aSemy, i'll get it done today.

thammerl added a commit to QloudNetwork/qloud-integrations that referenced this issue Sep 20, 2022
@Raibaz
Copy link
Collaborator

Raibaz commented Sep 23, 2022

Just released v1.13.1.

@Raibaz Raibaz closed this as completed Sep 23, 2022
@aSemy
Copy link
Contributor

aSemy commented Sep 23, 2022

Just released v1.13.1.

@Raibaz There's a couple of minor mistakes in the release notes, and in the docs :)

  • There's no -android suffix - it's only mockk-jvm or just mockk.

    While there is a mockk-android library, this is a pure JVM Android library not a Kotlin multiplatform library, so there is no -jvm platform suffix.

    If MockK had a JavaScript version, then the mockk lib would have two platform variants: mockk-jvm and mockk-js. But this wouldn't affect mockk-android.

  • The release notes say it's a 'major release', but going from 1.12.x to 1.13.x changes the minor version. A major release would be 2.x.

  • If using Maven, a platform suffix is required. If using Gradle, the platform suffix can be omitted. The website sometimes adds the -jvm suffix on the Gradle dependencies.

    Here's how I'd describe it:

    If using Maven, then you must change the MockK dependency to include the platform suffix, -jvm

    <dependency>
        <groupId>io.mockk</groupId>
        <artifactId>mockk-jvm</artifactId>
        <version>{version}</version>
        <scope>test</scope>
    </dependency>

    If using Gradle, there is no need to add the platform suffix.

        testImplementation("io.mockk:mockk:{version}")

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

No branches or pull requests

3 participants