Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ jobs:
distribution: zulu
- name: Prebuild library
run: ./gradlew publishToMavenLocal --rerun-tasks
- name: Prebuild plugin
run: ./gradlew -p resources-generator publishToMavenLocal --rerun-tasks
- name: Publish library
run: ./gradlew publish --no-parallel
- name: Publish plugin
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish plugin to maven central
run: ./gradlew -p resources-generator publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish plugin to Gradle Plugin Portal
run: ./gradlew -p resources-generator publishPlugins -Pgradle.publish.key=${{ secrets.GRADLE_PLUGIN_PORTAL_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PLUGIN_PORTAL_SECRET }}
release:
name: Create release
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![badge][badge-macosX64]
![badge][badge-jvm]
![badge][badge-js]
![badge][badge-wasmjs]
![badge][badge-wasm]

# Mobile Kotlin resources

Expand Down Expand Up @@ -208,7 +208,7 @@ In Xcode add `Build Phase` (at end of list) with script:
-Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH" \
-Pkotlin.native.cocoapods.platform="$PLATFORM_NAME" \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
-Pkotlin.native.cocoapods.configuration="${KOTLIN_FRAMEWORK_BUILD_TYPE:-$CONFIGURATION}"
```

`YourFrameworkName` is name of your project framework. Please, see on a static framework warning for get correct task name.
Expand All @@ -220,7 +220,7 @@ In Xcode add `Build Phase` (at end of list) with script:
```shell script
"$SRCROOT/../gradlew" -p "$SRCROOT/../" :yourframeworkproject:copyFrameworkResourcesToApp \
-Pmoko.resources.PLATFORM_NAME="$PLATFORM_NAME" \
-Pmoko.resources.CONFIGURATION="$CONFIGURATION" \
-Pmoko.resources.CONFIGURATION="${KOTLIN_FRAMEWORK_BUILD_TYPE:-$CONFIGURATION}" \
-Pmoko.resources.ARCHS="$ARCHS" \
-Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
-Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH"
Expand Down Expand Up @@ -680,7 +680,8 @@ For SwiftUI, create this `Image` extension:
```swift
extension Image {
init(resource: KeyPath<MR.images, ImageResource>) {
self.init(uiImage: MR.images()[keyPath: resource].toUIImage()!)
let imageResource = MR.images()[keyPath: resource]
self.init(imageResource.assetImageName, bundle: imageResource.bundle)
}
}
```
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ allprojects {
version = moko.versions.resourcesVersion.get()
}
}

// required for nexus plugin
group = "dev.icerock.moko"
version = moko.versions.resourcesVersion.get()

apply(plugin = "nexus-publication-convention")
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ kotlinCompilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embe
detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detektVersion" }
mokoMultiplatformPlugin = { module = "dev.icerock:mobile-multiplatform", version.ref = "mokoMultiplatformPluginVersion" }
composeJetBrainsPlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "composeJetbrainsVersion" }
nexusPublishing = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" }
1 change: 1 addition & 0 deletions resources-build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dependencies {
api(libs.kotlinGradlePlugin)
api(libs.androidGradlePlugin)
api(libs.detektGradlePlugin)
api(libs.nexusPublishing)
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ kotlin.targets

fun KonanTarget.getAppleSdk(): String {
return when (this) {
KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64 -> "iphoneos"

KonanTarget.IOS_SIMULATOR_ARM64,
Expand All @@ -124,16 +123,14 @@ fun KonanTarget.getAppleSdk(): String {

KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_X86 -> "watchsimulator"
KonanTarget.WATCHOS_X64 -> "watchsimulator"

else -> error("Unsupported target for selecting SDK: $this")
}
}

fun KonanTarget.getClangTarget(): String {
return when (this) {
KonanTarget.IOS_ARM32 -> "armv7-apple-ios"
KonanTarget.IOS_ARM64 -> "aarch64-apple-ios"
KonanTarget.IOS_SIMULATOR_ARM64 -> "aarch64-apple-ios-simulator"
KonanTarget.IOS_X64 -> "x86_64-apple-ios-simulator"
Expand All @@ -150,7 +147,6 @@ fun KonanTarget.getClangTarget(): String {
KonanTarget.WATCHOS_DEVICE_ARM64 -> "aarch64-apple-watchos"
KonanTarget.WATCHOS_SIMULATOR_ARM64 -> "aarch64-apple-watchos-simulator"
KonanTarget.WATCHOS_X64 -> "x86_64-apple-watchos-simulator"
KonanTarget.WATCHOS_X86 -> "i386-apple-watchos"

else -> error("Unsupported target for selecting clang target: $this")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import java.net.URI

plugins {
id("io.github.gradle-nexus.publish-plugin")
}

nexusPublishing {
repositories {
// see https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(URI.create("https://central.sonatype.com/repository/maven-snapshots/"))
username.set(System.getenv("OSSRH_USER"))
password.set(System.getenv("OSSRH_KEY"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ plugins {
}

publishing {
repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
name = "OSSRH"

credentials {
username = System.getenv("OSSRH_USER")
password = System.getenv("OSSRH_KEY")
}
}

publications.withType<MavenPublication> {
// Provide artifacts information requited by Maven Central
pom {
Expand Down
1 change: 1 addition & 0 deletions resources-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
id("com.gradle.plugin-publish") version ("1.2.0")
id("java-gradle-plugin")
kotlin("plugin.serialization") version ("1.9.25")
id("nexus-publication-convention")
}

group = "dev.icerock.moko"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ internal object AppleSdk {
targets.addAll(archs.map { arch ->
when (arch) {
"arm64", "arm64e" -> KonanTarget.IOS_ARM64
"armv7", "armv7s" -> KonanTarget.IOS_ARM32
else -> throw UnknownArchitectureException(platform, arch)
}
})
Expand Down Expand Up @@ -51,7 +50,6 @@ internal object AppleSdk {
targets.addAll(archs.map { arch ->
when (arch) {
"arm64", "arm64e" -> KonanTarget.WATCHOS_SIMULATOR_ARM64
"i386" -> KonanTarget.WATCHOS_X86
"x86_64" -> KonanTarget.WATCHOS_X64
else -> throw UnknownArchitectureException(platform, arch)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal fun <T> createByPlatform(
KotlinPlatformType.androidJvm -> createAndroid()
KotlinPlatformType.js -> createJs()
KotlinPlatformType.native -> when (konanTarget()) {
KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64,
KonanTarget.IOS_SIMULATOR_ARM64,
KonanTarget.IOS_X64,
Expand All @@ -42,26 +41,9 @@ internal fun <T> createByPlatform(
KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_DEVICE_ARM64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_X86 -> createApple()
KonanTarget.WATCHOS_X64 -> createApple()

KonanTarget.ANDROID_ARM32,
KonanTarget.ANDROID_ARM64,
KonanTarget.ANDROID_X64,
KonanTarget.ANDROID_X86,

KonanTarget.LINUX_ARM32_HFP,
KonanTarget.LINUX_ARM64,
KonanTarget.LINUX_MIPS32,
KonanTarget.LINUX_MIPSEL32,
KonanTarget.LINUX_X64,

KonanTarget.MINGW_X64,
KonanTarget.MINGW_X86,

KonanTarget.WASM32,

is KonanTarget.ZEPHYR -> error("$konanTarget not supported by moko-resources now")
else -> error("${konanTarget()} not supported by moko-resources now")
}

KotlinPlatformType.wasm -> createWasm()
Expand Down
Loading