mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

Usage with gradle Kotlin DSL (add instructions) #128

Closed AntonPieper closed 1 year ago

AntonPieper commented 1 year ago

Modern android applications use Kotlin DSL instead of groovy for the gradle scripts. Also they use libs.versions.toml. I tried to migrate to these, however it does not work. Could you ad instructions on how to add this plugin using Kotlin DSL and libs.versions.toml?

AntonPieper commented 1 year ago

Ok, it actually was really simple:

build.gradle.kts (in :app)

plugins {
    alias(libs.plugins.rust)
}

cargo {
    module  = "../rust"       // Or whatever directory contains your Cargo.toml
    libname = "rust"          // Or whatever matches Cargo.toml's [package] name.
    targets = listOf("arm", "x86")  // See bellow for a longer list of options
}

libs.versions.toml

[versions]
rust = "0.9.3"

[plugins]
rust = { id = "org.mozilla.rust-android-gradle.rust-android", version.ref = "rust" }