Skip to content

Commit bb49b5a

Browse files
Replace repository content with new JetCo structure
- Added JetCoKMP: Kotlin Multiplatform version of the library - Added jetco-android: Android-specific library code - Reorganized project structure for better multiplatform support
1 parent 83024ab commit bb49b5a

File tree

229 files changed

+7559
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+7559
-3
lines changed

JetCoKMP/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.iml
2+
.kotlin
3+
.gradle
4+
**/build/
5+
xcuserdata
6+
!src/**/build/
7+
local.properties
8+
.idea
9+
.DS_Store
10+
captures
11+
.externalNativeBuild
12+
.cxx
13+
*.xcodeproj/*
14+
!*.xcodeproj/project.pbxproj
15+
!*.xcodeproj/xcshareddata/
16+
!*.xcodeproj/project.xcworkspace/
17+
!*.xcworkspace/contents.xcworkspacedata
18+
**/xcshareddata/WorkspaceSettings.xcsettings
19+
node_modules/
20+
/build
21+
/jetco/build

JetCoKMP/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
This is a Kotlin Multiplatform project targeting Android, iOS, Web, Desktop (JVM).
2+
3+
* [/composeApp](./composeApp/src) is for code that will be shared across your Compose Multiplatform applications.
4+
It contains several subfolders:
5+
- [commonMain](./composeApp/src/commonMain/kotlin) is for code that’s common for all targets.
6+
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
7+
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
8+
the [iosMain](./composeApp/src/iosMain/kotlin) folder would be the right place for such calls.
9+
Similarly, if you want to edit the Desktop (JVM) specific part, the [jvmMain](./composeApp/src/jvmMain/kotlin)
10+
folder is the appropriate location.
11+
12+
* [/iosApp](./iosApp/iosApp) contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform,
13+
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.
14+
15+
### Build and Run Android Application
16+
17+
To build and run the development version of the Android app, use the run configuration from the run widget
18+
in your IDE’s toolbar or build it directly from the terminal:
19+
- on macOS/Linux
20+
```shell
21+
./gradlew :composeApp:assembleDebug
22+
```
23+
- on Windows
24+
```shell
25+
.\gradlew.bat :composeApp:assembleDebug
26+
```
27+
28+
### Build and Run Desktop (JVM) Application
29+
30+
To build and run the development version of the desktop app, use the run configuration from the run widget
31+
in your IDE’s toolbar or run it directly from the terminal:
32+
- on macOS/Linux
33+
```shell
34+
./gradlew :composeApp:run
35+
```
36+
- on Windows
37+
```shell
38+
.\gradlew.bat :composeApp:run
39+
```
40+
41+
### Build and Run Web Application
42+
43+
To build and run the development version of the web app, use the run configuration from the run widget
44+
in your IDE's toolbar or run it directly from the terminal:
45+
- for the Wasm target (faster, modern browsers):
46+
- on macOS/Linux
47+
```shell
48+
./gradlew :composeApp:wasmJsBrowserDevelopmentRun
49+
```
50+
- on Windows
51+
```shell
52+
.\gradlew.bat :composeApp:wasmJsBrowserDevelopmentRun
53+
```
54+
- for the JS target (slower, supports older browsers):
55+
- on macOS/Linux
56+
```shell
57+
./gradlew :composeApp:jsBrowserDevelopmentRun
58+
```
59+
- on Windows
60+
```shell
61+
.\gradlew.bat :composeApp:jsBrowserDevelopmentRun
62+
```
63+
64+
### Build and Run iOS Application
65+
66+
To build and run the development version of the iOS app, use the run configuration from the run widget
67+
in your IDE’s toolbar or open the [/iosApp](./iosApp) directory in Xcode and run it from there.
68+
69+
---
70+
71+
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html),
72+
[Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/#compose-multiplatform),
73+
[Kotlin/Wasm](https://kotl.in/wasm/)…
74+
75+
We would appreciate your feedback on Compose/Web and Kotlin/Wasm in the public Slack channel [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web).
76+
If you face any issues, please report them on [YouTrack](https://youtrack.jetbrains.com/newIssue?project=CMP).

JetCoKMP/build.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
// this is necessary to avoid the plugins to be loaded multiple times
3+
// in each subproject's classloader
4+
alias(libs.plugins.androidApplication) apply false
5+
alias(libs.plugins.androidLibrary) apply false
6+
alias(libs.plugins.composeHotReload) apply false
7+
alias(libs.plugins.composeMultiplatform) apply false
8+
alias(libs.plugins.composeCompiler) apply false
9+
alias(libs.plugins.kotlinMultiplatform) apply false
10+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
alias(libs.plugins.kotlinMultiplatform)
7+
alias(libs.plugins.androidApplication)
8+
alias(libs.plugins.composeMultiplatform)
9+
alias(libs.plugins.composeCompiler)
10+
alias(libs.plugins.composeHotReload)
11+
}
12+
13+
kotlin {
14+
androidTarget {
15+
compilerOptions {
16+
jvmTarget.set(JvmTarget.JVM_11)
17+
}
18+
}
19+
20+
listOf(
21+
iosArm64(),
22+
iosSimulatorArm64()
23+
).forEach { iosTarget ->
24+
iosTarget.binaries.framework {
25+
baseName = "ComposeApp"
26+
isStatic = true
27+
}
28+
}
29+
30+
jvm {
31+
compilerOptions {
32+
jvmTarget.set(JvmTarget.JVM_11)
33+
}
34+
}
35+
36+
@OptIn(ExperimentalWasmDsl::class)
37+
wasmJs {
38+
browser {
39+
commonWebpackConfig {
40+
outputFileName = "composeApp.js"
41+
}
42+
}
43+
binaries.executable()
44+
}
45+
46+
sourceSets {
47+
androidMain.dependencies {
48+
implementation(compose.preview)
49+
implementation(libs.androidx.activity.compose)
50+
}
51+
commonMain.dependencies {
52+
implementation(compose.runtime)
53+
implementation(compose.foundation)
54+
implementation(compose.material3)
55+
implementation(compose.ui)
56+
implementation(compose.components.resources)
57+
implementation(compose.components.uiToolingPreview)
58+
implementation(libs.androidx.lifecycle.viewmodelCompose)
59+
implementation(libs.androidx.lifecycle.runtimeCompose)
60+
implementation("org.jetbrains.compose.material:material-icons-extended:1.7.3")
61+
implementation(project(":jetco"))
62+
}
63+
commonTest.dependencies {
64+
implementation(libs.kotlin.test)
65+
}
66+
jvmMain.dependencies {
67+
implementation(compose.desktop.currentOs)
68+
implementation(libs.kotlinx.coroutinesSwing)
69+
}
70+
}
71+
}
72+
73+
android {
74+
namespace = "com.developerstring.jetco_kmp"
75+
compileSdk = libs.versions.android.compileSdk.get().toInt()
76+
77+
defaultConfig {
78+
applicationId = "com.developerstring.jetco_cmp"
79+
minSdk = libs.versions.android.minSdk.get().toInt()
80+
targetSdk = libs.versions.android.targetSdk.get().toInt()
81+
versionCode = 1
82+
versionName = "1.0"
83+
}
84+
packaging {
85+
resources {
86+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
87+
}
88+
}
89+
buildTypes {
90+
getByName("release") {
91+
isMinifyEnabled = false
92+
}
93+
}
94+
compileOptions {
95+
sourceCompatibility = JavaVersion.VERSION_11
96+
targetCompatibility = JavaVersion.VERSION_11
97+
}
98+
}
99+
100+
dependencies {
101+
debugImplementation(compose.uiTooling)
102+
}
103+
104+
compose.desktop {
105+
application {
106+
mainClass = "com.developerstring.jetco_cmp.MainKt"
107+
108+
nativeDistributions {
109+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
110+
packageName = "com.developerstring.jetco_cmp"
111+
packageVersion = "1.0.0"
112+
}
113+
}
114+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:supportsRtl="true"
10+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
11+
<activity
12+
android:exported="true"
13+
android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
22+
</manifest>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.developerstring.jetco_kmp
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.activity.enableEdgeToEdge
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.tooling.preview.Preview
9+
10+
class MainActivity : ComponentActivity() {
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
enableEdgeToEdge()
13+
super.onCreate(savedInstanceState)
14+
15+
setContent {
16+
App()
17+
}
18+
}
19+
}
20+
21+
@Preview
22+
@Composable
23+
fun AppAndroidPreview() {
24+
App()
25+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.developerstring.jetco_kmp
2+
3+
import android.os.Build
4+
5+
class AndroidPlatform : Platform {
6+
override val name: String = "Android ${Build.VERSION.SDK_INT}"
7+
}
8+
9+
actual fun getPlatform(): Platform = AndroidPlatform()

0 commit comments

Comments
 (0)