Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupt wire library (okio) #651

Open
1 task done
WetABQ opened this issue Jan 9, 2023 · 2 comments
Open
1 task done

Corrupt wire library (okio) #651

WetABQ opened this issue Jan 9, 2023 · 2 comments
Assignees

Comments

@WetABQ
Copy link

WetABQ commented Jan 9, 2023

🐛 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.

@freynder
Copy link

freynder commented Mar 2, 2023

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
Copy link

freynder commented Mar 2, 2023

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.

@LouisCAD LouisCAD self-assigned this Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants