kosi-libs/MocKMP

Build Error with JS Source Set in KMP (Version 1.10.0)

Amud opened this issue · 1 comments

Amud commented

Environment:

Plugin version: 1.10.0
Kotlin version: 1.7.20
Gradle version: (please include if relevant)
Operating System: (please include if relevant)
Problem:
I am using the org.kodein.mock.mockmp plugin for mock objects in unit tests for a common module in a Kotlin Multiplatform Project. While the plugin works fine with Android and iOS source sets, I encountered a build error when adding the JS source set.

Here's how I've configured the JS source set in my project:

js(IR) {
    binaries.library()
}

Error Log:

> Could not create task ':myLibrary1:compileProductionExecutableKotlinJs'.
   > Failed to apply plugin class 'org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin'.
      > Project#afterEvaluate(Action) on project ':myLibrary2' cannot be executed in the current context.

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':myLibrary1-imp'.
  at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
  at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:77)
  at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:55)
  at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:255)
  at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
  at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
  at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
  at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
  at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)

Steps to Reproduce:

Configure the plugin for a common module.
Add a JS source set as described above.
Attempt to build the project.

Expected Behavior:
The project should build successfully with the JS source set.

Actual Behavior:
The build fails with the error message provided.

At least with the new version 1.16.0, I can confirm that JS is properly supported.
See https://github.com/kosi-libs/MocKMP/blob/master/tests-projects/tests-jvm-junit4/build.gradle.kts#L19