Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karmakrafts/kmbed
Resource compiler tooling for Kotlin Multiplatform.
https://github.com/karmakrafts/kmbed
api embedding gradle gradle-plugin kotlin kotlin-js kotlin-jvm kotlin-multiplatform kotlin-native kotlinx-io library plugin resources
Last synced: 4 days ago
JSON representation
Resource compiler tooling for Kotlin Multiplatform.
- Host: GitHub
- URL: https://github.com/karmakrafts/kmbed
- Owner: karmakrafts
- License: apache-2.0
- Created: 2025-01-24T10:18:15.000Z (27 days ago)
- Default Branch: master
- Last Pushed: 2025-02-16T00:55:49.000Z (5 days ago)
- Last Synced: 2025-02-16T01:25:23.833Z (5 days ago)
- Topics: api, embedding, gradle, gradle-plugin, kotlin, kotlin-js, kotlin-jvm, kotlin-multiplatform, kotlin-native, kotlinx-io, library, plugin, resources
- Language: Kotlin
- Homepage: https://git.karmakrafts.dev/kk/kmbed
- Size: 221 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KMbed
[](https://git.karmakrafts.dev/kk/kmbed/-/pipelines)
[](https://git.karmakrafts.dev/kk/kmbed/-/packages)KMbed is a Gradle/KMP plugin for embedding resources in KMP modules.
The runtime provides an API similar to Android's R-class, zlib compression and [kotlinx.io](https://github.com/Kotlin/kotlinx-io) integration.### Platform support
* Windows x64
* Linux x64
* Linux arm64
* macOS x64
* macOS arm64
* iOS x64
* iOS arm64
* Android Native x64
* Android Native arm64
* Android Native arm32
* JVM
* JS### How to use it
First, add the required maven repository:
```kotlin
repositories {
maven("https://files.karmakrafts.dev/maven")
}
```Using KMbed is as simple as applying the KMbed Gradle Plugin and the runtime.
```kotlin
plugins {
id("io.karma.kmbed.kmbed-gradle-plugin") version ""
}kotlin {
sourceSets {
commonMain {
dependencies {
implementation("io.karma.kmbed:kmbed-runtime:")
}
}
}
}
```Resource may be accessed from any source set using the `Res` global:
```kotlin
import com.example.foo.Res // Generated resource indexfun main(args: Array) {
val data = Res["my_resource.bin"].asByteArray()
// ...
}
```### How to configure it
The following configuration properties are avaiable through the kmbed project extension:
```kotlin
kmbed {
// Allows changing the namespace (package name) of the generated resources for the current module
resourceNamespace = "com.example.foo"
// Allows force-disabling resource compression in the resource compiler
compression = true
// Allows adjusting the threshold at which resources are compressed (in bytes)
compressionThreshold = 256
// Custom source sets
kmbedSourceSets {
defaultSourceSets(project)
val customSourceSet by creating {
resourceNamespace = "com.example.foo.bar"
compression = false
}
}
}
```