Skip to content

Commit

Permalink
Create languageSettings extension and remove warnings by adding the c…
Browse files Browse the repository at this point in the history
…orrect imports to the right module.
  • Loading branch information
thomaskioko committed Nov 11, 2024
1 parent 0051e6c commit 0a3b6a7
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

class KotlinMultiplatformConventionPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
Expand Down Expand Up @@ -44,18 +45,10 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
sourceSets.all {
languageSettings {
listOf(
"androidx.paging.ExperimentalPagingApi",
"kotlin.RequiresOptIn",
"kotlin.experimental.ExperimentalObjCName",
"kotlin.time.ExperimentalTime",
"kotlinx.cinterop.BetaInteropApi",
"kotlinx.cinterop.ExperimentalForeignApi",
"kotlinx.coroutines.DelicateCoroutinesApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.FlowPreview",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"org.mobilenativefoundation.store.store5.ExperimentalStoreApi",
).forEach { optIn(it) }
}
}
Expand Down Expand Up @@ -103,6 +96,16 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
}
}

fun Project.addLanguageArgs(vararg args: String){
extensions.configure<KotlinMultiplatformExtension> {
sourceSets.all {
languageSettings {
args.forEach { optIn(it) }
}
}
}
}

fun Project.addKspDependencyForAllTargets(dependencyNotation: Any) = addKspDependencyForAllTargets("", dependencyNotation)
private fun Project.addKspDependencyForAllTargets(
configurationNameSuffix: String,
Expand Down
6 changes: 6 additions & 0 deletions core/base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.android.library)
alias(libs.plugins.tvmaniac.multiplatform)
Expand All @@ -16,3 +18,7 @@ kotlin {
}

android { namespace = "com.thomaskioko.tvmaniac.core.base" }

addLanguageArgs(
"kotlinx.coroutines.InternalCoroutinesApi",
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Delay
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.Runnable
import platform.darwin.DISPATCH_TIME_NOW
import platform.darwin.dispatch_after
Expand All @@ -16,7 +15,6 @@ import platform.darwin.dispatch_time

val applicationNsQueueDispatcher: CoroutineDispatcher = NsQueueDispatcher(dispatch_get_main_queue())

@InternalCoroutinesApi
internal class NsQueueDispatcher(private val dispatchQueue: dispatch_queue_t) :
CoroutineDispatcher(), Delay {

Expand Down
6 changes: 6 additions & 0 deletions core/paging/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins { id("plugin.tvmaniac.multiplatform") }

kotlin {
Expand All @@ -10,3 +12,7 @@ kotlin {
}
}
}

addLanguageArgs(
"androidx.paging.ExperimentalPagingApi",
)
7 changes: 7 additions & 0 deletions core/util/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addKspDependencyForAllTargets
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.android.library)
Expand Down Expand Up @@ -35,3 +36,9 @@ android {
}

addKspDependencyForAllTargets(libs.kotlinInject.compiler)

addLanguageArgs(
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.cinterop.ExperimentalForeignApi",
"kotlinx.cinterop.BetaInteropApi",
)
6 changes: 6 additions & 0 deletions data/popularshows/implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.multiplatform)
alias(libs.plugins.ksp)
Expand Down Expand Up @@ -29,3 +31,7 @@ kotlin {
commonTest { dependencies { implementation(libs.bundles.unittest) } }
}
}

addLanguageArgs(
"androidx.paging.ExperimentalPagingApi",
)
6 changes: 6 additions & 0 deletions data/request-manager/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins { alias(libs.plugins.tvmaniac.multiplatform) }

kotlin {
Expand All @@ -10,3 +12,7 @@ kotlin {
}
}
}

addLanguageArgs(
"kotlinx.coroutines.ExperimentalCoroutinesApi",
)
6 changes: 6 additions & 0 deletions data/topratedshows/implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.multiplatform)
alias(libs.plugins.ksp)
Expand Down Expand Up @@ -26,3 +28,7 @@ kotlin {
}
}
}

addLanguageArgs(
"androidx.paging.ExperimentalPagingApi",
)
6 changes: 6 additions & 0 deletions data/trendingshows/implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.multiplatform)
alias(libs.plugins.ksp)
Expand Down Expand Up @@ -26,3 +28,7 @@ kotlin {
}
}
}

addLanguageArgs(
"androidx.paging.ExperimentalPagingApi",
)
6 changes: 6 additions & 0 deletions data/upcomingshows/implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.multiplatform)
alias(libs.plugins.ksp)
Expand Down Expand Up @@ -26,3 +28,7 @@ kotlin {
}
}
}

addLanguageArgs(
"androidx.paging.ExperimentalPagingApi",
)
7 changes: 7 additions & 0 deletions datastore/implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addKspDependencyForAllTargets
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins {
alias(libs.plugins.tvmaniac.android.library)
Expand Down Expand Up @@ -26,3 +27,9 @@ kotlin {
addKspDependencyForAllTargets(libs.kotlinInject.compiler)

android { namespace = "com.thomaskioko.tvmaniac.shared.domain.datastore.implementation" }

addLanguageArgs(
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.cinterop.ExperimentalForeignApi"
)
6 changes: 6 additions & 0 deletions presentation/search/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.thomaskioko.tvmaniac.plugins.addLanguageArgs

plugins { id("plugin.tvmaniac.multiplatform") }

kotlin {
Expand Down Expand Up @@ -33,3 +35,7 @@ kotlin {
}
}
}

addLanguageArgs(
"kotlinx.coroutines.ExperimentalCoroutinesApi",
)

0 comments on commit 0a3b6a7

Please sign in to comment.