Scaffold native Android build and enforce Rust boundaries (#89)
Dependency security audit / rustsec (push) Failing after 22s
Dependency security audit / rustsec (push) Failing after 22s
This commit is contained in:
1 parent
30d9119302
commit
e079b82b15
62 files changed
+5822
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import java.io.File
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
alias(libs.plugins.kotlin.jvm) apply false
|
||||
alias(libs.plugins.compose) apply false
|
||||
alias(libs.plugins.hilt) apply false
|
||||
alias(libs.plugins.ksp) apply false
|
||||
alias(libs.plugins.ktlint) apply false
|
||||
}
|
||||
|
||||
val allowed = mapOf(
|
||||
":app" to setOf(":features", ":core", ":platform"),
|
||||
":features" to setOf(":core"),
|
||||
":core" to setOf(":rust-bridge"),
|
||||
":platform" to setOf(":core"),
|
||||
":rust-bridge" to emptySet(),
|
||||
)
|
||||
subprojects {
|
||||
apply(plugin = "org.jlleitschuh.gradle.ktlint")
|
||||
extensions.configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
|
||||
version.set(rootProject.libs.versions.ktlint.get())
|
||||
filter { exclude("**/build/**") }
|
||||
}
|
||||
dependencyLocking { lockAllConfigurations() }
|
||||
val ownerPath = project.path
|
||||
configurations.configureEach {
|
||||
dependencies.withType<ProjectDependency>().configureEach {
|
||||
val destination = this.path
|
||||
require(destination == ownerPath || destination in allowed.getValue(ownerPath)) {
|
||||
"$ownerPath cannot depend on $destination"
|
||||
}
|
||||
}
|
||||
dependencies.withType<ExternalModuleDependency>().configureEach {
|
||||
require(group.orEmpty().let { group ->
|
||||
listOf("org.eclipse.jgit", "org.bouncycastle", "androidx.room", "com.squareup.retrofit2", "com.squareup.okhttp3").none { group.startsWith(it) }
|
||||
}) { "Domain libraries must stay in crates/storage: $group:$name" }
|
||||
}
|
||||
resolutionStrategy.eachDependency {
|
||||
require(!requested.version.orEmpty().contains('+')) { "Dynamic versions are forbidden" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 = layout.projectDirectory.dir("..").asFile
|
||||
val checkArchitecture = tasks.register<Exec>("checkArchitecture") {
|
||||
workingDir = workspace
|
||||
inputs.files(fileTree(".") { include("**/src/**/*.kt", "**/build.gradle.kts"); exclude("**/build/**", ".gradle/**") })
|
||||
inputs.files(workspace.resolve("Cargo.lock"), workspace.resolve("tools/android-build/src/main.rs"))
|
||||
commandLine(cargoExecutable.get(), "run", "--locked", "--package", "ironstorage-android-build", "--", "check", layout.projectDirectory.asFile.absolutePath)
|
||||
}
|
||||
subprojects {
|
||||
tasks.matching { it.name == "preBuild" || it.name == "check" }.configureEach { dependsOn(rootProject.tasks.named("checkArchitecture")) }
|
||||
}
|
||||
Reference in new issue
Block a user