Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repositories {

dependencies {
implementation(libs.kotlin.multiplatform.gradle)
implementation(libs.android.library)
implementation(libs.android.gradle.plugin)
implementation(libs.detekt.gradle)
implementation(libs.dokka.gradle)
Expand Down
65 changes: 39 additions & 26 deletions buildSrc/src/main/kotlin/Android.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.android.build.api.dsl.ApplicationExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

fun Project.configureLibraryAndroidTarget(
fun KotlinMultiplatformExtension.configureLibraryAndroidTarget(
namespace: String? = null,
minSdk: Int = 23,
javaVersion: JavaVersion = JavaVersion.VERSION_1_8
javaVersion: JvmTarget = JvmTarget.JVM_1_8
) {
extensions.configure(LibraryExtension::class) {
compileSdk = 36
android {
this.namespace = namespace ?: "${project.extra["base-group"].toString().replace("-", ".")}.${this@configureLibraryAndroidTarget.project.name.replace("-", "")}.library"
compileSdk = 37
this.minSdk = minSdk
compilerOptions {
jvmTarget.set(javaVersion)
}
lint {
abortOnError = false
}
}
/*extensions.configure(LibraryExtension::class) {
compileSdk = 37
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
this.namespace = namespace ?: "${extra["base-group"].toString().replace("-", ".")}.${this@configureLibraryAndroidTarget.name.replace("-", "")}.library"
this.namespace =
defaultConfig {
this.minSdk = minSdk
}
Expand All @@ -25,27 +35,30 @@ fun Project.configureLibraryAndroidTarget(
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
}
}*/

}

fun BaseAppModuleExtension.configureApplicationAndroidTarget(
fun Project.configureApplicationAndroidTarget(
javaVersion: JavaVersion = JavaVersion.VERSION_1_8
) {
compileSdk = 36
defaultConfig {
applicationId = "io.github.jan.supabase.android"
minSdk = 26
versionCode = 1
versionName = "1.0-SNAPSHOT"
}
namespace = "io.github.jan.supabase.android"
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure<ApplicationExtension>("android") {
compileSdk = 37
defaultConfig {
applicationId = "io.github.jan.supabase.android"
minSdk = 26
versionCode = 1
versionName = "1.0-SNAPSHOT"
}
namespace = "io.github.jan.supabase.android"
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
}
22 changes: 14 additions & 8 deletions buildSrc/src/main/kotlin/KotlinTargets.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.dsl.androidLibrary

import com.android.build.api.dsl.KotlinMultiplatformAndroidLibraryTarget
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.extra
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
Expand Down Expand Up @@ -44,18 +45,23 @@ fun KotlinMultiplatformExtension.configuredJvmTarget(jvmTarget: JvmTarget = JvmT
fun KotlinMultiplatformExtension.configuredAndroidTarget(
jvmTarget: JvmTarget = JvmTarget.JVM_1_8,
) {
androidLibrary {
compileSdk = 36
minSdk = 23
android {
compileSdk { version = release(37) }
minSdk { version = release(23) }
this.namespace = namespace ?: "${project.extra["base-group"].toString().replace("-", ".")}.${project.name.replace("-", "")}.library"
compilations.configureEach {
compilerOptions.configure {
this.jvmTarget.set(jvmTarget)
}
compilerOptions {
this.jvmTarget.set(jvmTarget)
}
}
}

// workaround because the method somehow does not exist in convention plugins
fun KotlinMultiplatformExtension.android(configure: KotlinMultiplatformAndroidLibraryTarget.() -> Unit) {
(extensions.getByName("android") as KotlinMultiplatformAndroidLibraryTarget).apply {
configure()
}
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
fun KotlinMultiplatformExtension.jvmTargets(jvmTarget: JvmTarget = JvmTarget.JVM_1_8) {
configuredAndroidTarget(jvmTarget)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
kotlin.code.style=official
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096m
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.native.ignoreDisabledTargets=true
org.gradle.parallel=true
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
android.enableLegacyVariantApi=true

org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-startup = "1.2.0"
androidx-activity-compose = "1.13.0"
multiplatform-settings = "1.3.0"
complete-kotlin = "1.1.0"
agp = "8.11.1"
agp = "9.2.1"
maven-publish = "0.36.0"
apollo-kotlin = "5.0.0"
serialization = "1.11.0"
Expand All @@ -24,7 +24,7 @@ compose = "1.11.1"
coil2 = "2.7.0"
okio = "3.17.0"
koin = "4.2.2"
androidx-core = "1.18.0"
androidx-core = "1.19.0"
androidx-compat = "1.7.1"
androidx-lifecycle = "2.10.0"
filekit = "0.8.8"
Expand Down Expand Up @@ -67,6 +67,7 @@ detekt-gradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", v
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
publishing-gradle = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
compose-gradle = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "compose" }
android-library = { module = "com.android.kotlin.multiplatform.library:com.android.kotlin.multiplatform.library.gradle.plugin", version.ref = "agp"}

ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
Expand Down
5 changes: 1 addition & 4 deletions sample/chat-demo-mpp/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id("com.android.application")
id(libs.plugins.kotlin.android.get().pluginId)
alias(libs.plugins.kotlinx.plugin.serialization)
}

Expand All @@ -16,9 +15,7 @@ dependencies {
implementation(libs.androidx.activity.compose)
}

android {
configureApplicationAndroidTarget(JavaVersion.VERSION_11)
}
configureApplicationAndroidTarget(JavaVersion.VERSION_11)

kotlin {
compilerOptions {
Expand Down
6 changes: 3 additions & 3 deletions sample/chat-demo-mpp/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id(libs.plugins.kotlin.multiplatform.get().pluginId)
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.android.kotlin.multiplatform.library.get().pluginId)
alias(libs.plugins.kotlinx.plugin.serialization)
}

Expand All @@ -26,7 +26,7 @@ kotlin {
}
}
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
androidTarget()
configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JvmTarget.JVM_11)
jvmToolchain(11)
jvm("desktop") {
compilerOptions {
Expand Down Expand Up @@ -90,4 +90,4 @@ kotlin {
}
}

configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JavaVersion.VERSION_11)
//configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JavaVersion.VERSION_11)
5 changes: 1 addition & 4 deletions sample/file-upload/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id("com.android.application")
id(libs.plugins.kotlin.android.get().pluginId)
alias(libs.plugins.kotlinx.plugin.serialization)
}

Expand All @@ -17,9 +16,7 @@ dependencies {
implementation(libs.accompanist.permissions)
}

android {
configureApplicationAndroidTarget(JavaVersion.VERSION_11)
}
configureApplicationAndroidTarget(JavaVersion.VERSION_11)

kotlin {
compilerOptions {
Expand Down
6 changes: 2 additions & 4 deletions sample/file-upload/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id(libs.plugins.kotlin.multiplatform.get().pluginId)
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.android.kotlin.multiplatform.library.get().pluginId)
alias(libs.plugins.kotlinx.plugin.serialization)
}

Expand All @@ -22,7 +22,7 @@ repositories {

kotlin {
jvmToolchain(11)
androidTarget()
configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JvmTarget.JVM_11)
jvm("desktop") {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
Expand Down Expand Up @@ -71,5 +71,3 @@ kotlin {
}
}
}

configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JavaVersion.VERSION_11)
5 changes: 1 addition & 4 deletions sample/multi-factor-auth/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id("com.android.application")
id(libs.plugins.kotlin.android.get().pluginId)
alias(libs.plugins.kotlinx.plugin.serialization)
}

Expand All @@ -16,9 +15,7 @@ dependencies {
implementation(project(":sample:multi-factor-auth:common"))
}

android {
configureApplicationAndroidTarget(JavaVersion.VERSION_11)
}
configureApplicationAndroidTarget(JavaVersion.VERSION_11)

kotlin {
compilerOptions {
Expand Down
5 changes: 2 additions & 3 deletions sample/multi-factor-auth/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.android.kotlin.multiplatform.library.get().pluginId)
id(libs.plugins.compose.plugin.get().pluginId)
alias(libs.plugins.compose.compiler)
id(libs.plugins.kotlin.multiplatform.get().pluginId)
Expand All @@ -16,7 +16,7 @@ version = "1.0-SNAPSHOT"
@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
jvmToolchain(11)
androidTarget()
configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JvmTarget.JVM_11)
jvm("desktop") {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
Expand Down Expand Up @@ -75,4 +75,3 @@ kotlin {
}
}

configureLibraryAndroidTarget("io.github.jan.supabase.common", 26, JavaVersion.VERSION_11)
Loading