square / square/wire

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

Open
#3,362 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

PR welcome!
Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

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 {}
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure from server/build.gradle.kts at line 77 with Kotlin 2.2.0 and Wire 5.3.10, focusing on compilerOptions.extraWarnings when the Wire plugin is applied. Inspect the Wire Gradle plugin integration and its Kotlin Multiplatform compiler configuration; the work is done when extraWarnings is recognized and the reproduced build completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.