Skip to content

Commit

Permalink
Merge pull request #106 from yshrsmz/renovate/kotlin-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
yshrsmz authored Nov 7, 2023
2 parents 676865c + c9080a9 commit e4f9856
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Have a look at `./sample` directory.

```
# Publish the latest version of the plugin to test maven repository(./build/localMaven)
$ ./gradlew publishAllPublicationsToTestMavenRepository
$ ./gradlew publishAllPublicationsToTestMavenRepository -PRELEASE_SIGNING_ENABLED=false
# Try out the samples.
# BuildKonfig will be generated in ./sample/build/buildkonfig
Expand Down
1 change: 0 additions & 1 deletion buildkonfig-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
alias(libs.plugins.mavenPublish)
alias(libs.plugins.pluginPublish)
id("java-gradle-plugin")
id("signing")
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun decideOutputs(
outputDirectory: File
): Map<String, TargetConfigSource> {
return mppExtension.sources()
// Map<SourceName, TargetConfigSource
// Map<SourceName, TargetConfigSource>
.fold(emptyMap()) { acc, source ->
if (targetConfigs.size == 1 && source.name != COMMON_SOURCESET_NAME) {
// there's only common config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BuildKonfigPluginFlavorTest {
| browser()
| nodejs()
| }
| iosX64('ios')
| iosX64()
|}
""".trimMargin()

Expand Down Expand Up @@ -99,7 +99,7 @@ class BuildKonfigPluginFlavorTest {
val jsResult = File(buildDir, "jsMain/com/example/BuildKonfig.kt")
Truth.assertThat(jsResult.exists()).isFalse()

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.exists()).isFalse()
}

Expand Down Expand Up @@ -150,7 +150,7 @@ class BuildKonfigPluginFlavorTest {
val jsResult = File(buildDir, "jsMain/com/example/BuildKonfig.kt")
Truth.assertThat(jsResult.exists()).isFalse()

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.exists()).isFalse()
}

Expand Down Expand Up @@ -204,7 +204,7 @@ class BuildKonfigPluginFlavorTest {
val jsResult = File(buildDir, "jsMain/com/example/BuildKonfig.kt")
Truth.assertThat(jsResult.exists()).isFalse()

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.exists()).isFalse()
}

Expand Down Expand Up @@ -258,7 +258,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jsResult.readText())
.contains("devDefaultValue")

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.readText())
.contains("devDefaultValue")
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jsResult.readText())
.contains("devJsValue")

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.readText())
.contains("devDefaultValue")
}
Expand Down Expand Up @@ -454,7 +454,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jsResult.readText())
.contains("devJsValue")

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.readText())
.contains("defaultValue")
}
Expand Down Expand Up @@ -511,7 +511,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jsResult.readText())
.contains("defaultJsValue")

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.readText())
.contains("defaultValue")
}
Expand Down Expand Up @@ -610,7 +610,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jvmResult.readText())
.contains("internal actual object AwesomeConfig")

val iosResult = File(buildDir, "iosMain/com/example/AwesomeConfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/AwesomeConfig.kt")
Truth.assertThat(iosResult.readText())
.contains("internal actual object AwesomeConfig")
}
Expand Down Expand Up @@ -715,7 +715,7 @@ class BuildKonfigPluginFlavorTest {
Truth.assertThat(jvmResult.readText())
.contains("object AwesomeConfig")

val iosResult = File(buildDir, "iosMain/com/example/AwesomeConfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/AwesomeConfig.kt")
Truth.assertThat(iosResult.readText())
.contains("object AwesomeConfig")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class BuildKonfigPluginHMPPTest {
| browser()
| nodejs()
| }
| ios()
| iosX64()
| iosArm64()
| iosSimulatorArm64()
|
| sourceSets {
| commonMain {
Expand Down Expand Up @@ -276,16 +278,18 @@ class BuildKonfigPluginHMPPTest {
|kotlin {
| jvm {}
| android {}
| js("browser") {
| js("jsCommon", IR) {
| browser()
| }
| js("node") {
| nodejs()
| }
| ios()
| iosX64()
| iosArm64()
| iosSimulatorArm64()
| macosX64()
| linuxX64()
| mingwX64()
|
| applyDefaultHierarchyTemplate()
|
| sourceSets {
| commonMain {}
Expand Down Expand Up @@ -315,12 +319,6 @@ class BuildKonfigPluginHMPPTest {
| jsCommonMain {
| dependsOn(commonMain)
| }
| browserMain {
| dependsOn(jsCommonMain)
| }
| nodeMain {
| dependsOn(jsCommonMain)
| }
| }
|}
""".trimMargin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class BuildKonfigPluginKotlinDSLFlavorTest {
| browser()
| nodejs()
| }
| iosX64("ios")
| iosX64()
| iosArm64()
| iosSimulatorArm64()
|}
""".trimMargin()

Expand Down Expand Up @@ -105,7 +107,7 @@ class BuildKonfigPluginKotlinDSLFlavorTest {
contains("devJsValue")
}

val iosResult = File(buildDir, "iosMain/com/example/BuildKonfig.kt")
val iosResult = File(buildDir, "iosX64Main/com/example/BuildKonfig.kt")
Truth.assertThat(iosResult.readText())
.contains("defaultValue")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BuildKonfigPluginTest {
| browser()
| nodejs()
| }
| iosX64('ios')
| iosX64()
|
| sourceSets {
| commonMain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ class BuildkonfigPluginKotlinDSLTest {
|kotlin {
| android()
|
| val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
| if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
| ::iosArm64
| else
| ::iosX64
|
| iosTarget("ios") {
| binaries {
| framework {
| baseName = "shared"
| }
| }
| }
| iosX64()
| iosArm64()
| iosSimulatorArm64()
|
| js(IR) {
| browser()
| }
|
| applyDefaultHierarchyTemplate()
|
| sourceSets {
| val commonMain by getting
Expand Down Expand Up @@ -103,6 +95,8 @@ class BuildkonfigPluginKotlinDSLTest {
.withArguments("generateBuildKonfig", "--stacktrace")
.build()

// println(result.output)

assertThat(result.output).contains("BUILD SUCCESSFUL")

val commonResult = File(buildDir, "commonMain/com/sample/buildkonfig/issues/BuildKonfig.kt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ val settingsGradle = """
|
| repositories {
| mavenCentral()
| jcenter()
| maven { url 'https://plugins.gradle.org/m2/' }
| }
|}
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]
gradle = "8.2.1"
kotlin = "1.9.10"
kotlin = "1.9.20"
dokka = "1.9.10"
android = "8.1.1"
jvmTarget = "1.8"
Expand Down
1 change: 1 addition & 0 deletions sample-kts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin-js-store
18 changes: 6 additions & 12 deletions sample-kts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ plugins {

kotlin {
jvm()
js(IR) {
js("jsCommon", IR) {
browser()
}
js("node") {
nodejs()
}
ios()
iosArm64()
iosSimulatorArm64()
macosX64()
linuxX64()
mingwX64()

applyDefaultHierarchyTemplate()

/**
* - commonMain
* - appMain
Expand All @@ -27,8 +29,6 @@ kotlin {
* - linuxX64Main
* - mingwX64Main
* - jsCommonMain
* - jsMain
* - nodeMain
* - iosMain
* - iosArm64Main
* - iosX64Main
Expand Down Expand Up @@ -59,15 +59,9 @@ kotlin {
dependsOn(desktopMain)
}

val jsCommonMain by creating {
val jsCommonMain by getting {
dependsOn(commonMain)
}
val jsMain by getting {
dependsOn(jsCommonMain)
}
val nodeMain by getting {
dependsOn(jsCommonMain)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin-js-store
24 changes: 6 additions & 18 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
plugins {
id("org.jetbrains.kotlin.multiplatform") version "1.9.10"
id("org.jetbrains.kotlin.multiplatform") version "1.9.20"
id("com.codingfeline.buildkonfig") version "+"
}

kotlin {
jvm {}
js(IR) {
js("jsCommon", IR) {
browser()
}
js("node") {
nodejs()
}
ios()
iosArm64()
iosSimulatorArm64()
macosX64()
linuxX64()
mingwX64()

applyDefaultHierarchyTemplate()

/**
* - commonMain
* - appMain
Expand All @@ -25,28 +26,22 @@ kotlin {
* - linuxX64Main
* - mingwX64Main
* - jsCommonMain
* - jsMain
* - nodeMain
* - iosMain
* - iosArm64Main
* - iosX64Main
*/
sourceSets {
commonMain {}
commonTest {}

appMain {
dependsOn(commonMain)
}

jvmMain {
dependsOn(appMain)
}

desktopMain {
dependsOn(appMain)
}

macosX64Main {
dependsOn(desktopMain)
}
Expand All @@ -56,16 +51,9 @@ kotlin {
mingwX64Main {
dependsOn(desktopMain)
}

jsCommonMain {
dependsOn(commonMain)
}
jsMain {
dependsOn(jsCommonMain)
}
nodeMain {
dependsOn(jsCommonMain)
}
}
}

Expand Down

0 comments on commit e4f9856

Please sign in to comment.