diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd302797..f03697ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ -1.0.0-beta05 (not yet released) +1.0.0-beta05 ======================================== - fixed: Custom Http Method with @Body is now possible #6 +- based on Ktor 2.0.1 +- cleanup example project @mattrob33 1.0.0-beta04 ======================================== diff --git a/README.md b/README.md index f12c6418f..5a5207521 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Next you have to add the Ktorfit KSP Plugin to the common target and every compi ```kotlin -val ktorfitVersion = "1.0.0-beta04" +val ktorfitVersion = "1.0.0-beta05" dependencies { add("kspCommonMainMetadata", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion") @@ -93,7 +93,7 @@ Look here for more information https://kotlinlang.org/docs/ksp-multiplatform.htm Add the Ktorfit-lib to your common module. ```kotlin -val ktorfitVersion = "1.0.0-beta04" +val ktorfitVersion = "1.0.0-beta05" sourceSets { val commonMain by getting{ diff --git a/build.gradle.kts b/build.gradle.kts index 1e7de7b0a..c03f4327a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("multiplatform") apply false - id("com.vanniktech.maven.publish") version "0.19.0" apply false + id("com.vanniktech.maven.publish") version "0.18.0" apply false } @@ -17,8 +17,8 @@ buildscript { } } dependencies { - classpath("com.vanniktech:gradle-maven-publish-plugin:0.19.0") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.10") + classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.30") classpath("org.jetbrains.kotlin:kotlin-serialization:1.6.10") classpath("com.android.tools.build:gradle:7.0.4") diff --git a/docs/index.md b/docs/index.md index b7fb0b8dc..984f7382f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -319,7 +319,7 @@ Next you have to add the Ktorfit KSP Plugin to the common target and every compi ```kotlin -val ktorfitVersion = "1.0.0-beta04" +val ktorfitVersion = "1.0.0-beta05" dependencies { add("kspCommonMainMetadata", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion") @@ -336,7 +336,7 @@ Look here for more information https://kotlinlang.org/docs/ksp-multiplatform.htm Add the Ktorfit-lib to your common module. ```kotlin -val ktorfitVersion = "1.0.0-beta04" +val ktorfitVersion = "1.0.0-beta05" sourceSets { val commonMain by getting{ diff --git a/example/AndroidOnlyExample/app/build.gradle b/example/AndroidOnlyExample/app/build.gradle index 16bcbe9db..9c4196258 100644 --- a/example/AndroidOnlyExample/app/build.gradle +++ b/example/AndroidOnlyExample/app/build.gradle @@ -2,6 +2,8 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'com.google.devtools.ksp' version '1.6.10-1.0.4' + id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10' + } android { @@ -48,11 +50,11 @@ android { } dependencies { - ksp('de.jensklingenberg.ktorfit:ktorfit-ksp:1.0.0-beta04') - implementation("de.jensklingenberg.ktorfit:ktorfit-lib:1.0.0-beta04") + ksp('de.jensklingenberg.ktorfit:ktorfit-ksp:1.0.0-beta05') + implementation("de.jensklingenberg.ktorfit:ktorfit-lib:1.0.0-beta05") implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1' + implementation 'androidx.activity:activity-compose:1.4.0' implementation "androidx.compose.ui:ui:$compose_ui_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" implementation 'androidx.compose.material:material:1.1.1' @@ -62,5 +64,8 @@ dependencies { androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version" + implementation("io.ktor:ktor-client-serialization:2.0.1") + implementation("io.ktor:ktor-client-content-negotiation:2.0.1") + implementation("io.ktor:ktor-serialization-kotlinx-json:2.0.1") } diff --git a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/MainActivity.kt b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/MainActivity.kt index 794994459..27043a541 100644 --- a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/MainActivity.kt +++ b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/MainActivity.kt @@ -1,23 +1,24 @@ package de.jensklingenberg.androidonlyexample import android.os.Bundle -import android.util.Log import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text -import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.lifecycleScope import de.jensklingenberg.androidonlyexample.ui.theme.AndroidOnlyExampleTheme -import de.jensklingenberg.ktorfit.Call import de.jensklingenberg.ktorfit.Ktorfit +import de.jensklingenberg.ktorfit.adapter.FlowResponseConverter import de.jensklingenberg.ktorfit.create -import de.jensklingenberg.ktorfit.http.GET -import kotlinx.coroutines.GlobalScope +import io.ktor.client.* +import io.ktor.client.plugins.contentnegotiation.* +import io.ktor.serialization.kotlinx.json.* import kotlinx.coroutines.launch +import kotlinx.serialization.json.Json val ktorfit = Ktorfit("https://swapi.dev/api/", HttpClient { install(ContentNegotiation) { @@ -26,12 +27,12 @@ val ktorfit = Ktorfit("https://swapi.dev/api/", HttpClient { }).also { it.addResponseConverter(FlowResponseConverter()) } +val api: StarWarsApi = ktorfit.create() class MainActivity : ComponentActivity() { - val api: StarWarsApi = ktorfit.create() - val peopleState = MutableStateFlow(listOf()) + private val peopleState = mutableStateOf(null) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -41,19 +42,16 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background ) { - val people = peopleState.rememberAsState() - - LazyColumn { - items(people) { person -> - Text(person.name) - } + peopleState.value?.let { + Text(it.name?: "") } + } } } lifecycleScope.launch { - peopleState.value = api.getPeople(page = 1) + peopleState.value = api.getPerson( 1) } } } \ No newline at end of file diff --git a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/StarWarsApi.kt b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/StarWarsApi.kt index 20fe35e0f..06894ecd8 100644 --- a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/StarWarsApi.kt +++ b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/StarWarsApi.kt @@ -1,14 +1,20 @@ package de.jensklingenberg.androidonlyexample +import de.jensklingenberg.ktorfit.Call +import de.jensklingenberg.ktorfit.http.GET +import de.jensklingenberg.ktorfit.http.Path +import de.jensklingenberg.ktorfit.http.Query +import kotlinx.coroutines.flow.Flow + interface StarWarsApi { @GET("people/{id}/") suspend fun getPerson(@Path("id") personId: Int): Person - @GET("people") - fun getPeople(@Query("page") page: Int): List - @GET("people") fun getPeopleFlow(@Query("page") page: Int): Flow + @GET("people/{id}/") + fun getPersonCall(@Path("id") personId: Int): Call + } \ No newline at end of file diff --git a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/TestJava.java b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/TestJava.java index 5494d3517..c15a67682 100644 --- a/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/TestJava.java +++ b/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/TestJava.java @@ -1,7 +1,6 @@ package de.jensklingenberg.androidonlyexample; -import static de.jensklingenberg.androidonlyexample.MainActivityKt.testApi; - +import static de.jensklingenberg.androidonlyexample.MainActivityKt.getApi; import android.util.Log; import androidx.annotation.NonNull; @@ -11,11 +10,12 @@ public class TestJava { - void test(){ - testApi().getPersonCall().onExecute(new Callback() { + void test() { + getApi().getPersonCall(1).onExecute(new Callback() { + @Override - public void onResponse(String s, @NonNull HttpResponse httpResponse) { - Log.d("Android:",s); + public void onResponse(Person person, @NonNull HttpResponse httpResponse) { + Log.d("Android:", person.toString()); } @Override diff --git a/example/MultiplatformExample/Readme.md b/example/MultiplatformExample/Readme.md new file mode 100644 index 000000000..27036a98d --- /dev/null +++ b/example/MultiplatformExample/Readme.md @@ -0,0 +1 @@ +The Http Reponse will be printed to the logcat \ No newline at end of file diff --git a/example/MultiplatformExample/build.gradle.kts b/example/MultiplatformExample/build.gradle.kts index 525941692..1eecf4544 100644 --- a/example/MultiplatformExample/build.gradle.kts +++ b/example/MultiplatformExample/build.gradle.kts @@ -6,8 +6,8 @@ buildscript { } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20") - classpath("com.android.tools.build:gradle:7.3.0-alpha07") - classpath("org.jetbrains.kotlin:kotlin-serialization:1.6.20") + classpath("com.android.tools.build:gradle:7.3.0-alpha09") + classpath("org.jetbrains.kotlin:kotlin-serialization:1.6.21") } } diff --git a/example/MultiplatformExample/gradle/wrapper/gradle-wrapper.properties b/example/MultiplatformExample/gradle/wrapper/gradle-wrapper.properties index ee24bc542..89c35223e 100644 --- a/example/MultiplatformExample/gradle/wrapper/gradle-wrapper.properties +++ b/example/MultiplatformExample/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Apr 11 19:19:06 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/example/MultiplatformExample/settings.gradle.kts b/example/MultiplatformExample/settings.gradle.kts index a2748c56a..5cfc106fd 100644 --- a/example/MultiplatformExample/settings.gradle.kts +++ b/example/MultiplatformExample/settings.gradle.kts @@ -6,6 +6,6 @@ pluginManagement { } } -rootProject.name = "My_Application" +rootProject.name = "KtorfitMultiplatformExample" include(":androidApp") include(":shared") \ No newline at end of file diff --git a/example/MultiplatformExample/shared/build.gradle.kts b/example/MultiplatformExample/shared/build.gradle.kts index f19673892..9db710b7a 100644 --- a/example/MultiplatformExample/shared/build.gradle.kts +++ b/example/MultiplatformExample/shared/build.gradle.kts @@ -8,8 +8,8 @@ plugins { } version = "1.0" -val ktorVersion = "2.0.0" -val ktorfitVersion = "1.0.0-beta04" +val ktorVersion = "2.0.1" +val ktorfitVersion = "1.0.0-beta05" kotlin { android() @@ -35,7 +35,7 @@ kotlin { val commonMain by getting { dependencies { implementation("de.jensklingenberg.ktorfit:ktorfit-lib:$ktorfitVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") //Only needed when you want to use Kotlin Serialization implementation("io.ktor:ktor-client-serialization:$ktorVersion") diff --git a/example/MultiplatformExample/shared/src/commonMain/kotlin/com/example/ktorfittest/Greeting.kt b/example/MultiplatformExample/shared/src/commonMain/kotlin/com/example/ktorfittest/Greeting.kt index 6aaab6152..136fb01b0 100644 --- a/example/MultiplatformExample/shared/src/commonMain/kotlin/com/example/ktorfittest/Greeting.kt +++ b/example/MultiplatformExample/shared/src/commonMain/kotlin/com/example/ktorfittest/Greeting.kt @@ -26,7 +26,7 @@ class Greeting { fun greeting(): String { loadData() - return "Hello, ${Platform().platform}!" + return "Hello, ${Platform().platform}! Look in the LogCat" } diff --git a/ktorfit-ksp/build.gradle.kts b/ktorfit-ksp/build.gradle.kts index df076df13..819008b25 100644 --- a/ktorfit-ksp/build.gradle.kts +++ b/ktorfit-ksp/build.gradle.kts @@ -15,7 +15,7 @@ tasks.withType { group = "de.jensklingenberg.ktorfit" -version = "1.0.0-beta04" +version = "1.0.0-beta05" dependencies { implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion") diff --git a/ktorfit-lib/build.gradle.kts b/ktorfit-lib/build.gradle.kts index a89ed3c4a..2fe22d416 100644 --- a/ktorfit-lib/build.gradle.kts +++ b/ktorfit-lib/build.gradle.kts @@ -14,7 +14,7 @@ tasks.withType { kotlinOptions.jvmTarget = "1.8" } -version = "1.0.0-beta04" +version = "1.0.0-beta05" val ktorVersion = "2.0.1" kotlin { @@ -51,7 +51,7 @@ kotlin { val commonMain by getting { dependencies { api("io.ktor:ktor-client-core:$ktorVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") } } @@ -125,7 +125,7 @@ publishing { publications { create("default") { artifact(tasks["sourcesJar"]) - //artifact(tasks["dokkaJar"]) + // artifact(tasks["javadocJar"]) pom { name.set(project.name) diff --git a/local.properties b/local.properties index 20e4434c2..c5b3cc9e7 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Thu May 05 21:33:50 CEST 2022 -sdk.dir=/home/jens/Code/Android/Sdk +#Sun May 08 21:33:07 CEST 2022 +sdk.dir=/Users/jensklingenberg/Library/Android/sdk diff --git a/workload/build.gradle.kts b/workload/build.gradle.kts index fab7289aa..cf016516b 100644 --- a/workload/build.gradle.kts +++ b/workload/build.gradle.kts @@ -43,7 +43,7 @@ kotlin { dependencies { implementation("io.ktor:ktor-client-core-native:1.3.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt") - implementation("io.ktor:ktor-client-curl:2.0.0-eap-362") + implementation("io.ktor:ktor-client-curl:2.0.1") } }