diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d2513d194..344d1a216 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,7 +19,7 @@ jobs: - uses: gradle/gradle-build-action@v2 - name: Publish release - run: ./gradlew clean :ktorfit-annotations:publishAllPublicationsToMavenCentralRepository :ktorfit-ksp:publishAllPublicationsToMavenCentralRepository :ktorfit-lib:publishAllPublicationsToMavenCentralRepository :ktorfit-lib-common:publishAllPublicationsToMavenCentralRepository :compiler-plugin:publishAllPublicationsToMavenCentralRepository + run: ./gradlew clean :ktorfit-annotations:publishAllPublicationsToMavenCentralRepository :ktorfit-ksp:publishAllPublicationsToMavenCentralRepository :ktorfit-lib:publishAllPublicationsToMavenCentralRepository :ktorfit-lib-common:publishAllPublicationsToMavenCentralRepository :compiler-plugin:publishAllPublicationsToMavenCentralRepository :ktorfit-converters:call:publishAllPublicationsToMavenCentralRepository :ktorfit-converters:flow:publishAllPublicationsToMavenCentralRepository env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} diff --git a/RELEASING.md b/RELEASING.md index c3308a844..42cb41903 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,13 +1,16 @@ Releasing ========= - 1. Change the version in `gradle.properties` to a non-SNAPSHOT version. - 2. Update the `CHANGELOG.md` for the impending release. - 3. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) - 4. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) - 5. `./gradlew clean publish --no-daemon --no-parallel && ./gradlew closeAndReleaseRepository` - 6. Update the `gradle.properties` to the next SNAPSHOT version. - 7. `git commit -am "Prepare next development version."` - 8. `git push && git push --tags` +# Publish new version -//publishAllPublicationsToMavenCentralRepository \ No newline at end of file +1. Create new branch `release/X.Y.Z` from `master` branch +2. Update **ktorfit** version inside `gradle/libs.versions.toml` +3. Update Compatibility table in Readme.md +4. Update ktorfit release version in mkdocs.yml +5. `git commit -am "Release X.Y.Z."` (where X.Y.Z is the new version) +6. Push and create a PR to the `master` branch +7. When all checks successful, run GitHub Action `Publish Release` from your branch +8. Set the Git tag `git tag -a X.Y.Z -m "X.Y.Z"` (where X.Y.Z is the new version) +9. Merge the PR +10. Create a new release with for the Tag on GitHub +11. Put the relevant changelog in the release description \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 8baa7b372..ef503a0e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,9 +28,7 @@ subprojects { google() mavenLocal() mavenCentral() - } - } // ./gradlew clean :sandbox:compileKotlinJvm --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n" \ No newline at end of file diff --git a/gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitCompilerSubPlugin.kt b/gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitCompilerSubPlugin.kt index 817014105..4115490a8 100644 --- a/gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitCompilerSubPlugin.kt +++ b/gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitCompilerSubPlugin.kt @@ -22,11 +22,10 @@ internal class KtorfitCompilerSubPlugin : KotlinCompilerPluginSupportPlugin { ?: KtorfitGradleConfiguration() return kotlinCompilation.target.project.provider { - val options = mutableListOf( + listOf( SubpluginOption("enabled", gradleExtension.enabled.toString()), SubpluginOption("logging", gradleExtension.logging.toString()) ) - options } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d5ce28972..265279d20 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,7 +41,6 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorVer ktor-client-core-jvm = { module = "io.ktor:ktor-client-core-jvm", version.ref = "ktorVersion" } ktor-client-core-linux = { module = "io.ktor:ktor-client-core-linuxx64", version.ref = "ktorVersion" } ktor-client-core-mingwx64 = { module = "io.ktor:ktor-client-core-mingwx64", version.ref = "ktorVersion" } -ktor-client-core-native = "io.ktor:ktor-client-core-native:1.3.1" ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktorVersion" } ktor-client-ios = { module = "io.ktor:ktor-client-ios", version.ref = "ktorVersion" } ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktorVersion" } @@ -55,7 +54,6 @@ ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.8.0" logbackClassic = "ch.qos.logback:logback-classic:1.4.11" mockito-kotlin = "org.mockito.kotlin:mockito-kotlin:4.1.0" -rxjava3 = "io.reactivex.rxjava3:rxjava:3.1.6" truth = "com.google.truth:truth:1.1.5" [plugins] diff --git a/ktorfit-converters/call/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/CallResponseConverter.kt b/ktorfit-converters/call/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/CallResponseConverter.kt index 4f6b4c1d5..301f3ff05 100644 --- a/ktorfit-converters/call/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/CallResponseConverter.kt +++ b/ktorfit-converters/call/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/CallResponseConverter.kt @@ -34,10 +34,8 @@ public class CallResponseConverter : SuspendResponseConverter, ResponseConverter } catch (ex: Exception) { callBack.onError(ex) } - } } - } } diff --git a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/HeaderCodeGenerator.kt b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/HeaderCodeGenerator.kt index 50e4b16a2..4e7d2c87e 100644 --- a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/HeaderCodeGenerator.kt +++ b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/HeaderCodeGenerator.kt @@ -18,10 +18,6 @@ fun getHeadersCode( arrayType: KSType ): String { - val contentTypeText = if (functionAnnotations.anyInstance()) { - "append(\"Content-Type\", \"application/x-www-form-urlencoded\")\n" - } else "" - val headerAnnotationText = parameterDataList .filter { it.hasAnnotation
() } @@ -60,6 +56,10 @@ fun getHeadersCode( "${it.name}?.forEach { append(it.key, \"\${it.value}\") }\n" } + val contentTypeText = if (functionAnnotations.anyInstance()) { + "append(\"Content-Type\", \"application/x-www-form-urlencoded\")\n" + } else "" + return "$contentTypeText$headerAnnotationText$headerMapAnnotationText$headersAnnotationText".surroundIfNotEmpty( "headers{\n", "}" diff --git a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/DefaultSuspendResponseConverterFactory.kt b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/DefaultSuspendResponseConverterFactory.kt index 146a46124..ca4364bf8 100644 --- a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/DefaultSuspendResponseConverterFactory.kt +++ b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/DefaultSuspendResponseConverterFactory.kt @@ -14,11 +14,7 @@ internal class DefaultSuspendResponseConverterFactory : Converter.Factory { class DefaultSuspendResponseConverter(val typeData: TypeData) : Converter.SuspendResponseConverter { override suspend fun convert(response: HttpResponse): Any { - return try { - response.call.body(typeData.typeInfo) - } catch (exception: Exception) { - throw exception - } + return response.call.body(typeData.typeInfo) } } diff --git a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/KtorfitDefaultConverterFactory.kt b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/KtorfitDefaultConverterFactory.kt index bddd99912..dd273db81 100644 --- a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/KtorfitDefaultConverterFactory.kt +++ b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/converter/builtin/KtorfitDefaultConverterFactory.kt @@ -16,31 +16,29 @@ internal class KtorfitDefaultConverterFactory : Converter.Factory { Converter.SuspendResponseConverter> { override suspend fun convert(response: HttpResponse): Response { val typeInfo = typeData.typeArgs.first().typeInfo - return try { - val rawResponse = response - - val code: Int = rawResponse.status.value - when { - code < 200 || code >= 300 -> { - val errorBody = rawResponse.body() - Response.error(errorBody, rawResponse) - } - - code == 204 || code == 205 -> { - Response.success(null, rawResponse) - } - - else -> { - val convertedBody = ktorfit.nextSuspendResponseConverter( - null, - typeData.typeArgs.first() - )?.convert(rawResponse) - ?: rawResponse.body(typeInfo) - Response.success(convertedBody, rawResponse) - } + + val rawResponse = response + + val code: Int = rawResponse.status.value + + return when { + code < 200 || code >= 300 -> { + val errorBody = rawResponse.body() + Response.error(errorBody, rawResponse) + } + + code == 204 || code == 205 -> { + Response.success(null, rawResponse) + } + + else -> { + val convertedBody = ktorfit.nextSuspendResponseConverter( + null, + typeData.typeArgs.first() + )?.convert(rawResponse) + ?: rawResponse.body(typeInfo) + Response.success(convertedBody, rawResponse) } - } catch (exception: Exception) { - throw exception } } } diff --git a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClient.kt b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClient.kt index ca6b2fda4..8cc8c6390 100644 --- a/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClient.kt +++ b/ktorfit-lib-common/src/commonMain/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClient.kt @@ -70,13 +70,6 @@ internal class KtorfitClient(private val ktorfit: Ktorfit) : Client { } as ReturnType } - if (returnTypeData.typeInfo.type == HttpResponse::class) { - val response = httpClient.request { - requestBuilder(requestData) - } - return response as ReturnType - } - ktorfit.nextSuspendResponseConverter(null, returnTypeData)?.let { val response = httpClient.request { @@ -124,6 +117,4 @@ internal class KtorfitClient(private val ktorfit: Ktorfit) : Client { ) { requestData.ktorfitRequestBuilder(this) } - - } diff --git a/sandbox/build.gradle.kts b/sandbox/build.gradle.kts index 4c1454e02..3d6116dcb 100644 --- a/sandbox/build.gradle.kts +++ b/sandbox/build.gradle.kts @@ -68,8 +68,6 @@ kotlin { } val linuxX64Main by getting { dependencies { - - implementation(libs.ktor.client.core.native) implementation(libs.kotlinx.coroutines.core) implementation(libs.ktor.client.curl) implementation(libs.ktor.client.core.linux) @@ -85,7 +83,7 @@ kotlin { dependencies { implementation(libs.ktor.client.core.jvm) implementation(libs.kotlinx.coroutines.rx3) - implementation(libs.rxjava3) + implementation("io.reactivex.rxjava3:rxjava:3.1.7") implementation(libs.ktor.client.logging) // implementation(libs.logbackClassic)