From d729ed075bb7fc858e0705c3242c5c56f550a5f8 Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:26:39 +0700 Subject: [PATCH 1/6] remove unecessary import --- build.gradle.kts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d9ba08ac..8b211638 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,6 @@ * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -import java.net.URI - allprojects { repositories { mavenLocal() @@ -11,9 +9,9 @@ allprojects { google() jcenter() - maven { url = URI("https://kotlin.bintray.com/kotlin") } - maven { url = URI("https://kotlin.bintray.com/kotlinx") } - maven { url = URI("https://dl.bintray.com/icerockdev/moko") } + maven { url = uri("https://kotlin.bintray.com/kotlin") } + maven { url = uri("https://kotlin.bintray.com/kotlinx") } + maven { url = uri("https://dl.bintray.com/icerockdev/moko") } } // workaround for https://youtrack.jetbrains.com/issue/KT-27170 From 8517a9e8b635eeb151fe1a4b88e10671d08bae1c Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:27:00 +0700 Subject: [PATCH 2/6] add lost repository for plugins --- settings.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.gradle.kts b/settings.gradle.kts index 2fe781ab..20fe13ab 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,7 @@ pluginManagement { 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") } } resolutionStrategy.eachPlugin { val module = Deps.plugins[requested.id.id] ?: return@eachPlugin From e56f53fbd3033daab88767216a5463ace019b0ba Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:27:18 +0700 Subject: [PATCH 3/6] update version of mobile-multiplatform plugin --- buildSrc/build.gradle.kts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 2ba90577..1463635a 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,7 +12,9 @@ repositories { } dependencies { - implementation("dev.icerock:mobile-multiplatform:0.2.0") + implementation("dev.icerock:mobile-multiplatform:0.3.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50") + implementation("com.android.tools.build:gradle:3.5.0") } kotlinDslPluginOptions { From 99eb07b9c6a4900fe552af886b51b409dad8d602 Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:27:40 +0700 Subject: [PATCH 4/6] fix link tasks infinite invalidation --- .../gradle/generator/IosMRGenerator.kt | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/gradle-plugin/src/main/kotlin/dev/icerock/gradle/generator/IosMRGenerator.kt b/gradle-plugin/src/main/kotlin/dev/icerock/gradle/generator/IosMRGenerator.kt index d24b3c84..eeba45ba 100644 --- a/gradle-plugin/src/main/kotlin/dev/icerock/gradle/generator/IosMRGenerator.kt +++ b/gradle-plugin/src/main/kotlin/dev/icerock/gradle/generator/IosMRGenerator.kt @@ -7,11 +7,9 @@ package dev.icerock.gradle.generator import com.squareup.kotlinpoet.* import org.gradle.api.Project import org.gradle.api.Task -import org.gradle.api.tasks.Copy import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.mpp.Framework import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink -import org.w3c.dom.Node import java.io.File import java.io.FileWriter import javax.xml.parsers.DocumentBuilderFactory @@ -66,42 +64,33 @@ class IosMRGenerator( val framework = linkTask.binary as? Framework ?: return@forEach - val pack = - project.tasks.create(linkTask.name.replace("link", "pack"), Copy::class.java) { - group = "multiplatform" + linkTask.doLast { + resourcesGenerationDir.copyRecursively(framework.outputFile, overwrite = true) - from(resourcesGenerationDir) - into(framework.outputFile) + val infoPList = File(framework.outputFile, "Info.plist") - // set development region in Info.plist for activate Base.lproj usage - doLast { - val infoPList = File(framework.outputFile, "Info.plist") + val dbFactory = DocumentBuilderFactory.newInstance() + val dBuilder = dbFactory.newDocumentBuilder() + val doc = dBuilder.parse(infoPList) - val dbFactory = DocumentBuilderFactory.newInstance() - val dBuilder = dbFactory.newDocumentBuilder() - val doc = dBuilder.parse(infoPList) + val rootDict = doc.getElementsByTagName("dict").item(0) - val rootDict = doc.getElementsByTagName("dict").item(0) + rootDict.appendChild(doc.createElement("key").apply { + textContent = "CFBundleDevelopmentRegion" + }) + rootDict.appendChild(doc.createElement("string").apply { + textContent = "en" + }) - rootDict.appendChild(doc.createElement("key").apply { - textContent = "CFBundleDevelopmentRegion" - }) - rootDict.appendChild(doc.createElement("string").apply { - textContent = "en" - }) + val transformerFactory = TransformerFactory.newInstance() + val transformer = transformerFactory.newTransformer() + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - val transformerFactory = TransformerFactory.newInstance() - val transformer = transformerFactory.newTransformer() - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + val writer = FileWriter(infoPList) + val result = StreamResult(writer) - val writer = FileWriter(infoPList) - val result = StreamResult(writer) - - transformer.transform(DOMSource(doc), result) - } - } - - linkTask.finalizedBy(pack) + transformer.transform(DOMSource(doc), result) + } } } From eccee13b5b6d1c00f13ce4792938d68fe75284d8 Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:27:51 +0700 Subject: [PATCH 5/6] update version of lib --- buildSrc/src/main/kotlin/Versions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index c85611d5..96b32699 100755 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -11,7 +11,7 @@ object Versions { const val kotlin = "1.3.50" - private const val mokoResources = "0.3.0" + private const val mokoResources = "0.4.0" object Plugins { const val android = "3.4.1" From f01d4968ada10c0ee2b95ad3cb5628ff9544a0ec Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 14 Oct 2019 23:38:52 +0700 Subject: [PATCH 6/6] update readme --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e886d42..add2adf0 100755 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ This is a Kotlin MultiPlatform library that provides access to the resources on - 0.1.0 - 0.2.0 - 0.3.0 + - 0.4.0 ## Installation root build.gradle @@ -39,7 +40,7 @@ buildscript { } dependencies { - classpath "dev.icerock.moko:resources-generator:0.3.0" + classpath "dev.icerock.moko:resources-generator:0.4.0" } } @@ -56,7 +57,11 @@ project build.gradle apply plugin: "dev.icerock.mobile.multiplatform-resources" dependencies { - commonMainApi("dev.icerock.moko:resources:0.3.0") + commonMainApi("dev.icerock.moko:resources:0.4.0") +} + +multiplatformResources { + multiplatformResourcesPackage = "org.example.library" } ``` @@ -67,7 +72,7 @@ enableFeaturePreview("GRADLE_METADATA") On iOS, in addition to the Kotlin library add Pod in the Podfile. ```ruby -pod 'MultiPlatformLibraryResources', :git => 'https://github.com/icerockdev/moko-resources.git', :tag => 'release/0.2.0' +pod 'MultiPlatformLibraryResources', :git => 'https://github.com/icerockdev/moko-resources.git', :tag => 'release/0.4.0' ``` **`MultiPlatformLibraryResources` CocoaPod requires that the framework compiled from Kotlin be named `MultiPlatformLibrary` and be connected as a CocoaPod `MultiPlatformLibrary`.