Skip to content

Commit a20b560

Browse files
committed
refactor: Restructure sample module into multi-platform subprojects
Modularizes the sample application by splitting the monolithic `sample` module into platform-specific subprojects (`android`, `ios`, `desktop`, `web`) and a `shared` module. - Created separate `build.gradle.kts` files for `sample:android`, `sample:ios`, `sample:desktop`, and `sample:web`. - Renamed the original `sample` module to `sample:shared` and updated its configuration to provide common logic and resources. - Migrated platform-specific source sets (Android, iOS, JVM, Wasm) from the root sample directory to their respective subprojects. - Enabled `TYPESAFE_PROJECT_ACCESSORS` in `settings.gradle.kts` and refactored project dependencies to use the `projects` accessor (e.g., `projects.theme.themePrefs`). - Renamed `kotlin-compose` plugin alias to `kotlin-compose-compiler` for clarity and consistency across all modules. - Updated Xcode project shell script to point to the new `:sample:ios` build task. - Cleaned up `gradle.properties` by removing unused Android properties and reorganized `build.gradle.kts` in theme modules.
1 parent 998830a commit a20b560

37 files changed

Lines changed: 199 additions & 100 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
alias(libs.plugins.kotlin.multiplatform) apply false
3-
alias(libs.plugins.kotlin.compose) apply false
3+
alias(libs.plugins.kotlin.compose.compiler) apply false
44
alias(libs.plugins.kotlin.serialization) apply false
55
alias(libs.plugins.android.application) apply false
66
alias(libs.plugins.android.kotlin.multiplatform.library) apply false

convention-plugins/settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
rootProject.name = "convention-plugins"
2+
13
pluginManagement {
24
repositories {
35
gradlePluginPortal()

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ org.jetbrains.compose.experimental.uikit.enabled=true
1414

1515
android.useAndroidX=true
1616
android.nonTransitiveRClass=false
17-
android.nonFinalResIds=false
1817

1918
gnsp.disableApplyOnlyOnRootProjectEnforcement=true
2019

2120
xcodeproj=./iosSample
22-

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ vanniktech-gradle-maven-publish-plugin = { module = "com.vanniktech:gradle-maven
3434

3535
[plugins]
3636
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
37-
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
37+
kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
3838
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
3939
android-application = { id = "com.android.application", version.ref = "agp" }
4040
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }

iosSample/iosApp.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
);
176176
runOnlyForDeploymentPostprocessing = 0;
177177
shellPath = /bin/sh;
178-
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :sample:embedAndSignAppleFrameworkForXcode\n";
178+
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :sample:ios:embedAndSignAppleFrameworkForXcode\n";
179179
};
180180
/* End PBXShellScriptBuildPhase section */
181181

sample/android/build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.compose.compiler)
4+
}
5+
6+
android {
7+
namespace = "com.softartdev.sample"
8+
compileSdk = libs.versions.compileSdk.get().toInt()
9+
10+
defaultConfig {
11+
applicationId = "com.softartdev.sample"
12+
minSdk = 23
13+
targetSdk = libs.versions.compileSdk.get().toInt()
14+
versionCode = 1
15+
versionName = "1.0"
16+
}
17+
18+
buildFeatures {
19+
compose = true
20+
}
21+
22+
compileOptions {
23+
sourceCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
24+
targetCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
25+
}
26+
}
27+
28+
dependencies {
29+
implementation(projects.sample.shared)
30+
implementation(libs.androidx.activity.compose)
31+
}
File renamed without changes.

sample/src/androidMain/kotlin/com/softartdev/sample/MainActivity.kt renamed to sample/android/src/main/kotlin/com/softartdev/sample/MainActivity.kt

File renamed without changes.

sample/build.gradle.kts

Lines changed: 0 additions & 89 deletions
This file was deleted.

sample/desktop/build.gradle.kts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+
4+
plugins {
5+
alias(libs.plugins.kotlin.multiplatform)
6+
alias(libs.plugins.kotlin.compose.compiler)
7+
alias(libs.plugins.compose.multiplatform)
8+
}
9+
10+
kotlin {
11+
jvmToolchain(libs.versions.jdk.get().toInt())
12+
jvm("desktop") {
13+
compilerOptions.jvmTarget = JvmTarget.fromTarget(libs.versions.jdk.get())
14+
}
15+
sourceSets {
16+
val desktopMain by getting {
17+
dependencies {
18+
implementation(projects.sample.shared)
19+
implementation(libs.compose.desktop)
20+
}
21+
}
22+
}
23+
}
24+
25+
compose.desktop {
26+
application {
27+
mainClass = "com.softartdev.shared.MainKt"
28+
nativeDistributions {
29+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
30+
packageName = "com.softartdev.sample"
31+
packageVersion = "1.0.0"
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)