Skip to content

Commit 92e6066

Browse files
committed
initial commit: add Kotlin Multiplatform project structure with dynamic layout support
0 parents  commit 92e6066

File tree

34 files changed

+2845
-0
lines changed

34 files changed

+2845
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
*.iml
3+
.gradle
4+
.idea
5+
.kotlin
6+
.DS_Store
7+
build
8+
*/build
9+
captures
10+
.externalNativeBuild
11+
.cxx
12+
local.properties
13+
xcuserdata/
14+
Pods/
15+
*.jks
16+
*.gpg
17+
*yarn.lock

README.MD

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Compose Remote
2+
3+
Kotlin Multiplatform Library
4+
5+
### Run Sample App
6+
7+
- Desktop JVM: `./gradlew :sample:composeApp:run`
8+
- Android: `open project in Android Studio and run the sample app`
9+
- iOS: `open 'sample/iosApp/iosApp.xcodeproj' in Xcode and run the sample app`
10+
- JavaScript: `./gradlew :sample:composeApp:jsBrowserRun`
11+
- Linux/Macos/Windows native: `./gradlew :sample:terminalApp:runDebugExecutable[architecture]`
12+
13+
### Publish to MavenLocal
14+
15+
1) Run `./gradlew :shared:publishToMavenLocal`
16+
2) Open `~/.m2/repository/com/utsman/composeremote/app/"}`
17+
18+
### Publish to MavenCentral
19+
20+
1) Create a account and a namespace on Sonatype:
21+
https://central.sonatype.org/register/central-portal/#create-an-account
22+
2) Add developer id, name, email and the project url to
23+
`/convention-plugins/src/main/kotlin/convention.publication.gradle.kts`
24+
3) Generate a GPG key:
25+
https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/#generating-a-gpg-key-pair
26+
```
27+
gpg --full-gen-key
28+
gpg --keyserver keyserver.ubuntu.com --send-keys XXXXXXXX
29+
gpg --export-secret-key XXXXXXXX > XXXXXXXX.gpg
30+
```
31+
4) Add the secrets to `local.properties`:
32+
```
33+
signing.keyId=XXXXXXXX
34+
signing.password=[key password]
35+
signing.secretKeyRingFile=../XXXXXXXX.gpg
36+
ossrhUsername=[Sonatype token_user]
37+
ossrhPassword=[Sonatype token_password]
38+
```
39+
5) Run `./gradlew :shared:publishAllPublicationsToSonatypeRepository`

build.gradle.kts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
plugins {
2+
alias(libs.plugins.multiplatform).apply(false)
3+
alias(libs.plugins.android.library).apply(false)
4+
alias(libs.plugins.kotlinx.serialization).apply(false)
5+
alias(libs.plugins.android.application).apply(false)
6+
}

convention-plugins/build.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl` // Is needed to turn our build logic written in Kotlin into Gralde Plugin
3+
}
4+
5+
repositories {
6+
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//Publishing your Kotlin Multiplatform library to Maven Central
2+
//https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k
3+
4+
import org.gradle.api.publish.maven.MavenPublication
5+
import org.gradle.api.tasks.bundling.Jar
6+
import org.gradle.kotlin.dsl.`maven-publish`
7+
import org.gradle.kotlin.dsl.signing
8+
import java.util.*
9+
10+
plugins {
11+
id("maven-publish")
12+
id("signing")
13+
}
14+
15+
// Stub secrets to let the project sync and build without the publication values set up
16+
ext["signing.keyId"] = null
17+
ext["signing.password"] = null
18+
ext["signing.secretKeyRingFile"] = null
19+
ext["ossrhUsername"] = null
20+
ext["ossrhPassword"] = null
21+
22+
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
23+
val secretPropsFile = project.rootProject.file("local.properties")
24+
if (secretPropsFile.exists()) {
25+
secretPropsFile.reader().use {
26+
Properties().apply { load(it) }
27+
}.onEach { (name, value) ->
28+
ext[name.toString()] = value
29+
}
30+
} else {
31+
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
32+
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
33+
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
34+
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
35+
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
36+
}
37+
38+
val javadocJar by tasks.registering(Jar::class) {
39+
archiveClassifier.set("javadoc")
40+
}
41+
42+
fun getExtraString(name: String) = ext[name]?.toString()
43+
44+
publishing {
45+
// Configure maven central repository
46+
repositories {
47+
maven("https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
48+
name = "sonatype"
49+
credentials {
50+
username = getExtraString("ossrhUsername")
51+
password = getExtraString("ossrhPassword")
52+
}
53+
}
54+
}
55+
56+
// Configure all publications
57+
publications.withType<MavenPublication> {
58+
// Stub javadoc.jar artifact
59+
artifact(javadocJar.get())
60+
61+
// Provide artifacts information requited by Maven Central
62+
pom {
63+
name.set("Compose Remote")
64+
description.set("Kotlin Multiplatform library")
65+
//url.set("") todo
66+
67+
licenses {
68+
license {
69+
name.set("MIT")
70+
url.set("https://opensource.org/licenses/MIT")
71+
}
72+
}
73+
developers {
74+
developer {
75+
//id.set("") todo
76+
//name.set("") todo
77+
//email.set("") todo
78+
}
79+
}
80+
scm {
81+
//url.set("") todo
82+
}
83+
}
84+
}
85+
}
86+
87+
// Signing artifacts. Signing.* extra properties values will be used
88+
signing {
89+
if (getExtraString("signing.keyId") != null) {
90+
sign(publishing.publications)
91+
}
92+
}
93+
94+
//https://github.com/gradle/gradle/issues/26132
95+
val signingTasks = tasks.withType<Sign>()
96+
tasks.withType<AbstractPublishToMaven>().configureEach {
97+
mustRunAfter(signingTasks)
98+
}

gradle.properties

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Gradle
2+
org.gradle.jvmargs=-Xmx4G
3+
org.gradle.caching=true
4+
org.gradle.configuration-cache=true
5+
org.gradle.daemon=true
6+
org.gradle.parallel=true
7+
8+
#Kotlin
9+
kotlin.code.style=official
10+
kotlin.daemon.jvmargs=-Xmx4G -Xms4g
11+
12+
#Android
13+
android.useAndroidX=true
14+
android.nonTransitiveRClass=true
15+
16+
#Compose
17+
org.jetbrains.compose.experimental.jscanvas.enabled=true

gradle/libs.versions.toml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[versions]
2+
3+
kotlin = "2.1.0"
4+
agp = "8.6.1"
5+
kotlinx-coroutines = "1.10.1"
6+
kotlinx-serialization = "1.7.3"
7+
ktor = "3.0.3"
8+
compose = "1.7.1"
9+
androidx-activityCompose = "1.9.3"
10+
11+
[libraries]
12+
13+
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
14+
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
15+
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
16+
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
17+
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
18+
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
19+
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
20+
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
21+
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
22+
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
23+
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
24+
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
25+
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
26+
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
27+
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
28+
29+
[plugins]
30+
31+
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
32+
android-library = { id = "com.android.library", version.ref = "agp" }
33+
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
34+
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
35+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
36+
android-application = { id = "com.android.application", version.ref = "agp" }

gradle/wrapper/gradle-wrapper.jar

42.4 KB
Binary file not shown.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)