Skip to content

Commit

Permalink
Initial setup for KMP
Browse files Browse the repository at this point in the history
  • Loading branch information
gabfssilva committed Jan 22, 2024
1 parent 5e5651d commit a0d9ef1
Show file tree
Hide file tree
Showing 217 changed files with 1,007 additions and 663 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ build
.idea/
volume/
.DS_Store
data/
data/
kotlin-js-store/
local.properties
136 changes: 105 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)

import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import com.android.build.gradle.LibraryExtension as AndroidExtension

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.android) apply false
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotest.multiplatform)
alias(libs.plugins.dokka)
alias(libs.plugins.nexus.publish) apply false
alias(libs.plugins.setup.android.sdk)

`maven-publish`
signing
`java-library`
}

group = "com.river-kt"

repositories {
mavenCentral()
google()
}

tasks.dokkaHtmlMultiModule.configure {
Expand All @@ -20,24 +30,90 @@ tasks.dokkaHtmlMultiModule.configure {
moduleName.set(project.name)
}

kotlin {
jvm {
withSourcesJar(false)
}
}

setupAndroidSdk {
sdkToolsVersion("11076708_latest")
}

subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.multiplatform")
apply(plugin = "io.kotest.multiplatform")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "java-library")
apply(plugin = "signing")

version = "1.0.0-alpha12"

version = "1.0.0-alpha13"
group = "com.river-kt"

