Skip to content

Commit 74b4dc3

Browse files
authored
Merge pull request #72 from icerockdev/develop
Release 0.10.0
2 parents 1fc79aa + d545073 commit 74b4dc3

125 files changed

Lines changed: 2008 additions & 1003 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: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ name: KMP library compilation check
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- master
7+
- develop
78

89
jobs:
910
build:
1011
runs-on: macOS-latest
1112

1213
steps:
13-
- uses: actions/checkout@v1
14-
- name: Set up JDK 1.8
15-
uses: actions/setup-java@v1
16-
with:
17-
java-version: 1.8
18-
- name: Check plugin build
19-
run: ./gradlew -PlibraryPublish :gradle-plugin:publishPluginPublicationToMavenLocal
20-
- name: Check library build
21-
run: ./gradlew -PlibraryPublish :resources:publishToMavenLocal
14+
- uses: actions/checkout@v1
15+
- name: Set up JDK 1.8
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.8
19+
- name: Check plugin build
20+
run: ./gradlew -PlibraryPublish detekt :gradle-plugin:publishPluginPublicationToMavenLocal
21+
- name: Check library build
22+
run: ./gradlew -PlibraryPublish detekt :resources:publishToMavenLocal
23+
- name: Check demo library
24+
run: ./gradlew detekt :sample:mpp-conditional:build :sample:mpp-hierarhical:build :sample:mpp-library:build :sample:mpp-mixed:build

