Skip to content

Commit

Permalink
Merge pull request #72 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.10.0
  • Loading branch information
Alex009 authored May 5, 2020
2 parents 1fc79aa + d545073 commit 74b4dc3
Show file tree
Hide file tree
Showing 125 changed files with 2,008 additions and 1,003 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/compilation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ name: KMP library compilation check
on:
pull_request:
branches:
- master
- master
- develop

jobs:
build:
runs-on: macOS-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Check plugin build
run: ./gradlew -PlibraryPublish :gradle-plugin:publishPluginPublicationToMavenLocal
- name: Check library build
run: ./gradlew -PlibraryPublish :resources:publishToMavenLocal
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Check plugin build
run: ./gradlew -PlibraryPublish detekt :gradle-plugin:publishPluginPublicationToMavenLocal
- name: Check library build
run: ./gradlew -PlibraryPublish detekt :resources:publishToMavenLocal
- name: Check demo library
run: ./gradlew detekt :sample:mpp-conditional:build :sample:mpp-hierarhical:build :sample:mpp-library:build :sample:mpp-mixed:build
41 changes: 8 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![moko-resources](img/logo.png)
[![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)
[![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)

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

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

## Requirements
Expand All @@ -43,6 +42,8 @@ This is a Kotlin MultiPlatform library that provides access to the resources on
- 0.9.0
- kotlin 1.3.71
- 0.9.1
- kotlin 1.3.72
- 0.10.0

## Installation
root build.gradle
Expand All @@ -53,7 +54,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko:resources-generator:0.9.1"
classpath "dev.icerock.moko:resources-generator:0.10.0"
}
}
Expand All @@ -70,7 +71,7 @@ project build.gradle
apply plugin: "dev.icerock.mobile.multiplatform-resources"
dependencies {
commonMainApi("dev.icerock.moko:resources:0.9.1")
commonMainApi("dev.icerock.moko:resources:0.10.0")
}
multiplatformResources {
Expand Down Expand Up @@ -282,40 +283,14 @@ We got autogenerated `MR.fonts.Raleway.italic`, `MR.fonts.Raleway.regular`, `MR.
- Android: `textView.typeface = font.getTypeface(context = this)`
- iOS: `textView.font = font.uiFont(withSize: 14.0)`

## FAQ
If on iOS you see just localization keys - add to iOS framework exports `moko-resources`.
[Gradle - exports](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#exporting-dependencies-to-binaries)
sample with [mobile-multiplatform-plugin](https://github.com/icerockdev/mobile-multiplatform-gradle-plugin):
```
setupFramework(
exports = listOf(Deps.Libs.MultiPlatform.mokoResources)
)
```
sample without our plugin:
```
kotlin {
iosX64().binaries {
framework {
export("dev.icerock.moko:resources-iosx64:0.9.0")
}
}
iosArm64().binaries {
framework {
export("dev.icerock.moko:resources-iosarm64:0.9.0")
}
}
}
```

## Samples
Please see more examples in the [sample directory](sample).

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

## Contributing
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`.
Expand Down
44 changes: 42 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
plugin(Deps.Plugins.detekt) apply false
}

