-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Flow converter to own module (#432)
- Loading branch information
Showing
20 changed files
with
300 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradleConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.jensklingenberg.ktorfit.gradle | ||
|
||
open class KtorfitGradleConfiguration { | ||
/** | ||
* If the compiler plugin should be active | ||
*/ | ||
var enabled: Boolean = true | ||
|
||
/** | ||
* version number of the compiler plugin | ||
*/ | ||
@Deprecated("Update the this Gradle plugin instead of updating this version") | ||
var version: String = "1.7.0" // remember to bump this version before any release! | ||
|
||
/** | ||
* used to get debug information from the compiler plugin | ||
*/ | ||
var logging: Boolean = false | ||
} |
48 changes: 48 additions & 0 deletions
48
gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradlePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package de.jensklingenberg.ktorfit.gradle | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.findByType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension | ||
|
||
|
||
|
||
class KtorfitGradlePlugin : Plugin<Project> { | ||
companion object { | ||
const val GRADLE_TASKNAME = "ktorfit" | ||
} | ||
|
||
private val Project.kotlinExtension: KotlinProjectExtension? | ||
get() = this.extensions.findByType<KotlinProjectExtension>() | ||
|
||
override fun apply(project: Project) { | ||
|
||
with(project) { | ||
extensions.create(GRADLE_TASKNAME, KtorfitGradleConfiguration::class.java) | ||
|
||
val flowConverterDependencyNotation = "de.jensklingenberg.ktorfit:ktorfit-converters-flow:1.7.0" | ||
when (kotlinExtension) { | ||
is KotlinSingleTargetExtension<*> -> { | ||
dependencies { | ||
add("implementation", flowConverterDependencyNotation) | ||
} | ||
} | ||
|
||
is KotlinMultiplatformExtension -> { | ||
dependencies { | ||
add("commonMainImplementation", flowConverterDependencyNotation) | ||
} | ||
} | ||
|
||
else -> { /* Do nothing */ | ||
} | ||
} | ||
} | ||
project.pluginManager.apply(KtorfitCompilerSubPlugin::class.java) | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
/.gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
public final class de/jensklingenberg/ktorfit/converter/builtin/FlowConverterFactory : de/jensklingenberg/ktorfit/converter/Converter$Factory { | ||
public fun <init> ()V | ||
public fun requestParameterConverter (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;)Lde/jensklingenberg/ktorfit/converter/Converter$RequestParameterConverter; | ||
public fun responseConverter (Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$ResponseConverter; | ||
public fun suspendResponseConverter (Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$SuspendResponseConverter; | ||
} | ||
|
||
public final class de/jensklingenberg/ktorfit/converter/builtin/FlowResponseConverter : de/jensklingenberg/ktorfit/converter/request/ResponseConverter { | ||
public fun <init> ()V | ||
public fun supportedType (Lde/jensklingenberg/ktorfit/internal/TypeData;Z)Z | ||
public fun wrapResponse (Lde/jensklingenberg/ktorfit/internal/TypeData;Lkotlin/jvm/functions/Function1;Lde/jensklingenberg/ktorfit/Ktorfit;)Ljava/lang/Object; | ||
} | ||
|
||
public final class de/jensklingenberg/ktorfit/converters/flow/BuildConfig { | ||
public static final field BUILD_TYPE Ljava/lang/String; | ||
public static final field DEBUG Z | ||
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; | ||
public fun <init> ()V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
public final class de/jensklingenberg/ktorfit/converter/builtin/FlowConverterFactory : de/jensklingenberg/ktorfit/converter/Converter$Factory { | ||
public fun <init> ()V | ||
public fun requestParameterConverter (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;)Lde/jensklingenberg/ktorfit/converter/Converter$RequestParameterConverter; | ||
public fun responseConverter (Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$ResponseConverter; | ||
public fun suspendResponseConverter (Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$SuspendResponseConverter; | ||
} | ||
|
||
public final class de/jensklingenberg/ktorfit/converter/builtin/FlowResponseConverter : de/jensklingenberg/ktorfit/converter/request/ResponseConverter { | ||
public fun <init> ()V | ||
public fun supportedType (Lde/jensklingenberg/ktorfit/internal/TypeData;Z)Z | ||
public fun wrapResponse (Lde/jensklingenberg/ktorfit/internal/TypeData;Lkotlin/jvm/functions/Function1;Lde/jensklingenberg/ktorfit/Ktorfit;)Ljava/lang/Object; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
id("maven-publish") | ||
id("signing") | ||
id("com.vanniktech.maven.publish") | ||
id("com.android.library") | ||
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" | ||
id("app.cash.licensee") | ||
} | ||
|
||
licensee { | ||
allow("Apache-2.0") | ||
allow("MIT") | ||
} | ||
|
||
|
||
val enableSigning = project.hasProperty("ORG_GRADLE_PROJECT_signingInMemoryKey") | ||
|
||
mavenPublishing { | ||
|
||
coordinates( | ||
"de.jensklingenberg.ktorfit", | ||
"ktorfit-converters-flow", | ||
libs.versions.ktorfit.asProvider().get() | ||
) | ||
publishToMavenCentral() | ||
// publishToMavenCentral(SonatypeHost.S01) for publishing through s01.oss.sonatype.org | ||
if (enableSigning) { | ||
signAllPublications() | ||
} | ||
} | ||
|
||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
|
||
kotlin { | ||
explicitApi() | ||
jvm { | ||
|
||
} | ||
js(IR) { | ||
this.nodejs() | ||
binaries.executable() // not applicable to BOTH, see details below | ||
} | ||
androidTarget { | ||
publishLibraryVariants("release", "debug") | ||
} | ||
iosArm64() | ||
iosX64() | ||
iosSimulatorArm64() | ||
|
||
watchosArm32() | ||
watchosArm64() | ||
watchosX64() | ||
watchosSimulatorArm64() | ||
tvosArm64() | ||
tvosX64() | ||
tvosSimulatorArm64() | ||
macosX64() | ||
macosArm64() | ||
linuxX64 { | ||
binaries { | ||
executable() | ||
} | ||
} | ||
|
||
ios("ios") { | ||
binaries { | ||
framework { | ||
baseName = "library" | ||
} | ||
} | ||
} | ||
mingwX64() | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation(projects.ktorfitLibCommon) | ||
} | ||
} | ||
val linuxX64Main by getting | ||
val mingwX64Main by getting | ||
val androidMain by getting | ||
val jvmMain by getting | ||
val iosX64Main by getting | ||
val iosArm64Main by getting | ||
val iosSimulatorArm64Main by getting | ||
val jsMain by getting | ||
val iosMain by getting { | ||
dependsOn(commonMain) | ||
iosX64Main.dependsOn(this) | ||
iosArm64Main.dependsOn(this) | ||
iosSimulatorArm64Main.dependsOn(this) | ||
dependencies { | ||
|
||
} | ||
} | ||
} | ||
} | ||
val javadocJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
android { | ||
compileSdk = 33 | ||
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") | ||
defaultConfig { | ||
minSdk = 21 | ||
targetSdk = 33 | ||
} | ||
namespace = "de.jensklingenberg.ktorfit.converters.flow" | ||
} | ||
|
||
|
||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("default") { | ||
artifact(tasks["sourcesJar"]) | ||
// artifact(tasks["javadocJar"]) | ||
|
||
pom { | ||
name.set(project.name) | ||
description.set("Flow Converter for Ktorfit") | ||
url.set("https://github.com/Foso/Ktorfit") | ||
|
||
licenses { | ||
license { | ||
name.set("Apache License 2.0") | ||
url.set("https://github.com/Foso/Ktorfit/blob/master/LICENSE.txt") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/Foso/Ktorfit") | ||
connection.set("scm:git:git://github.com/Foso/Ktorfit.git") | ||
} | ||
developers { | ||
developer { | ||
name.set("Jens Klingenberg") | ||
url.set("https://github.com/Foso") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
if ( | ||
hasProperty("sonatypeUsername") && | ||
hasProperty("sonatypePassword") && | ||
hasProperty("sonatypeSnapshotUrl") && | ||
hasProperty("sonatypeReleaseUrl") | ||
) { | ||
maven { | ||
val url = when { | ||
"SNAPSHOT" in version.toString() -> property("sonatypeSnapshotUrl") | ||
else -> property("sonatypeReleaseUrl") | ||
} as String | ||
setUrl(url) | ||
credentials { | ||
username = property("sonatypeUsername") as String | ||
password = property("sonatypePassword") as String | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class) { | ||
rootProject.the(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class).nodeVersion = "18.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kotlin.mpp.androidSourceSetLayoutVersion=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.