atsushieno / augene-ng

MML + MIDI + Tracktion Engine XML manipulation tool for real production
GNU General Public License v3.0
9 stars 2 forks source link

kotractive gradle sync fails on IDEA unless we disable native builds. #10

Closed atsushieno closed 2 years ago

atsushieno commented 2 years ago

It has been known when I had been stuck at https://github.com/atsushieno/augene-ng/issues/5 but while that issue is gone it's still there:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':commonizeNativeDistribution'.
    at org.gradle.api.internal.tasks.properties.DefaultTaskProperties.resolve(DefaultTaskProperties.java:83)
    at org.gradle.execution.plan.LocalTaskNode.resolveMutations(LocalTaskNode.java:200)
    at org.gradle.execution.plan.DefaultExecutionPlan.getResolvedMutationInfo(DefaultExecutionPlan.java:665)
    at org.gradle.execution.plan.DefaultExecutionPlan.selectNext(DefaultExecutionPlan.java:577)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$executeNextNode$1(DefaultPlanExecutor.java:166)
    at org.gradle.internal.resources.DefaultResourceLockCoordinationService.withStateLock(DefaultResourceLockCoordinationService.java:45)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:155)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension (org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated is in unnamed module of loader 
...
(snip)

To workaround the problem, disable native build again (disable native targets in kotractive/build.gradle.kts).

atsushieno commented 2 years ago

I think I figured out why this problem happens.

ksp gradle plugin has some hacky configuration hack to populate ksp targets for each existing target. That part of the code does not blend with standard way of defining targets in JetBrains Kotlin Multiplatform project structure that is generated by IDEA default template, which is like:

    val nativeTarget = when {
        hostOs == "Mac OS X" -> macosX64("native") { ... 
        hostOs == "Linux" -> linuxX64("native") { ... }
        isMingwX64 -> mingwX64("native") { ... }
        else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
    }

They define native targets in the name of "native". On the other hand, what Google devs did on their examples/multiplatform:

    linuxX64() { ... }
    // requires Android SDK
    androidNativeX64() { ... }
    // requires Android SDK
    androidNativeArm64() { ... }
    mingwX64()

Looking totally different. It is quite impractical and lacks common source set (nativeMain) specification. It is most likely Google's responsibility to get things working along with how JetBrains' native commonizer works.

atsushieno commented 2 years ago

The latest native build is on native-issue3 branch.

atsushieno commented 2 years ago

It is now filed as a ksp issue https://github.com/google/ksp/issues/737

atsushieno commented 2 years ago

fixed at 1ab9599.