java {
withJavadocJar()
withSourcesJar()
kotlin {
jvmToolchain(17)

compilerOptions {
freeCompilerArgs = listOf("-Xcontext-receivers")
}

jvm().compilations.all {
compilerOptions.configure {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers")
}
}

sourceSets {
val commonMain by getting {
dependencies {
api(rootProject.libs.coroutines)
api(rootProject.libs.kotlinx.datetime)
}
}

val commonTest by getting {
dependencies {
api(rootProject.libs.kotest.assertions.core)
api(rootProject.libs.kotest.engine)
api(rootProject.libs.turbine)
api(rootProject.libs.kotlin.reflect)
}

languageSettings {
optIn("com.river.core.ExperimentalRiverApi")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}

val jvmTest by getting {
dependencies {
api(rootProject.libs.kotest.junit5)
}
}

afterEvaluate {
if (androidEnabled()) {
val androidUnitTest by getting {
dependencies {
implementation(rootProject.libs.kotest.junit5)
}
}
}
}
}
}

pluginManager.withPlugin("com.android.library") {
extensions.configure<AndroidExtension> {
namespace = "com.river"
compileSdk = 30
}
}

repositories {
mavenCentral()
google()
}

tasks.withType<Test>().configureEach {
Expand Down Expand Up @@ -79,15 +155,15 @@ subprojects {
artifactId = project.name
version = "${project.version}"

artifact(tasks["jar"])

artifact(tasks["sourcesJar"]) {
classifier = "sources"
}

artifact(tasks["javadocJar"]) {
classifier = "javadoc"
}
// artifact(tasks["jar"])
//
// artifact(tasks["sourcesJar"]) {
// classifier = "sources"
// }
//
// artifact(tasks["javadocJar"]) {
// classifier = "javadoc"
// }

pom {
name.set(project.name)
Expand Down Expand Up @@ -118,7 +194,9 @@ subprojects {

withXml {
asNode().appendNode("dependencies").apply {
for (dependency in configurations["api"].dependencies) {
val dependencies = configurations.asMap["api"]?.dependencies ?: emptySet()

for (dependency in dependencies) {
appendNode("dependency").apply {
appendNode("groupId", dependency.group)
appendNode("artifactId", dependency.name)
Expand Down Expand Up @@ -163,7 +241,7 @@ subprojects {
useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword)

sign(publishing.publications["maven"])
sign(tasks["javadocJar"])
// sign(tasks["javadocJar"])
}

tasks.withType<PublishToMavenRepository>().configureEach {
Expand All @@ -183,19 +261,15 @@ subprojects {
)
}

tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}

dependencies {
api(rootProject.libs.coroutines)
testImplementation(rootProject.libs.kotest.junit5)
testImplementation(rootProject.libs.turbine)
}
// tasks.javadoc {
// if (JavaVersion.current().isJava9Compatible) {
// (options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
// }
// }
}

fun Task.skipExamples() {
onlyIf { !project.path.contains("examples") }
}

fun Project.androidEnabled() = pluginManager.hasPlugin("com.android.library")
52 changes: 16 additions & 36 deletions buildSrc/src/main/kotlin/Dependency.kt
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.project

object Modules {
val core =
Module(":core")

val awsHttp11Spi =
Module(":connector:connector-aws:connector-aws-java-11-http-spi")

val http =
Module(":connector:connector-http")

val debezium =
Module(":connector:connector-red-hat:connector-red-hat-debezium")

val json =
Module(":connector:connector-format:connector-format-json")

val csv =
Module(":connector:connector-format:connector-format-csv")

val s3 =
Module(":connector:connector-aws:connector-aws-s3")

val sqs =
Module(":connector:connector-aws:connector-aws-sqs")

val sns =
Module(":connector:connector-aws:connector-aws-sns")

val jdbc =
Module(":connector:connector-rdbms:connector-rdbms-jdbc")

val file =
Module(":connector:connector-file")
class Modules(val project: (String) -> ProjectDependency) {
val core by lazy { project(":core") }
val http by lazy { project(":connector:connector-http") }
val awsHttp11Spi by lazy { project(":connector:connector-aws:connector-aws-java-11-http-spi") }
val debezium by lazy { project(":connector:connector-red-hat:connector-red-hat-debezium") }
val json by lazy { project(":connector:connector-format:connector-format-json") }
val csv by lazy { project(":connector:connector-format:connector-format-csv") }
val s3 by lazy { project(":connector:connector-aws:connector-aws-s3") }
val sqs by lazy { project(":connector:connector-aws:connector-aws-sqs") }
val sns by lazy { project(":connector:connector-aws:connector-aws-sns") }
val jdbc by lazy { project(":connector:connector-rdbms:connector-rdbms-jdbc") }
val file by lazy { project(":connector:connector-file") }
}

class Module(val name: String)
val DependencyHandler.modules
get() = Modules { project(it) }

val Project.modules
get() = Modules
fun modules(project: (String) -> ProjectDependency) = Modules(project)

fun DependencyHandler.api(module: Module): Dependency? =
add("api", this.project(module.name))
Expand Down
10 changes: 8 additions & 2 deletions connectors/amqp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
dependencies {
api(libs.amqp)
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(libs.amqp)
}
}
}
}
12 changes: 9 additions & 3 deletions connectors/apache/kafka/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
dependencies {
api(libs.reactor.kafka)
api(libs.coroutines.reactive)
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(libs.reactor.kafka)
api(libs.coroutines.reactive)
}
}
}
}
25 changes: 19 additions & 6 deletions connectors/aws/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
subprojects {
dependencies {
api(rootProject.modules.http)
kotlin {
jvm {
configurations.all {
exclude("software.amazon.awssdk", "netty-nio-client")
}
}

sourceSets {
val jvmMain by getting {
dependencies {
val modules = modules { project(it) }

api(rootProject.libs.aws.http.client.spi)
api(rootProject.libs.coroutines.reactive)
api(modules.http)
api(rootProject.libs.aws.http.client.spi)
api(rootProject.libs.coroutines.reactive)

if (project.name != "connector-aws-java-11-http-spi") {
api(rootProject.modules.awsHttp11Spi)
if (project.name != "connector-aws-java-11-http-spi") {
api(modules.awsHttp11Spi)
}
}
}
}
}
}
4 changes: 2 additions & 2 deletions connectors/aws/dynamodb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
//dependencies {
// implementation(libs.aws.dynamodb)
}
//}
7 changes: 7 additions & 0 deletions connectors/aws/java-11-http-spi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kotlin {
sourceSets {
val jvmMain by getting {

}
}
}
10 changes: 7 additions & 3 deletions connectors/aws/lambda/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies {
api(libs.aws.lambda) {
exclude("software.amazon.awssdk", "netty-nio-client")
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(rootProject.libs.aws.lambda)
}
}
}
}
10 changes: 7 additions & 3 deletions connectors/aws/s3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies {
api(libs.aws.s3) {
exclude("software.amazon.awssdk", "netty-nio-client")
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(rootProject.libs.aws.s3)
}
}
}
}
10 changes: 7 additions & 3 deletions connectors/aws/ses/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies {
api(libs.aws.ses) {
exclude("software.amazon.awssdk", "netty-nio-client")
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(rootProject.libs.aws.ses)
}
}
}
}
10 changes: 7 additions & 3 deletions connectors/aws/sns/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies {
api(libs.aws.sns) {
exclude("software.amazon.awssdk", "netty-nio-client")
kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(rootProject.libs.aws.sns)
}
}
}
}
Loading

0 comments on commit a0d9ef1

Please sign in to comment.