Skip to content

Commit 29e481c

Browse files
authored
Merge pull request #294 from icerockdev/develop
Release 0.18.0
2 parents ec2d7fa + e88ab20 commit 29e481c

102 files changed

Lines changed: 1794 additions & 280 deletions

File tree

Some content is hidden

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

.github/workflows/compilation-check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
java-version: 11
1919
- name: Plugin check
2020
run: ./gradlew -p resources-generator build publishToMavenLocal
21+
- name: detekt run
22+
run: ./gradlew detekt
2123
- name: check android only build
2224
run: ./gradlew clean && ./gradlew assembleDebug
2325
- name: check jvm only build

README.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
![moko-resources](img/logo.png)
22
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/resources) ](https://repo1.maven.org/maven2/dev/icerock/moko/resources) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko&name=resources)
33
![badge][badge-android]
4-
![badge][badge-iosx64]
5-
![badge][badge-iosarm64]
6-
![badge][badge-macos64]
4+
![badge][badge-iosX64]
5+
![badge][badge-iosArm64]
6+
![badge][badge-iosSimulatorArm64]
7+
![badge][badge-macosArm64]
8+
![badge][badge-macosX64]
79
![badge][badge-jvm]
810

911
# Mobile Kotlin resources
@@ -25,7 +27,7 @@ This is a Kotlin MultiPlatform library that provides access to the resources on
2527
- **Colors** with light/dark mode support;
2628
- **StringDesc** for lifecycle-aware access to resources and unified localization on both platforms;
2729
- **Static** iOS frameworks support;
28-
- **FatFrameworkWithResourcesTask** Gradle task.
30+
- **Fat and XC** frameworks support.
2931

3032
## Requirements
3133
- Gradle version 6.8.3+
@@ -41,7 +43,7 @@ buildscript {
4143
}
4244
4345
dependencies {
44-
classpath "dev.icerock.moko:resources-generator:0.17.4"
46+
classpath "dev.icerock.moko:resources-generator:0.18.0"
4547
}
4648
}
4749
@@ -58,11 +60,16 @@ project build.gradle
5860
apply plugin: "dev.icerock.mobile.multiplatform-resources"
5961
6062
dependencies {
61-
commonMainApi("dev.icerock.moko:resources:0.17.4")
63+
commonMainApi("dev.icerock.moko:resources:0.18.0")
64+
androidMainApi("dev.icerock.moko:resources-compose:0.18.0")
65+
jvmMainApi("dev.icerock.moko:resources-compose:0.18.0")
66+
commonTestImplementation("dev.icerock.moko:resources-test:0.18.0")
6267
}
6368
6469
multiplatformResources {
6570
multiplatformResourcesPackage = "org.example.library" // required
71+
multiplatformResourcesClassName = "SharedRes" // optional, default MR
72+
multiplatformResourcesVisibility = MRVisibility.Internal // optional, default Public
6673
iosBaseLocalizationRegion = "en" // optional, default "en"
6774
multiplatformResourcesSourceSet = "commonClientMain" // optional, default "commonMain"
6875
}
@@ -447,36 +454,6 @@ framework {
447454
}
448455
```
449456

450-
### Gradle task for creating Fat Framework with resources
451-
452-
If you want to create Fat Framework for iOS with all resources from KMP Gradle module you should use
453-
extended Gradle task `FatFrameworkWithResourcesTask`. There is example of
454-
`FatFrameworkWithResourcesTask` task using for the `mpp-library` module of the Sample. In the end
455-
of the `sample/mpp-library/build.gradle.kts` file:
456-
457-
```kotlin
458-
tasks.register("debugFatFramework", dev.icerock.gradle.tasks.FatFrameworkWithResourcesTask::class) {
459-
baseName = "multiplatform"
460-
461-
val targets = mapOf(
462-
"iosX64" to kotlin.targets.getByName<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>("iosX64"),
463-
"iosArm64" to kotlin.targets.getByName<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>("iosArm64")
464-
)
465-
466-
from(
467-
targets.toList().map {
468-
it.second.binaries.getFramework("MultiPlatformLibrary", org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG)
469-
}
470-
)
471-
}
472-
```
473-
474-
Then just launch task:
475-
476-
```shell script
477-
./gradlew :sample:mpp-library:debugFatFramework
478-
```
479-
480457
### Example 10 - plain file resource access
481458
The first step is a create a resource file `test.txt` for example, in `commonMain/resources/MR/files`
482459
After gradle sync we can get file by id `MR.files.test`
@@ -492,6 +469,28 @@ val text = MR.files.test.readText()
492469
```
493470
If you want to read files not as text, add your own implementation to expect/actual FileResource
494471

