Warning, /network/kdeconnect-android/build.gradle.kts is written in an unsupported language. File is not indexed.
0001 import com.github.jk1.license.LicenseReportExtension
0002 import com.github.jk1.license.render.ReportRenderer
0003 import com.github.jk1.license.render.TextReportRenderer
0004
0005 buildscript {
0006 dependencies {
0007 classpath(libs.android.gradlePlugin)
0008 classpath(libs.kotlin.gradlePlugin)
0009 }
0010 }
0011
0012 @Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed
0013 plugins {
0014 alias(libs.plugins.android.application)
0015 alias(libs.plugins.kotlin.android)
0016 alias(libs.plugins.dependencyLicenseReport)
0017 }
0018
0019 val licenseResDir = File("$projectDir/build/dependency-license-res")
0020
0021 fun String.runCommand(
0022 workingDir: File = File("."),
0023 timeoutAmount: Long = 60,
0024 timeoutUnit: TimeUnit = TimeUnit.SECONDS
0025 ): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
0026 .directory(workingDir)
0027 .redirectOutput(ProcessBuilder.Redirect.PIPE)
0028 .redirectError(ProcessBuilder.Redirect.PIPE)
0029 .start()
0030 .apply { waitFor(timeoutAmount, timeoutUnit) }
0031 .run {
0032 val error = errorStream.bufferedReader().readText().trim()
0033 if (error.isNotEmpty()) {
0034 throw Exception(error)
0035 }
0036 inputStream.bufferedReader().readText().trim()
0037 }
0038
0039 android {
0040 namespace = "org.kde.kdeconnect_tp"
0041 compileSdk = 34
0042 defaultConfig {
0043 minSdk = 21
0044 targetSdk = 33
0045 proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
0046 }
0047 buildFeatures {
0048 viewBinding = true
0049 compose = true
0050 }
0051
0052 composeOptions {
0053 kotlinCompilerExtensionVersion = "1.5.3"
0054 }
0055
0056 compileOptions {
0057 sourceCompatibility = JavaVersion.VERSION_1_8
0058 targetCompatibility = JavaVersion.VERSION_1_8
0059
0060 // Flag to enable support for the new language APIs
0061 isCoreLibraryDesugaringEnabled = true
0062 }
0063 kotlinOptions {
0064 jvmTarget = "1.8"
0065 }
0066
0067 androidResources {
0068 generateLocaleConfig = true
0069 }
0070 sourceSets {
0071 getByName("main") {
0072 manifest.srcFile("AndroidManifest.xml")
0073 java.setSrcDirs(listOf("src"))
0074 resources.setSrcDirs(listOf("resources"))
0075 res.setSrcDirs(listOf(licenseResDir, "res"))
0076 assets.setSrcDirs(listOf("assets"))
0077 }
0078 getByName("test") {
0079 java.setSrcDirs(listOf("tests"))
0080 }
0081 }
0082
0083 packaging {
0084 resources {
0085 merges += listOf("META-INF/DEPENDENCIES", "META-INF/LICENSE", "META-INF/NOTICE")
0086 }
0087 }
0088 signingConfigs {
0089 getByName("debug") {
0090 storeFile = file("debug.keystore")
0091 storePassword = "android"
0092 keyAlias = "androiddebugkey"
0093 keyPassword = "android"
0094 }
0095 }
0096 buildTypes {
0097 getByName("debug") {
0098 isMinifyEnabled = true
0099 isShrinkResources = true
0100 signingConfig = signingConfigs.getByName("debug")
0101 }
0102 // keep minifyEnabled false above for faster builds; set to 'true'
0103 // when testing to make sure ProGuard/R8 is not deleting important stuff
0104 getByName("release") {
0105 isMinifyEnabled = true
0106 isShrinkResources = true
0107 }
0108 }
0109 lint {
0110 abortOnError = false
0111 checkReleaseBuilds = false
0112 }
0113
0114 testOptions {
0115 unitTests.all {
0116 it.jvmArgs = it.jvmArgs.orEmpty() + listOf(
0117 "--add-opens=java.base/java.lang=ALL-UNNAMED",
0118 "--add-opens=java.base/java.security=ALL-UNNAMED",
0119 "--add-opens=java.base/sun.security.rsa=ALL-UNNAMED",
0120 "--add-opens=java.base/sun.security.x509=ALL-UNNAMED",
0121 "--add-opens=java.base/java.util=ALL-UNNAMED",
0122 "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED"
0123 )
0124 }
0125 }
0126
0127 applicationVariants.all {
0128 val variant = this
0129 logger.quiet("Found a variant called ${variant.name}")
0130
0131 if (variant.buildType.isDebuggable) {
0132 variant.outputs.all {
0133 val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
0134 if (output.outputFile.name.endsWith(".apk")) {
0135 // Default output filename is "${project.name}-${v.name}.apk". We want
0136 // the Git commit short-hash to be added onto that default filename.
0137 try {
0138 val hash = "git rev-parse --short HEAD".runCommand(workingDir = rootDir)
0139 val newName = "${project.name}-${variant.name}-${hash}.apk"
0140 logger.quiet(" Found an output file ${output.outputFile.name}, renaming to ${newName}")
0141 output.outputFileName = newName
0142 } catch (ignored: Exception) {
0143 logger.warn("Could not make use of the 'git' command-line tool. Output filenames will not be customized.")
0144 }
0145 }
0146 }
0147 }
0148 }
0149 }
0150
0151 dependencies {
0152 coreLibraryDesugaring(libs.android.desugarJdkLibs)
0153
0154 implementation(libs.androidx.compose.material3)
0155 implementation(libs.androidx.compose.ui.tooling.preview)
0156 implementation(libs.androidx.activity.compose)
0157 implementation(libs.accompanist.themeadapter.material3) // TODO: Remove deprecated library https://google.github.io/accompanist/themeadapter-material3/
0158 implementation(libs.androidx.constraintlayout.compose)
0159
0160 implementation(libs.androidx.compose.ui.tooling.preview)
0161 debugImplementation(libs.androidx.compose.ui.tooling)
0162
0163 implementation(libs.androidx.media)
0164 implementation(libs.androidx.appcompat)
0165 implementation(libs.androidx.core.ktx)
0166 implementation(libs.androidx.preference.ktx)
0167 implementation(libs.androidx.recyclerview)
0168 implementation(libs.androidx.swiperefreshlayout)
0169 implementation(libs.androidx.documentfile)
0170 implementation(libs.androidx.lifecycle.viewmodel.ktx)
0171 implementation(libs.androidx.lifecycle.runtime.ktx)
0172 implementation(libs.androidx.lifecycle.extensions)
0173 implementation(libs.androidx.lifecycle.common.java8)
0174 implementation(libs.androidx.gridlayout)
0175 implementation(libs.material)
0176 implementation(libs.disklrucache) //For caching album art bitmaps
0177 implementation(libs.slf4j.handroid)
0178
0179 implementation(libs.apache.sshd.core)
0180 implementation(libs.apache.mina.core) //For some reason, makes sshd-core:0.14.0 work without NIO, which isn't available until Android 8 (api 26)
0181
0182 //implementation("com.github.bright:slf4android:0.1.6") { transitive = true } // For org.apache.sshd debugging
0183 implementation(libs.bcpkix.jdk15on) //For SSL certificate generation
0184
0185 implementation(libs.classindex)
0186 annotationProcessor(libs.classindex)
0187
0188 // The android-smsmms library is the only way I know to handle MMS in Android
0189 // (Shouldn't a phone OS make phone things easy?)
0190 // This library was originally authored as com.klinkerapps at https://github.com/klinker41/android-smsmms.
0191 // However, that version is under-loved. I have therefore made "some fixes" and published it.
0192 // Please see https://invent.kde.org/sredman/android-smsmms/-/tree/master
0193 implementation(libs.android.smsmms)
0194 implementation(libs.logger)
0195
0196 implementation(libs.commons.io)
0197 implementation(libs.commons.collections4)
0198 implementation(libs.commons.lang3)
0199
0200 implementation(libs.univocity.parsers)
0201
0202 // Kotlin
0203 implementation(libs.kotlin.stdlib.jdk8)
0204 implementation(libs.kotlinx.coroutines.core)
0205 implementation(libs.kotlinx.coroutines.android)
0206
0207 // Testing
0208 testImplementation(libs.junit)
0209 testImplementation(libs.powermock.core)
0210 testImplementation(libs.powermock.module.junit4)
0211 testImplementation(libs.powermock.api.mockito2)
0212 testImplementation(libs.mockito.core) // powermock isn't compatible with mockito 4
0213 testImplementation(libs.jsonassert)
0214
0215 // For device controls
0216 implementation(libs.reactive.streams)
0217 implementation(libs.rxjava)
0218 }
0219
0220 licenseReport {
0221 configurations = LicenseReportExtension.ALL
0222 renderers = arrayOf<ReportRenderer>(TextReportRenderer())
0223 }
0224
0225 tasks.named("generateLicenseReport") {
0226 doLast {
0227 val target = File(licenseResDir, "raw/license")
0228 target.parentFile.mkdirs()
0229 target.writeText(
0230 files(
0231 layout.projectDirectory.file("COPYING"),
0232 layout.buildDirectory.file("reports/dependency-license/THIRD-PARTY-NOTICES.txt")
0233 ).joinToString(separator = "\n") {
0234 it.readText()
0235 }
0236 )
0237 }
0238 }
0239
0240 tasks.named("preBuild") {
0241 dependsOn("generateLicenseReport")
0242 }