refreshVersions icon indicating copy to clipboard operation
refreshVersions copied to clipboard

Corrupt wire library (okio)

Open WetABQ opened this issue 1 year ago • 2 comments

🐛 Describe the bug

When using this plugin and generating the proto by Wire, it will corrupt the Wire Gradle plugin "okio" library.

⚠️ Current behavior

Unable to find method ''okio.FileSystem okio.Okio.asResourceFileSystem(java.lang.ClassLoader)''
'okio.FileSystem okio.Okio.asResourceFileSystem(java.lang.ClassLoader)'

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

✅ Expected behavior

No error should occur during generating proto files.

💣 Steps to reproduce

build.gradle.kts

plugins {
    kotlin("jvm") version "1.7.10"
    id("com.squareup.wire") version "4.4.3"
    idea
}


group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    api("com.squareup.wire:wire-runtime:4.4.3")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.+")
}

wire {
    sourcePath {
        srcDir("src/proto")
    }
    kotlin {
    }
}

idea {
    module {
        sourceDirs.add(project.file("src/proto"))
    }
}

Put some arbitrary proto to the src/proto folder, then run the generateMainProtos task.

WetABQ avatar Jan 09 '23 10:01 WetABQ

Hi, I experience the exact same issue. Versions: kotlin: 1.8.10 wire: 4.5.1 refreshVersions: 0.51.0 gradle: 8.0.1

freynder avatar Mar 02 '23 14:03 freynder

Debugging showed that the plugin tries to call extension function ClassLoader.asResourceFileSystem() which is defined in okio:3.0 . Somehow RefreshVersions prevents this dependency to be loaded it seems.

Caused by: java.lang.NoSuchMethodError: 'okio.FileSystem okio.Okio.asResourceFileSystem(java.lang.ClassLoader)'
	at com.squareup.wire.schema.CoreLoader$resourceFileSystem$2.invoke(CoreLoader.kt:34)

Seems like refreshVersions depends on okhttp v4.9.3 which also depends on com.squareup.okio:okio , however on v2.8.0; I suppose that is the issue. My project has a root settings.file using the RefreshVersions plugin, and the issue happens in a subproject, not sure if that is a factor.

So a more recent okhttp dependency is needed.

freynder avatar Mar 02 '23 18:03 freynder