472+
### Example 11 - assets access
473+
474+
Assets allow you save directories hierarchy (in files structure is plain).
475+
Locate files to `commonMain/resources/MR/assets` and access to it by `MR.assets.*`
476+
477+
### Creating Fat Framework with resources
478+
479+
Just use `FatFrameworkTask` [from kotlin plugin](https://kotlinlang.org/docs/mpp-build-native-binaries.html#build-universal-frameworks).
480+
481+
### Creating XCFramework with resources
482+
483+
Just use `XCFramework` [from kotlin plugin](https://kotlinlang.org/docs/mpp-build-native-binaries.html#build-xcframeworks).
484+
485+
But if you use **static frameworks** required additional setup - add to Xcode build phase (at end):
486+
```bash
487+
"$SRCROOT/../gradlew" -p "$SRCROOT/../" :shared:copyResourcesMPLReleaseXCFrameworkToApp \
488+
-Pmoko.resources.BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR \
489+
-Pmoko.resources.CONTENTS_FOLDER_PATH=$CONTENTS_FOLDER_PATH
490+
```
491+
492+
Details you can check in sample TestStaticXCFramework in ios-app. In this sample used mpp-hierarhical kotlin module with XCFramework.
493+
495494
## Samples
496495
Please see more examples in the [sample directory](sample).
497496

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313
}
1414
dependencies {
1515
classpath("dev.icerock.moko:resources-generator")
16-
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0")
16+
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.1")
1717
classpath(":resources-build-logic")
1818
}
1919
}

gradle/libs.versions.toml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
2-
kotlinVersion = "1.5.31"
3-
androidGradleVersion = "4.1.2"
2+
kotlinVersion = "1.6.10"
3+
androidGradleVersion = "7.0.4"
44

55
# kotlinx
66
kotlinxSerializationVersion = "1.2.1"
@@ -10,14 +10,18 @@ constraintLayoutVersion = "2.0.4"
1010
androidAppCompatVersion = "1.2.0"
1111

1212
# android compose
13-
composeVersion = "1.0.4"
13+
composeVersion = "1.0.5"
1414
composeActivityVersion = "1.3.1"
1515

16+
# jetbrains compose
17+
composeJetbrainsVersion = "1.0.1"
18+
1619
# jvm
1720
apacheCommonsTextVersion = "1.3"
18-
kotlinPoetVersion = "1.6.0"
19-
detektVersion = "1.15.0"
21+
kotlinPoetVersion = "1.10.2"
22+
detektVersion = "1.19.0"
2023
icu4jVersion = "69.1"
24+
commonsCodecVersion = "1.15"
2125

2226
# tests
2327
espressoCoreVersion = "3.3.0"
@@ -28,10 +32,10 @@ testCoreVersion = "1.3.0"
2832
robolectricVersion = "4.6"
2933

3034
# moko
31-
mokoGraphicsVersion = "0.7.0"
32-
mokoParcelizeVersion = "0.7.1"
33-
mokoTestVersion = "0.4.1"
34-
mokoResourcesVersion = "0.17.4"
35+
mokoGraphicsVersion = "0.9.0"
36+
mokoParcelizeVersion = "0.8.0"
37+
mokoTestVersion = "0.5.0"
38+
mokoResourcesVersion = "0.18.0"
3539

