2026-08-04 23:32:44 +08:00
|
|
|
import groovy.json.JsonSlurper
|
2026-08-07 18:00:38 +08:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2026-08-04 23:32:44 +08:00
|
|
|
|
2026-08-04 23:28:10 +08:00
|
|
|
plugins {
|
2026-08-07 18:00:38 +08:00
|
|
|
alias(libs.plugins.android.application)
|
|
|
|
|
alias(libs.plugins.kotlin.android)
|
|
|
|
|
alias(libs.plugins.kotlin.kapt)
|
|
|
|
|
alias(libs.plugins.hilt)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
android {
|
|
|
|
|
namespace = "net.opcapp.flash"
|
|
|
|
|
compileSdk = 34
|
|
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
|
applicationId = "net.opcapp.flash"
|
|
|
|
|
minSdk = 26
|
|
|
|
|
targetSdk = 34
|
|
|
|
|
versionCode = 1
|
|
|
|
|
versionName = "0.1.0"
|
|
|
|
|
|
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
|
vectorDrawables.useSupportLibrary = true
|
|
|
|
|
|
|
|
|
|
javaCompileOptions {
|
|
|
|
|
annotationProcessorOptions {
|
|
|
|
|
arguments += mapOf("room.schemaLocation" to "$projectDir/schemas")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
|
release {
|
|
|
|
|
isMinifyEnabled = false
|
|
|
|
|
proguardFiles(
|
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
|
"proguard-rules.pro",
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildFeatures {
|
|
|
|
|
compose = true
|
|
|
|
|
buildConfig = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composeOptions {
|
|
|
|
|
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
packaging {
|
|
|
|
|
resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-19 11:48:16 +08:00
|
|
|
sourceSets {
|
|
|
|
|
getByName("main").assets.srcDir(rootProject.file("content/packages"))
|
|
|
|
|
getByName("test").resources.srcDir(rootProject.file("content/packages"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 18:00:38 +08:00
|
|
|
testOptions {
|
|
|
|
|
unitTests.isReturnDefaultValues = true
|
|
|
|
|
}
|
2026-08-04 23:28:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kotlin {
|
|
|
|
|
jvmToolchain(17)
|
|
|
|
|
}
|
2026-08-07 18:00:38 +08:00
|
|
|
|
|
|
|
|
kapt {
|
|
|
|
|
correctErrorTypes = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tasks.withType<KotlinCompile>().configureEach {
|
|
|
|
|
kotlinOptions.jvmTarget = "17"
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 23:28:10 +08:00
|
|
|
dependencies {
|
2026-08-07 18:00:38 +08:00
|
|
|
val composeBom = platform(libs.androidx.compose.bom)
|
|
|
|
|
|
|
|
|
|
implementation(libs.androidx.core.ktx)
|
|
|
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
2026-08-19 10:58:09 +08:00
|
|
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
2026-08-07 18:00:38 +08:00
|
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
|
|
|
implementation(composeBom)
|
|
|
|
|
implementation(libs.androidx.compose.ui)
|
|
|
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
|
|
|
implementation(libs.androidx.compose.material3)
|
|
|
|
|
implementation(libs.androidx.navigation.compose)
|
|
|
|
|
implementation(libs.androidx.room.runtime)
|
|
|
|
|
implementation(libs.androidx.room.ktx)
|
|
|
|
|
kapt(libs.androidx.room.compiler)
|
|
|
|
|
implementation(libs.androidx.datastore.preferences)
|
|
|
|
|
implementation(libs.hilt.android)
|
|
|
|
|
kapt(libs.hilt.compiler)
|
|
|
|
|
|
2026-08-04 23:28:10 +08:00
|
|
|
testImplementation(libs.junit)
|
2026-08-07 18:00:38 +08:00
|
|
|
|
|
|
|
|
androidTestImplementation(composeBom)
|
|
|
|
|
androidTestImplementation(libs.androidx.test.ext.junit)
|
|
|
|
|
androidTestImplementation(libs.androidx.test.runner)
|
|
|
|
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
2026-08-19 10:58:09 +08:00
|
|
|
androidTestImplementation(libs.androidx.room.testing)
|
2026-08-07 18:00:38 +08:00
|
|
|
|
|
|
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
|
|
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
2026-08-04 23:28:10 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-07 18:00:38 +08:00
|
|
|
tasks.withType<Test>().configureEach {
|
2026-08-04 23:28:10 +08:00
|
|
|
useJUnit()
|
2026-08-19 10:58:09 +08:00
|
|
|
maxParallelForks = 1
|
|
|
|
|
maxHeapSize = "192m"
|
|
|
|
|
jvmArgs("-XX:MaxMetaspaceSize=128m", "-XX:+UseSerialGC")
|
2026-08-04 23:28:10 +08:00
|
|
|
testLogging {
|
|
|
|
|
events("failed", "skipped")
|
|
|
|
|
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-04 23:32:44 +08:00
|
|
|
|
|
|
|
|
tasks.register("verifyDependencyLicenses") {
|
|
|
|
|
group = "verification"
|
2026-08-07 18:00:38 +08:00
|
|
|
description = "Ensures every resolved debug runtime/test artifact has a reviewed license entry."
|
2026-08-04 23:32:44 +08:00
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
|
val manifest = JsonSlurper().parse(rootProject.file("config/dependency-licenses.json")) as Map<String, Any>
|
|
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
|
val components = manifest.getValue("components") as List<Map<String, Any>>
|
2026-08-07 18:00:38 +08:00
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
|
val groupPolicies = manifest.getValue("groupPolicies") as List<Map<String, Any>>
|
2026-08-04 23:32:44 +08:00
|
|
|
val reviewedCoordinates = components.mapNotNull { it["coordinates"] as String? }.toSet()
|
2026-08-19 10:58:09 +08:00
|
|
|
val resolvedCoordinates = listOf(
|
|
|
|
|
"debugRuntimeClasspath",
|
|
|
|
|
"debugUnitTestRuntimeClasspath",
|
|
|
|
|
"debugAndroidTestRuntimeClasspath",
|
|
|
|
|
)
|
2026-08-07 18:00:38 +08:00
|
|
|
.flatMap { configurationName ->
|
|
|
|
|
configurations.getByName(configurationName)
|
|
|
|
|
.resolvedConfiguration
|
|
|
|
|
.resolvedArtifacts
|
|
|
|
|
.mapNotNull { artifact ->
|
|
|
|
|
if (artifact.id.componentIdentifier !is org.gradle.api.artifacts.component.ModuleComponentIdentifier) {
|
|
|
|
|
return@mapNotNull null
|
|
|
|
|
}
|
|
|
|
|
val id = artifact.moduleVersion.id
|
|
|
|
|
"${id.group}:${id.name}:${id.version}"
|
|
|
|
|
}
|
2026-08-04 23:32:44 +08:00
|
|
|
}
|
|
|
|
|
.toSet()
|
2026-08-07 18:00:38 +08:00
|
|
|
val missing = resolvedCoordinates.filterNot { coordinates ->
|
|
|
|
|
if (coordinates in reviewedCoordinates) return@filterNot true
|
|
|
|
|
val group = coordinates.substringBefore(":")
|
|
|
|
|
groupPolicies.any { policy ->
|
|
|
|
|
val prefix = policy.getValue("groupPrefix") as String
|
|
|
|
|
group == prefix || group.startsWith("$prefix.")
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-04 23:32:44 +08:00
|
|
|
check(missing.isEmpty()) {
|
|
|
|
|
"Dependencies missing reviewed license entries: ${missing.sorted().joinToString()}"
|
|
|
|
|
}
|
2026-08-07 18:00:38 +08:00
|
|
|
logger.lifecycle(
|
|
|
|
|
"Dependency license coverage passed for ${resolvedCoordinates.size} artifacts " +
|
|
|
|
|
"with ${groupPolicies.size} reviewed group policies.",
|
|
|
|
|
)
|
2026-08-04 23:32:44 +08:00
|
|
|
}
|
|
|
|
|
}
|