buildscript {
repositories {
mavenLocal()

jcenter()
google()

maven { url = uri("https://dl.bintray.com/kotlin/kotlin") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://plugins.gradle.org/m2/") }
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
}
dependencies {
val libraryPublish: Boolean = properties.containsKey("libraryPublish")

with(Deps.Plugins) {
listOfNotNull(
androidApplication,
androidLibrary,
kotlinMultiplatform,
kotlinKapt,
kotlinAndroid,
if (!libraryPublish) mokoResources else null
)
}.let { plugins(it) }
}
}

allprojects {
repositories {
mavenLocal()
Expand All @@ -14,8 +46,16 @@ allprojects {
maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
}

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations.create("compileClasspath")
apply(plugin = Deps.Plugins.detekt.id)

configure<io.gitlab.arturbosch.detekt.extensions.DetektExtension> {
toolVersion = Versions.detekt
input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin")
}

dependencies {
"detektPlugins"(Deps.Libs.Jvm.detektFormatting)
}
}

tasks.register("clean", Delete::class).configure {
Expand Down
6 changes: 2 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ plugins {
}

repositories {
mavenLocal()

jcenter()
google()

Expand All @@ -13,8 +11,8 @@ repositories {

dependencies {
implementation("dev.icerock:mobile-multiplatform:0.6.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71")
implementation("com.android.tools.build:gradle:3.6.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
implementation("com.android.tools.build:gradle:3.6.3")
}

kotlinDslPluginOptions {
Expand Down
45 changes: 29 additions & 16 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@

object Deps {
object Plugins {
const val android =
"com.android.tools.build:gradle:${Versions.Plugins.android}"
const val kotlin =
"org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
const val mokoResources =
"dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
val androidApplication = PluginDesc(id = "com.android.application")
val androidLibrary = PluginDesc(
id = "com.android.library",
module = "com.android.tools.build:gradle:${Versions.Plugins.android}"
)

val kotlinMultiplatform = PluginDesc(
id = "org.jetbrains.kotlin.multiplatform",
module = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
)
val kotlinKapt = PluginDesc(id = "kotlin-kapt")
val kotlinAndroid = PluginDesc(id = "kotlin-android")
val kotlinAndroidExtensions = PluginDesc(id = "kotlin-android-extensions")

val mobileMultiplatform = PluginDesc(id = "dev.icerock.mobile.multiplatform")

val mokoResources = PluginDesc(
id = "dev.icerock.mobile.multiplatform-resources",
module = "dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
)

val detekt = PluginDesc(id = "io.gitlab.arturbosch.detekt", version = Versions.detekt)
}

object Libs {
Expand Down Expand Up @@ -47,20 +63,17 @@ object Deps {
iosX64 = "dev.icerock.moko:resources-iosx64:${Versions.Libs.MultiPlatform.mokoResources}",
iosArm64 = "dev.icerock.moko:resources-iosarm64:${Versions.Libs.MultiPlatform.mokoResources}"
)
val mokoParcelize = MultiPlatformLibrary(
common = "dev.icerock.moko:parcelize:${Versions.Libs.MultiPlatform.mokoParcelize}",
iosX64 = "dev.icerock.moko:parcelize-iosx64:${Versions.Libs.MultiPlatform.mokoParcelize}",
iosArm64 = "dev.icerock.moko:parcelize-iosarm64:${Versions.Libs.MultiPlatform.mokoParcelize}"
)
}

object Jvm {
const val kotlinPoet = "com.squareup:kotlinpoet:${Versions.Libs.Jvm.kotlinPoet}"
const val apacheCommonsText = "org.apache.commons:commons-text:${Versions.Libs.Jvm.apacheCommonsText}"
const val detektFormatting = "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.detekt}"
}
}

val plugins: Map<String, String> = mapOf(
"com.android.application" to Plugins.android,
"com.android.library" to Plugins.android,
"org.jetbrains.kotlin.multiplatform" to Plugins.kotlin,
"kotlin-kapt" to Plugins.kotlin,
"kotlin-android" to Plugins.kotlin,
"dev.icerock.mobile.multiplatform-resources" to Plugins.mokoResources
)
}
}
31 changes: 31 additions & 0 deletions buildSrc/src/main/kotlin/PluginDesc.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.artifacts.Dependency
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec

// TODO move to https://github.com/icerockdev/mobile-multiplatform-gradle-plugin
data class PluginDesc(
val id: String,
val module: String? = null,
val version: String? = null
)

fun DependencyHandlerScope.plugin(pluginDesc: PluginDesc): Dependency? {
return pluginDesc.module?.let { "classpath"(it) }
}

fun DependencyHandlerScope.plugins(pluginDescList: List<PluginDesc>) {
pluginDescList
.distinctBy { it.module }
.forEach { plugin(it) }
}

fun PluginDependenciesSpec.plugin(pluginDesc: PluginDesc): PluginDependencySpec {
val spec = id(pluginDesc.id)
pluginDesc.version?.also { spec.version(it) }
return spec
}
8 changes: 5 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ object Versions {
const val minSdk = 16
}

const val kotlin = "1.3.71"
const val kotlin = "1.3.72"
const val detekt = "1.7.4"

private const val mokoResources = "0.9.1"
private const val mokoResources = "0.10.0"

object Plugins {
const val android = "3.6.2"
Expand All @@ -33,11 +34,12 @@ object Versions {

object MultiPlatform {
const val mokoResources = Versions.mokoResources
const val mokoParcelize = "0.3.0"
}

object Jvm {
const val apacheCommonsText = "1.3"
const val kotlinPoet = "1.3.0"
}
}
}
}
7 changes: 4 additions & 3 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

plugins {
`kotlin-dsl`
`maven-publish`
id("org.gradle.maven-publish")
}

repositories {
Expand All @@ -16,9 +16,10 @@ repositories {

dependencies {
implementation(Deps.Libs.Jvm.kotlinPoet)
compileOnly(Deps.Plugins.kotlin)
compileOnly(Deps.Plugins.android)
compileOnly(Deps.Plugins.kotlinMultiplatform.module!!)
compileOnly(Deps.Plugins.androidLibrary.module!!)
implementation(Deps.Libs.Jvm.apacheCommonsText)
detektPlugins(Deps.Libs.Jvm.detektFormatting)
}

kotlinDslPluginOptions {
Expand Down
Loading

0 comments on commit 74b4dc3

Please sign in to comment.