Skip to content

extraWarnings Unresolved Reference When Applying Wire Gradle Plugin in Kotlin Multiplatform Project #3362

Description

@edsion1107

When applying the Wire Gradle plugin in a Kotlin Multiplatform project and using the new compilerOptions DSL with extraWarnings, the build fails with an unresolved reference error:

> Configure project :server
w: Missing `androidTarget()` in Kotlin Multiplatform Project
Missing `androidTarget()` Kotlin target in multiplatform project 'server (:server)'.
The Android Gradle plugin was applied without creating a corresponding `androidTarget()` Kotlin Target
`
plugins {
    id("com.android.application")
    kotlin("multiplatform")
}

kotlin {
    androidTarget() // <-- please register this Android target
}
`
Solution: Please register the Android target.


[Incubating] Problems report is available at: file:///Users/edsion/repo/appium-multiplatform/build/reports/problems/problems-report.html
8 actionable tasks: 8 up-to-date
e: file:///Users/edsion/repo/appium-multiplatform/server/build.gradle.kts:77:9: Unresolved reference: extraWarnings

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/edsion/repo/appium-multiplatform/server/build.gradle.kts' line: 77

* What went wrong:
Script compilation error:

  Line 77:         extraWarnings.set(true)
                   ^ Unresolved reference: extraWarnings

1 error

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
ScriptCompilationException(scriptCompilationErrors=[ScriptCompilationError(message=Unresolved reference: extraWarnings, location=/Users/edsion/.gradle/.tmp/gradle-kotlin-dsl-15560664044033123127.tmp/build.gradle.kts (77:9))])

Expected behavior
extraWarnings should be recognized as a valid property of compilerOptions in Kotlin 2.2+ Multiplatform projects, even when the Wire plugin is applied.

plugins {
    kotlin("multiplatform") version "2.2.0"
    id("com.squareup.wire") version "5.3.10"
}
kotlin {
    androidTarget()
    jvm()
    ....
    compilerOptions {
        extraWarnings.set(true)
        optIn.add("kotlin.time.ExperimentalTime")
        freeCompilerArgs.add("-Xexpect-actual-classes")
    }
}

wire {
    kotlin {}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions