Skip to content

Commit

Permalink
Fixing private target api use (#154)
Browse files Browse the repository at this point in the history
* [MISC] Fixing private api targets usage

This patch fixes usages of private targes api

* update samples
  • Loading branch information
MarcoSignoretto authored Nov 14, 2024
1 parent f57caae commit 22f556b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget

class MockingbirdPluginKspDelegate {
private val targetConfigurationFactory: TargetConfigurationFactory by lazy { TargetConfigurationFactory() }
Expand All @@ -44,7 +47,7 @@ class MockingbirdPluginKspDelegate {
// in commonTest. The plugin will add this the code generated at point 1 as source set for common test so that
// this code will be available for each platform and resolvable by the IDE

val kotlin = project.kotlinExtension
val kotlin: KotlinProjectExtension = project.kotlinExtension

val jvmTarget = kotlin.targets.firstOrNull { it.platformType == KotlinPlatformType.jvm }
?: kotlin.targets.firstOrNull { it.platformType == KotlinPlatformType.androidJvm }
Expand Down Expand Up @@ -80,7 +83,7 @@ class MockingbirdPluginKspDelegate {

private fun addKSPDependency(project: Project, kspConfiguration: String) {
project.dependencies {
kspConfiguration("com.careem.mockingbird:mockingbird-processor:${BuildConfig.VERSION}")
add(kspConfiguration, "com.careem.mockingbird:mockingbird-processor:${BuildConfig.VERSION}")
}
}

Expand All @@ -93,3 +96,10 @@ class MockingbirdPluginKspDelegate {
private fun hasKspPlugin(target: Project): Boolean =
target.plugins.findPlugin("com.google.devtools.ksp") != null
}

private val KotlinProjectExtension.targets: Iterable<KotlinTarget>
get() = when (this) {
is KotlinSingleTargetExtension<*> -> listOf(this.target)
is KotlinMultiplatformExtension -> targets
else -> error("Unexpected 'kotlin' extension $this")
}
2 changes: 1 addition & 1 deletion samples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions samples/kspsample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ kotlin {
// }

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
implementation(project(":common-sample"))
implementation(project(":common:sample"))
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(libs.kotlinx.coroutines)
implementation(libs.kotlin.test)
Expand Down
2 changes: 1 addition & 1 deletion versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlinTarget = "1.6"
kotlinTarget = "1.9"
jvmTarget = "1.8"

kotlin = "1.9.23"
Expand Down

0 comments on commit 22f556b

Please sign in to comment.