3640
[libraries]
3741
# kotlinx
@@ -55,9 +59,13 @@ composeMaterial = { module = "androidx.compose.material:material", version.ref =
5559
composeFoundation = { module = "androidx.compose.foundation:foundation", version.ref = "composeVersion" }
5660
composeActivity = { module = "androidx.activity:activity-compose", version.ref = "composeActivityVersion" }
5761

62+
# jetbrains compose
63+
composeGradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "composeJetbrainsVersion" }
64+
5865
# jvm
5966
kotlinPoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinPoetVersion" }
6067
apacheCommonsText = { module = "org.apache.commons:commons-text", version.ref = "apacheCommonsTextVersion" }
68+
commonsCodec = { module = "commons-codec:commons-codec", version.ref = "commonsCodecVersion" }
6169
icu4j = { module = "com.ibm.icu:icu4j", version.ref = "icu4jVersion" }
6270

6371
# tests
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

resources-build-logic/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repositories {
1010
}
1111

1212
dependencies {
13-
api("dev.icerock:mobile-multiplatform:0.12.0")
14-
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
15-
api("com.android.tools.build:gradle:7.0.0")
13+
api("dev.icerock:mobile-multiplatform:0.13.0")
14+
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
15+
api("com.android.tools.build:gradle:7.0.4")
1616
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0")
1717
}

resources-build-logic/src/main/kotlin/android-base-convention.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.android.build.gradle.BaseExtension
66

77
configure<BaseExtension> {
8-
compileSdkVersion(30)
8+
compileSdkVersion(31)
99

1010
defaultConfig {
1111
minSdkVersion(16)

resources-build-logic/src/main/kotlin/apple-main-convention.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ kotlin {
1616
val iosMain by getting {
1717
dependsOn(appleMain)
1818
}
19-
val macosX64Main by getting {
19+
val macosMain by getting {
2020
dependsOn(appleMain)
2121
}
2222

@@ -27,7 +27,7 @@ kotlin {
2727
val iosTest by getting {
2828
dependsOn(appleTest)
2929
}
30-
val macosX64Test by getting {
30+
val macosTest by getting {
3131
dependsOn(appleTest)
3232
}
3333
}

resources-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,33 @@ kotlin {
1313
jvm()
1414
android()
1515
ios()
16+
iosSimulatorArm64()
1617
macosX64()
17-
}
18+
macosArm64()
19+
20+
sourceSets {
21+
val iosMain by getting
22+
val iosSimulatorArm64Main by getting
23+
iosSimulatorArm64Main.dependsOn(iosMain)
24+
25+
val iosTest by getting
26+
val iosSimulatorArm64Test by getting
27+
iosSimulatorArm64Test.dependsOn(iosTest)
28+
29+
val commonMain by getting
30+
val macosMain by creating
31+
val macosArm64Main by getting
32+
val macosX64Main by getting
33+
macosArm64Main.dependsOn(macosMain)
34+
macosX64Main.dependsOn(macosMain)
35+
macosMain.dependsOn(commonMain)
1836

19-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
20-
settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
37+
val commonTest by getting
38+
val macosTest by creating
39+
val macosArm64Test by getting
40+
val macosX64Test by getting
41+
macosArm64Test.dependsOn(macosTest)
42+
macosX64Test.dependsOn(macosTest)
43+
macosTest.dependsOn(commonTest)
44+
}
2145
}

resources-compose/build.gradle.kts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
*/
44

55
plugins {
6+
id("com.android.library")
7+
id("android-base-convention")
68
id("org.jetbrains.kotlin.multiplatform")
79
id("detekt-convention")
810
id("org.jetbrains.compose")
911
id("javadoc-stub-convention")
12+
id("multiplatform-android-publish-convention")
1013
id("publication-convention")
14+
id("dev.icerock.mobile.multiplatform.android-manifest")
1115
}
1216

1317
java {
@@ -17,11 +21,20 @@ java {
1721
}
1822

1923
kotlin {
24+
android()
2025
jvm()
2126
sourceSets {
22-
named("jvmMain") {
27+
commonMain {
2328
dependencies {
2429
api(projects.resources)
30+
implementation(compose.runtime)
31+
implementation(compose.foundation)
32+
}
33+
}
34+
35+
named("jvmMain") {
36+
dependencies {
37+
api(compose.desktop.common)
2538
implementation(compose.desktop.currentOs)
2639
}
2740
}

0 commit comments

Comments
 (0)