Hi, I'm testing building a multiplatform library. ...
# javascript
l
Hi, I'm testing building a multiplatform library. I added the
js
target and a dependency to the js stdlib, but when I run the
build
gradle task, I get the following error:
Copy code
org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures.
	...
        ...
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':modules:bitflags:compileKotlinJs'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
	...
        ...
	... 6 more
Caused by: java.lang.NoSuchMethodError: org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments.setCommonSources([Ljava/lang/String;)V
	at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJsCompilerAsync(GradleKotlinCompilerRunner.kt:297)
	at org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:566)
	at org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:476)
Here's the link to the gradle.kts file of the module I'm trying to build: https://github.com/LouisCAD/Splitties/blob/baaf3548141ac5f8e631b5f858cc9ce25bfa2cbe/modules/bitflags/build.gradle.kts#L28 and here's the
buildSrc
it depends on: https://github.com/LouisCAD/Splitties/tree/baaf3548141ac5f8e631b5f858cc9ce25bfa2cbe/buildSrc I'm using Kotlin 1.3.21 with Gradle 4.10.1, and AGP 3.3.1 for the Android part.
d
My JVM builds fail on that gradle version for the same reason.
On gradle 4.7, metadata feature is outdated. On gradle 4.8 you get "Duplicate method name getExt() in AccessorsKt" on 4.10 you get "NoSuchMethodError: createModuleFile" on 5.1 you get "cannot change attributes of configuration ':nativeApiElements' after it has been resolved" For me, this is the definition of "experimental"
l
Thanks for the link, I'll try with the suggested resolution strategy!
For reference, adding the following into my `buildSrc`'s
build.gradle.kts
file resolved my issue:
Copy code
configurations.all {
    val isKotlinCompiler = name == "embeddedKotlin" || name.startsWith("kotlin") || name.startsWith("kapt")
    if (!isKotlinCompiler) {
        resolutionStrategy.eachDependency {
            if (requested.group == "org.jetbrains.kotlin" && requested.module.name == "kotlin-compiler-embeddable") {
                useVersion("1.3.21") // Update to whatever the Kotlin version you need is
            }
        }
    }
}
🎉 1
j
why is gradle so flakey?
d
I wish I knew.
j
every time there's a gradle update, something stops working compare it with maven where scripts that were written years ago still continue to work years later across maven versions. hopefully Gradle 5 doesn't change too much again
n
Gradle is known to break backwards compatibility often, which is a intentional part of its design unfortunately ☹️.