Open tomholub opened 4 years ago
Hmm, this is quite interesting. Do you have any pointer to help me identify the problem here?
I tried the following;
class ApiClient {
fun put(): Result<String, FuelError> = Fuel.put("https://httpbin.org/put", listOf("foo" to "bar"))
.header(Headers.ACCEPT, "application/json")
.responseString().third
}
class JUnitTest {
@Test
fun test() {
with(ApiClient().put()) {
success {
println("success: $it")
}
failure {
println("failure : $it")
}
}
}
}
This is what I got (which is correct as expected)
Thank you for the response. I'm not sure what is going on. I'll try to arrange a repro on our end that we could share.
Same issue here. Just imported fuel in gradle with:
implementation("com.github.kittinunf.fuel:fuel:2.3.0")
And then:
fun main() {
val (request, response, result) = "https://httpbin.org/get"
.httpGet()
.responseString()
}
Result:
Exception in thread "main" java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.MutablePropertyReference1Impl.<init>(java.lang.Class, java.lang.String, java.lang.String, int)'
at com.github.kittinunf.fuel.core.FuelManager.<clinit>(FuelManager.kt)
at com.github.kittinunf.fuel.Fuel.<init>(Fuel.kt:11)
at com.github.kittinunf.fuel.Fuel.<clinit>(Fuel.kt:11)
at com.github.kittinunf.fuel.FuelKt.httpGet(Fuel.kt:23)
at com.github.kittinunf.fuel.FuelKt.httpGet$default(Fuel.kt:22)
🙇 Not sure what exactly is the problem here but I tried the following;
Create a brand new project with these settings
build.gradle.kts
plugins {
application
kotlin("jvm")
}
version = ""
group = "com.github.kittinunf"
application {
mainClassName = "com.github.kittinunf.fuel.MainKt"
}
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
implementation("com.github.kittinunf.fuel:fuel:2.3.0")
}
main/Main.kt
fun main(args: Array<String>) {
println("Hello Fuel!")
val (_, _, result) = Fuel.get("https://httpbin.org/get").responseString()
println(result)
}
test/MainTest.kt
class MainTest {
@Test
fun test() {
val (_, _, result) = Fuel.get("https://httpbin.org/get").responseString()
println(result)
}
}
It works as expected on both test and main classes.
Do you think it has something to do with old Kotlin version left in the classpath or something?
It happened to me while writing a Gradle plugin, so that might be the culprit. Maybe Gradle 6.6.1 pulls in the classpath some incompatible Kotlin version? Which version of Kotlin does Fuel require?
For the latest version, it requires Kotlin 1.4.x and up
My feeling is that Gradle is still using 1.3.x, so developing with implementation(gradleApi()) makes the system incompatible with fuel.
On Sun, Oct 4, 2020 at 3:36 PM Kittinun Vantasin notifications@github.com wrote:
For the latest version, it requires Kotlin 1.4.x and up
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
-- Ing. Dott. Danilo Pianini, PhD
Site: http://www.danilopianini.org/ Phone: +39 320 41 36 573 Hangouts: danilo.pianini@gmail.com
@DanySK Thanks for reporting and sorry for the problem you are experiencing.
Do you think you could try to update to this version of the gradle instead?
https://github.com/gradle/gradle/issues/12660#issuecomment-700629974
Except from this issue; https://github.com/gradle/gradle/issues/12660
Upgrading to gradle 6.8 (not yet released as a final version!) seems to work. Latest milestone is M3:
./gradlew wrapper --gradle-version=6.8-milestone-3
@kittinunf yes I will eventually upgrade to Gradle 6.8 once it reaches stability
Bug Report
Description
We use Fuel in our prod code, which works well. When testing this code, we get:
To Reproduce
Write a class like:
Which you can use in your project normally:
But when trying to test it:
You will get NoSuchMethodError:
Expected behavior
Ability to use in tests.
Environment
Development Machine
Complete the following information if applicable
Additional context
We use a multi-module setup in our project, with folders like:
Where projectOne and projectTwo depends on shared. The gradle dependency implementation, class code as well as testing was all done in
projectOne
so I don't think this is relevant, just adding for completeness.