diffplug / goomph

IDE as build artifact
Apache License 2.0
130 stars 30 forks source link

okhttp3 TaskRunner initialization exception #181

Closed harmanea closed 2 years ago

harmanea commented 2 years ago

Hello, I've come across a really strange error.

I'm using the com.diffplug.eclipse.mavencentral plugin to get swt for my standalone desktop application. I've been using the 3.17.7 version of the plugin with 4.12.0 swt version. Today I tried switching to 3.35.0 and 4.20.0 respectively which results in the following error:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class okhttp3.internal.concurrent.TaskRunner
    at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:41)
    at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47)
    at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.kt:445)
    at com.diffplug.gradle.FileMisc.download(FileMisc.java:57)
    at com.diffplug.gradle.eclipse.MavenCentralMapping.lambda$createVersionMap$0(MavenCentralMapping.java:140)
    at com.diffplug.common.base.Errors$Rethrowing.lambda$wrap$11(Errors.java:342)
    at com.diffplug.common.base.Errors$Rethrowing.get(Errors.java:334)
    at com.diffplug.gradle.eclipse.MavenCentralMapping.createVersionMap(MavenCentralMapping.java:139)
    at com.diffplug.gradle.eclipse.MavenCentralMapping.groupIdArtifactIdToVersion(MavenCentralMapping.java:114)
    at com.diffplug.gradle.eclipse.MavenCentralExtension$ReleaseConfigurer.<init>(MavenCentralExtension.java:54)
    at com.diffplug.gradle.eclipse.MavenCentralExtension.release(MavenCentralExtension.java:45)
    at com.diffplug.gradle.eclipse.MavenCentralExtension.release(MavenCentralExtension.java:41)
    at com.diffplug.gradle.eclipse.MavenCentralExtension_Decorated.release(Unknown Source)

Interestingly, this does not happen for swt versions 4.12.0 or lower.

Do you have any suggestions on how to fix this?

nedtwigg commented 2 years ago

That is strange. Probably Goomph is asking for one version of okhttp, and some other plugin is asking for a different version. My advice would be:

One useful hint, re:

this does not happen for swt versions 4.12.0 or lower.

I assume you mean that you can use the latest version of Goomph, and it still works with SWT 4.12? The error you are getting is in the index download phase. The index is cached and only needs to be downloaded once, so if it was successfully downloaded with a previous version then you won't get a download error.

https://github.com/diffplug/goomph/blob/f33385480abe53b1b42713693efe1b8ff44ce1b6/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java#L130-L132

harmanea commented 2 years ago

Upgrading my Gradle version has fixed the issue. Thanks for the tip!

ql437967081 commented 2 years ago
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib</artifactId>
                <version>1.5.10</version>
            </dependency>

add this dependency works

nedtwigg commented 2 years ago

Thanks @ql437967081 for the workaround! This might not be necessary in 3.37.2 because we bumped our transitive deps to latest.