78 lines
2.4 KiB
Kotlin
78 lines
2.4 KiB
Kotlin
import java.io.File
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.library)
|
|
}
|
|
|
|
android {
|
|
namespace = "de.rfc1437.ironstorage.core"
|
|
compileSdk = libs.versions.compileSdk.get().toInt()
|
|
ndkVersion = libs.versions.ndk.get()
|
|
defaultConfig {
|
|
minSdk = libs.versions.minSdk.get().toInt()
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
defaultConfig { consumerProguardFiles("consumer-rules.pro") }
|
|
lint {
|
|
abortOnError = true
|
|
warningsAsErrors = true
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(25)
|
|
compilerOptions { jvmTarget.set(JvmTarget.JVM_17) }
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":rust-bridge"))
|
|
implementation(libs.coroutines.android)
|
|
testImplementation(libs.coroutines.test)
|
|
testImplementation(libs.junit)
|
|
}
|
|
|
|
val fixtureOutput = layout.buildDirectory.file(
|
|
"generated/fixtures/de/rfc1437/ironstorage/core/ShellFixtures.kt"
|
|
)
|
|
val cargoExecutable = providers.environmentVariable("CARGO")
|
|
.orElse(
|
|
providers.environmentVariable("PATH").map { path ->
|
|
path.split(File.pathSeparatorChar)
|
|
.map { File(it, "cargo") }
|
|
.firstOrNull { it.isFile && it.canExecute() }?.absolutePath
|
|
?: error("Cargo is required: put it in PATH or set CARGO to its absolute path")
|
|
}
|
|
)
|
|
val workspace = rootProject.layout.projectDirectory.dir("..").asFile
|
|
val generateShellFixtures = tasks.register<Exec>("generateShellFixtures") {
|
|
workingDir = workspace
|
|
inputs.files(
|
|
workspace.resolve("Cargo.toml"),
|
|
workspace.resolve("Cargo.lock"),
|
|
workspace.resolve("tools/android-build/Cargo.toml"),
|
|
workspace.resolve("tools/android-build/src/main.rs"),
|
|
workspace.resolve("crates/storage/src/mobile.rs")
|
|
)
|
|
outputs.file(fixtureOutput)
|
|
commandLine(
|
|
cargoExecutable.get(),
|
|
"run",
|
|
"--locked",
|
|
"--package",
|
|
"ironstorage-android-build",
|
|
"--",
|
|
"fixtures",
|
|
fixtureOutput.get().asFile.absolutePath
|
|
)
|
|
}
|
|
androidComponents.onVariants(androidComponents.selector().withBuildType("debug")) { variant ->
|
|
variant.sources.kotlin!!.addStaticSourceDirectory(
|
|
layout.buildDirectory.dir("generated/fixtures").get().asFile.absolutePath
|
|
)
|
|
}
|
|
tasks.matching { it.name == "preDebugBuild" }.configureEach { dependsOn(generateShellFixtures) }
|