Skip to content

Commit

Permalink
v1.0.0-beta05
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso committed May 9, 2022
1 parent a32f602 commit 33de121
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 51 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
========================================
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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

}

Expand All @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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{
Expand Down
13 changes: 9 additions & 4 deletions example/AndroidOnlyExample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'
Expand All @@ -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")
}

Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -26,12 +27,12 @@ val ktorfit = Ktorfit("https://swapi.dev/api/", HttpClient {
}).also {
it.addResponseConverter(FlowResponseConverter())
}
val api: StarWarsApi = ktorfit.create<StarWarsApi>()

class MainActivity : ComponentActivity() {

val api: StarWarsApi = ktorfit.create<StarWarsApi>()

val peopleState = MutableStateFlow(listOf<Person>())
private val peopleState = mutableStateOf<Person?>(null)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Person>

@GET("people")
fun getPeopleFlow(@Query("page") page: Int): Flow<Person>

@GET("people/{id}/")
fun getPersonCall(@Path("id") personId: Int): Call<Person>

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,11 +10,12 @@

public class TestJava {

void test(){
testApi().getPersonCall().onExecute(new Callback<String>() {
void test() {
getApi().getPersonCall(1).onExecute(new Callback<Person>() {

@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
Expand Down
1 change: 1 addition & 0 deletions example/MultiplatformExample/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Http Reponse will be printed to the logcat
4 changes: 2 additions & 2 deletions example/MultiplatformExample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion example/MultiplatformExample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ pluginManagement {
}
}

rootProject.name = "My_Application"
rootProject.name = "KtorfitMultiplatformExample"
include(":androidApp")
include(":shared")
6 changes: 3 additions & 3 deletions example/MultiplatformExample/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Greeting {
fun greeting(): String {

loadData()
return "Hello, ${Platform().platform}!"
return "Hello, ${Platform().platform}! Look in the LogCat"
}


Expand Down
2 changes: 1 addition & 1 deletion ktorfit-ksp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks.withType<KotlinCompile> {


group = "de.jensklingenberg.ktorfit"
version = "1.0.0-beta04"
version = "1.0.0-beta05"

dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion")
Expand Down
6 changes: 3 additions & 3 deletions ktorfit-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

version = "1.0.0-beta04"
version = "1.0.0-beta05"
val ktorVersion = "2.0.1"
kotlin {

Expand Down Expand Up @@ -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")

}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ publishing {
publications {
create<MavenPublication>("default") {
artifact(tasks["sourcesJar"])
//artifact(tasks["dokkaJar"])
// artifact(tasks["javadocJar"])

pom {
name.set(project.name)
Expand Down
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion workload/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
}
Expand Down

0 comments on commit 33de121

Please sign in to comment.