README.md

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![moko-resources](img/logo.png)
2-
[![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://api.bintray.com/packages/icerockdev/moko/moko-resources/images/download.svg) ](https://bintray.com/icerockdev/moko/moko-resources/_latestVersion) ![kotlin-version](https://img.shields.io/badge/kotlin-1.3.71-orange)
2+
[![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://api.bintray.com/packages/icerockdev/moko/moko-resources/images/download.svg) ](https://bintray.com/icerockdev/moko/moko-resources/_latestVersion) ![kotlin-version](https://img.shields.io/badge/kotlin-1.3.72-orange)
33

44
# Mobile Kotlin resources
55
This is a Kotlin MultiPlatform library that provides access to the resources on iOS & Android with the support of the default system localization.
@@ -10,14 +10,13 @@ This is a Kotlin MultiPlatform library that provides access to the resources on
1010
- [Versions](#versions)
1111
- [Installation](#installation)
1212
- [Usage](#usage)
13-
- [FAQ](#faq)
1413
- [Samples](#samples)
15-
- [Set Up Locally](#setup-locally)
14+
- [Set Up Locally](#set-up-locally)
1615
- [Contributing](#contributing)
1716
- [License](#license)
1817

1918
## Features
20-
- **Strings, Plurals, Images** to access the corresponding resources from common code;
19+
- **Strings, Plurals, Images, Fonts, Files** to access the corresponding resources from common code;
2120
- **StringDesc** for lifecycle-aware access to resources and unified localization on both platforms.
2221

2322
## Requirements
@@ -43,6 +42,8 @@ This is a Kotlin MultiPlatform library that provides access to the resources on
4342
- 0.9.0
4443
- kotlin 1.3.71
4544
- 0.9.1
45+
- kotlin 1.3.72
46+
- 0.10.0
4647

4748
## Installation
4849
root build.gradle
@@ -53,7 +54,7 @@ buildscript {
5354
}
5455
5556
dependencies {
56-
classpath "dev.icerock.moko:resources-generator:0.9.1"
57+
classpath "dev.icerock.moko:resources-generator:0.10.0"
5758
}
5859
}
5960
@@ -70,7 +71,7 @@ project build.gradle
7071
apply plugin: "dev.icerock.mobile.multiplatform-resources"
7172
7273
dependencies {
73-
commonMainApi("dev.icerock.moko:resources:0.9.1")
74+
commonMainApi("dev.icerock.moko:resources:0.10.0")
7475
}
7576
7677
multiplatformResources {
@@ -282,40 +283,14 @@ We got autogenerated `MR.fonts.Raleway.italic`, `MR.fonts.Raleway.regular`, `MR.
282283
- Android: `textView.typeface = font.getTypeface(context = this)`
283284
- iOS: `textView.font = font.uiFont(withSize: 14.0)`
284285

285-
## FAQ
286-
If on iOS you see just localization keys - add to iOS framework exports `moko-resources`.
287-
[Gradle - exports](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#exporting-dependencies-to-binaries)
288-
sample with [mobile-multiplatform-plugin](https://github.com/icerockdev/mobile-multiplatform-gradle-plugin):
289-
```
290-
setupFramework(
291-
exports = listOf(Deps.Libs.MultiPlatform.mokoResources)
292-
)
293-
```
294-
sample without our plugin:
295-
```
296-
kotlin {
297-
iosX64().binaries {
298-
framework {
299-
export("dev.icerock.moko:resources-iosx64:0.9.0")
300-
}
301-
}
302-
iosArm64().binaries {
303-
framework {
304-
export("dev.icerock.moko:resources-iosarm64:0.9.0")
305-
}
306-
}
307-
}
308-
```
309-
310286
## Samples
311287
Please see more examples in the [sample directory](sample).
312288

313289
## Set Up Locally
314290
- The [resources directory](resources) contains the `resources` library;
315291
- The [gradle-plugin directory](gradle-plugin) contains a gradle plugin with a `MR` class generator;
316292
- The [sample directory](sample) contains sample apps for Android and iOS; plus the mpp-library connected to the apps;
317-
- For local testing a library use the `:resources:publishToMavenLocal` gradle task - so that sample apps use the locally published version.
318-
- For local testing a plugin use the `:gradle-plugin:publishToMavenLocal` gradle task so that sample apps will use the locally published version.
293+
- For local testing use the `./publishToMavenLocal.sh` script - so that sample apps use the locally published version.
319294

320295
## Contributing
321296
All development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`.

build.gradle.kts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
plugins {
6+
plugin(Deps.Plugins.detekt) apply false
7+
}
8+
9+
buildscript {
10+
repositories {
11+
mavenLocal()
12+
13+
jcenter()
14+
google()
15+
16+
maven { url = uri("https://dl.bintray.com/kotlin/kotlin") }
17+
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
18+
maven { url = uri("https://plugins.gradle.org/m2/") }
19+
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
20+
}
21+
dependencies {
22+
val libraryPublish: Boolean = properties.containsKey("libraryPublish")
23+
24+
with(Deps.Plugins) {
25+
listOfNotNull(
26+
androidApplication,
27+
androidLibrary,
28+
kotlinMultiplatform,
29+
kotlinKapt,
30+
kotlinAndroid,
31+
if (!libraryPublish) mokoResources else null
32+
)
33+
}.let { plugins(it) }
34+
}
35+
}
36+
537
allprojects {
638
repositories {
739
mavenLocal()
@@ -14,8 +46,16 @@ allprojects {
1446
maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
1547
}
1648

17-
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
18-
configurations.create("compileClasspath")
49+
apply(plugin = Deps.Plugins.detekt.id)
50+
51+
configure<io.gitlab.arturbosch.detekt.extensions.DetektExtension> {
52+
toolVersion = Versions.detekt
53+
input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin")
54+
}
55+
56+
dependencies {
57+
"detektPlugins"(Deps.Libs.Jvm.detektFormatting)
58+
}
1959
}
2060

2161
tasks.register("clean", Delete::class).configure {

buildSrc/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ plugins {
33
}
44

55
repositories {
6-
mavenLocal()
7-
86
jcenter()
97
google()
108

@@ -13,8 +11,8 @@ repositories {
1311

1412
dependencies {
1513
implementation("dev.icerock:mobile-multiplatform:0.6.1")
16-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71")
17-
implementation("com.android.tools.build:gradle:3.6.2")
14+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
15+
implementation("com.android.tools.build:gradle:3.6.3")
1816
}
1917

2018
kotlinDslPluginOptions {

buildSrc/src/main/kotlin/Deps.kt

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,28 @@
44

55
object Deps {
66
object Plugins {
7-
const val android =
8-
"com.android.tools.build:gradle:${Versions.Plugins.android}"
9-
const val kotlin =
10-
"org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
11-
const val mokoResources =
12-
"dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
7+
val androidApplication = PluginDesc(id = "com.android.application")
8+
val androidLibrary = PluginDesc(
9+
id = "com.android.library",
10+
module = "com.android.tools.build:gradle:${Versions.Plugins.android}"
11+
)
12+
13+
val kotlinMultiplatform = PluginDesc(
14+
id = "org.jetbrains.kotlin.multiplatform",
15+
module = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
16+
)
17+
val kotlinKapt = PluginDesc(id = "kotlin-kapt")
18+
val kotlinAndroid = PluginDesc(id = "kotlin-android")
19+
val kotlinAndroidExtensions = PluginDesc(id = "kotlin-android-extensions")
20+
21+
val mobileMultiplatform = PluginDesc(id = "dev.icerock.mobile.multiplatform")
22+
23+
val mokoResources = PluginDesc(
24+
id = "dev.icerock.mobile.multiplatform-resources",
25+
module = "dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
26+
)
27+
28+
val detekt = PluginDesc(id = "io.gitlab.arturbosch.detekt", version = Versions.detekt)
1329
}
1430

1531
object Libs {
@@ -47,20 +63,17 @@ object Deps {
4763
iosX64 = "dev.icerock.moko:resources-iosx64:${Versions.Libs.MultiPlatform.mokoResources}",
4864
iosArm64 = "dev.icerock.moko:resources-iosarm64:${Versions.Libs.MultiPlatform.mokoResources}"
4965
)
66+
val mokoParcelize = MultiPlatformLibrary(
67+
common = "dev.icerock.moko:parcelize:${Versions.Libs.MultiPlatform.mokoParcelize}",
68+
iosX64 = "dev.icerock.moko:parcelize-iosx64:${Versions.Libs.MultiPlatform.mokoParcelize}",
69+
iosArm64 = "dev.icerock.moko:parcelize-iosarm64:${Versions.Libs.MultiPlatform.mokoParcelize}"
70+
)
5071
}
5172

5273
object Jvm {
5374
const val kotlinPoet = "com.squareup:kotlinpoet:${Versions.Libs.Jvm.kotlinPoet}"
5475
const val apacheCommonsText = "org.apache.commons:commons-text:${Versions.Libs.Jvm.apacheCommonsText}"
76+
const val detektFormatting = "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.detekt}"
5577
}
5678
}
57-
58-
val plugins: Map<String, String> = mapOf(
59-
"com.android.application" to Plugins.android,
60-
"com.android.library" to Plugins.android,
61-
"org.jetbrains.kotlin.multiplatform" to Plugins.kotlin,
62-
"kotlin-kapt" to Plugins.kotlin,
63-
"kotlin-android" to Plugins.kotlin,
64-
"dev.icerock.mobile.multiplatform-resources" to Plugins.mokoResources
65-
)
66-
}
79+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.gradle.api.artifacts.Dependency
6+
import org.gradle.kotlin.dsl.DependencyHandlerScope
7+
import org.gradle.plugin.use.PluginDependenciesSpec
8+
import org.gradle.plugin.use.PluginDependencySpec
9+
10+
// TODO move to https://github.com/icerockdev/mobile-multiplatform-gradle-plugin
11+
data class PluginDesc(
12+
val id: String,
13+
val module: String? = null,
14+
val version: String? = null
15+
)
16+
17+
fun DependencyHandlerScope.plugin(pluginDesc: PluginDesc): Dependency? {
18+
return pluginDesc.module?.let { "classpath"(it) }
19+
}
20+
21+
fun DependencyHandlerScope.plugins(pluginDescList: List<PluginDesc>) {
22+
pluginDescList
23+
.distinctBy { it.module }
24+
.forEach { plugin(it) }
25+
}
26+
27+
fun PluginDependenciesSpec.plugin(pluginDesc: PluginDesc): PluginDependencySpec {
28+
val spec = id(pluginDesc.id)
29+
pluginDesc.version?.also { spec.version(it) }
30+
return spec
31+
}

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ object Versions {
99
const val minSdk = 16
1010
}
1111

12-
const val kotlin = "1.3.71"
12+
const val kotlin = "1.3.72"
13+
const val detekt = "1.7.4"
1314

14-
private const val mokoResources = "0.9.1"
15+
private const val mokoResources = "0.10.0"
1516

1617
object Plugins {
1718
const val android = "3.6.2"
@@ -33,11 +34,12 @@ object Versions {
3334

3435
object MultiPlatform {
3536
const val mokoResources = Versions.mokoResources
37+
const val mokoParcelize = "0.3.0"
3638
}
3739

3840
object Jvm {
3941
const val apacheCommonsText = "1.3"
4042
const val kotlinPoet = "1.3.0"
4143
}
4244
}
43-
}
45+
}

gradle-plugin/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
plugins {
66
`kotlin-dsl`
7-
`maven-publish`
7+
id("org.gradle.maven-publish")
88
}
99

1010
repositories {
@@ -16,9 +16,10 @@ repositories {
1616

1717
dependencies {
1818
implementation(Deps.Libs.Jvm.kotlinPoet)
19-
compileOnly(Deps.Plugins.kotlin)
20-
compileOnly(Deps.Plugins.android)
19+
compileOnly(Deps.Plugins.kotlinMultiplatform.module!!)
20+
compileOnly(Deps.Plugins.androidLibrary.module!!)
2121
implementation(Deps.Libs.Jvm.apacheCommonsText)
22+
detektPlugins(Deps.Libs.Jvm.detektFormatting)
2223
}
2324

2425
kotlinDslPluginOptions {

0 commit comments

Comments
 (0)