Skip to content

Commit

Permalink
API to add source-sets
Browse files Browse the repository at this point in the history
  • Loading branch information
SalomonBrys committed Mar 3, 2024
1 parent 4316e08 commit 747f08c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {

allprojects {
group = "org.kodein.internal.gradle"
version = "8.5.2"
version = "8.6.0"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
# https://docs.gradle.org/current/userguide/compatibility.html#kotlin
kotlin = "1.9.10"
kotlin = "1.9.20"
gradle-publishPlugin = "1.2.1"
gradle-enterprisePlugin = "3.15.1"

Expand Down
26 changes: 22 additions & 4 deletions src/main/kotlin/org/kodein/internal/gradle/KodeinMppExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public open class KodeinMppExtension(internal val kotlin: KotlinMultiplatformExt
public fun mainDependencies(configure: KotlinDependencyHandler.() -> Unit) { main.configure { dependencies(configure) } }
public fun test(configure: KotlinSourceSet.() -> Unit) { test.configure(configure) }
public fun testDependencies(configure: KotlinDependencyHandler.() -> Unit) { test.configure { dependencies(configure) } }
public fun dependsOn(sources: Sources) {
main.configure { dependsOn(sources.main.get()) }
test.configure { dependsOn(sources.test.get()) }
}
public fun dependsOn(target: KodeinTarget) { dependsOn(target.sourceBuilder(target.name)) }
public fun dependsOn(targets: List<KodeinTarget>) { targets.forEach { dependsOn(it) } }
public fun feedsInto(sources: Sources) {
sources.main.configure { dependsOn(main.get()) }
sources.test.configure { dependsOn(test.get()) }
}
public fun feedsInto(target: KodeinTarget) { feedsInto(target.sourceBuilder(target.name)) }
public fun feedsInto(targets: List<KodeinTarget>) { targets.forEach { feedsInto(it) } }
}

public val common: Sources get() = Sources("common")
Expand Down Expand Up @@ -207,8 +219,8 @@ public open class KodeinMppExtension(internal val kotlin: KotlinMultiplatformExt

public open val all: List<KodeinTarget> get() = allNative + jvm + js + allWasm

public open val allComposeStable: List<KodeinTarget> get() = allDesktop + allIos + allTvos + allWatchosNoDevice + jvm + js
public val allComposeExperimental: List<KodeinTarget> get() = allComposeStable + wasmJs
public open val allComposeUi: List<KodeinTarget> get() = allIos + jvm + wasmJs
public open val allComposeRuntime: List<KodeinTarget> get() = allComposeUi + js + allDesktop + allTvos + allWatchosNoDevice

public open val allTestable: List<KodeinTarget> get() = allDesktop + iosX64 + iosSimulatorArm64 + tvosX64 + tvosSimulatorArm64 + watchosX64 + watchosSimulatorArm64 + jvm + js
}
Expand Down Expand Up @@ -329,8 +341,14 @@ public open class KodeinMppExtension(internal val kotlin: KotlinMultiplatformExt

public fun all(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.all) { configure() }

public fun allComposeExperimental(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.allComposeExperimental) { configure() }
public fun allComposeStable(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.allComposeStable) { configure() }
public fun allComposeUi(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.allComposeUi) { configure() }
public fun allComposeRuntime(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.allComposeRuntime) { configure() }

public fun allTestable(configure: KodeinTargetBuilder.() -> Unit = {}): Unit = addAll(targets.allTestable) { configure() }

public fun createSources(name: String, configure: Sources.() -> Unit = {}): Sources {
val main = kotlin.sourceSets.create(name + "Main")
kotlin.sourceSets.create(name + "Test") { }
return Sources(name).apply(configure)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class KodeinMppWithAndroidExtension(kotlin: KotlinMultiplatformExtension)
}

override val all: List<KodeinTarget> get() = super.all + android
override val allComposeStable: List<KodeinTarget> get() = super.allComposeStable + android
override val allComposeUi: List<KodeinTarget> get() = super.allComposeUi + android
override val allTestable: List<KodeinTarget> get() = super.allTestable + android
}

Expand Down

0 comments on commit 747f08c

Please sign in to comment.