mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 01:51:47 +00:00
Is the third time the charm? f-droid does not allow libraries pulled from non-listed maven repositories, thus the build fails in f-droid: https://gitlab.com/fdroid/fdroiddata/-/jobs/3654530159#L236 > Found unknown maven repo 'https://invent.kde.org/api/v4/projects/72/packages/maven' at settings.gradle This MR changes to use [jitpack](https://jitpack.io/#org.kde.invent.sredman/android-smsmms/kdeconnect-1-21-0), which is an allowed repository.
211 lines
8.3 KiB
Groovy
211 lines
8.3 KiB
Groovy
import com.android.build.gradle.AppExtension
|
|
import com.android.build.gradle.api.ApkVariantOutput
|
|
import com.android.build.gradle.api.ApplicationVariant
|
|
import com.github.jk1.license.render.TextReportRenderer
|
|
|
|
buildscript {
|
|
ext.kotlin_version = '1.7.21'
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:7.4.0'
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'com.github.jk1.dependency-license-report' version '1.16'
|
|
}
|
|
def licenseResDir = new File("$projectDir/build/dependency-license-res")
|
|
|
|
apply plugin: 'com.android.application'
|
|
apply plugin: 'kotlin-android'
|
|
|
|
android {
|
|
compileSdkVersion 33
|
|
defaultConfig {
|
|
minSdkVersion 21
|
|
targetSdkVersion 31
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
|
|
multiDexEnabled true
|
|
}
|
|
buildFeatures {
|
|
viewBinding true
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
|
|
// Flag to enable support for the new language APIs
|
|
coreLibraryDesugaringEnabled true
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = '1.8'
|
|
}
|
|
sourceSets {
|
|
main {
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
java.srcDirs = ['src']
|
|
resources.srcDirs = ['resources']
|
|
res.srcDirs = [licenseResDir, 'res']
|
|
assets.srcDirs = ['assets']
|
|
}
|
|
test {
|
|
java.srcDirs = ['tests']
|
|
}
|
|
}
|
|
packagingOptions {
|
|
resources {
|
|
merges += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
|
|
}
|
|
}
|
|
signingConfigs {
|
|
debug {
|
|
storeFile file("debug.keystore")
|
|
storePassword 'android'
|
|
keyAlias 'androiddebugkey'
|
|
keyPassword 'android'
|
|
}
|
|
}
|
|
buildTypes {
|
|
debug {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
signingConfig signingConfigs.debug
|
|
}
|
|
// keep minifyEnabled false above for faster builds; set to 'true'
|
|
// when testing to make sure ProGuard/R8 is not deleting important stuff
|
|
release {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
}
|
|
}
|
|
lint {
|
|
abortOnError false
|
|
checkReleaseBuilds false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This is a special on-demand Gradle object.
|
|
*
|
|
* Its value will not be determined until someone calls one of the gitHashProvider.getXXX() methods.
|
|
*
|
|
* If it does not encounter an explicit 'return' statement, getHashProvider.isPresent() will return false.
|
|
*/
|
|
Provider<String> gitHashProvider = project.provider {
|
|
Process gitCommand = null
|
|
try {
|
|
// This invokes 'git' immediately, but does not wait for it to finish
|
|
gitCommand = 'git rev-parse --short HEAD'.execute([], project.rootDir)
|
|
} catch (IOException ignored) {
|
|
}
|
|
|
|
if (gitCommand == null) {
|
|
logger.log(LogLevel.WARN, "Could not make use of the 'git' command-line tool. Output filenames will not be customized.")
|
|
} else if (gitCommand.waitFor() == 0) {
|
|
// This call to '::getText' (using the 'text' Groovy accessor syntax) collects the
|
|
// output stream
|
|
return '-' + gitCommand.text.trim()
|
|
} else {
|
|
logger.log(
|
|
LogLevel.WARN,
|
|
"Could not determine which commit is currently checked out -" +
|
|
" did you download this code without the .git directory?"
|
|
)
|
|
}
|
|
}
|
|
|
|
// We know we can safely cast the 'android' type to the 'AppExtension' class because
|
|
// we used the 'com.android.application' plugin at the top of the file.
|
|
//
|
|
// Note the use of the '::all' extension method; unlike '::each', it can detect every
|
|
// object added to the collection, no matter in which build phase that happens.
|
|
(android as AppExtension).applicationVariants.all { ApplicationVariant v ->
|
|
logger.log(LogLevel.INFO, "Found a variant called '${v.name}'.")
|
|
if (v.buildType.debuggable) {
|
|
// We're looking at variants made from android.buildTypes.debug! This one
|
|
// might have multiple outputs, but only one output will be an APK file.
|
|
v.outputs.matching { it instanceof ApkVariantOutput }.all {
|
|
// Default output filename is "${project.name}-${v.name}.apk". We want
|
|
// the Git commit short-hash to be added onto that default filename.
|
|
(it as ApkVariantOutput).outputFileName = "${project.name}-${v.name}${gitHashProvider.getOrElse("")}.apk"
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
coroutines_version = '1.6.0'
|
|
}
|
|
|
|
dependencies {
|
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
|
|
implementation 'androidx.multidex:multidex:2.0.1'
|
|
|
|
implementation 'androidx.media:media:1.6.0'
|
|
implementation 'androidx.appcompat:appcompat:1.6.0'
|
|
implementation 'androidx.core:core-ktx:1.9.0'
|
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
|
implementation 'androidx.documentfile:documentfile:1.0.1'
|
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
|
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
|
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
|
implementation 'androidx.lifecycle:lifecycle-common-java8:2.5.1'
|
|
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
|
implementation 'com.google.android.material:material:1.7.0'
|
|
implementation 'com.jakewharton:disklrucache:2.0.2' //For caching album art bitmaps
|
|
implementation 'com.jaredrummler:android-device-names:1.1.9' //To get a human-friendly device name
|
|
|
|
implementation 'org.apache.sshd:sshd-core:0.14.0'
|
|
implementation 'org.apache.mina:mina-core:2.0.19' //For some reason, makes sshd-core:0.14.0 work without NIO, which isn't available until Android 8 (api 26)
|
|
|
|
//implementation('com.github.bright:slf4android:0.1.6') { transitive = true } // For org.apache.sshd debugging
|
|
implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' //For SSL certificate generation
|
|
|
|
implementation 'org.atteo.classindex:classindex:3.6'
|
|
annotationProcessor 'org.atteo.classindex:classindex:3.6'
|
|
|
|
// The android-smsmms library is the only way I know to handle MMS in Android
|
|
// (Shouldn't a phone OS make phone things easy?)
|
|
// This library was originally authored as com.klinkerapps at https://github.com/klinker41/android-smsmms.
|
|
// However, that version is under-loved. I have therefore made "some fixes" and published it.
|
|
// Please see https://invent.kde.org/sredman/android-smsmms/-/tree/master
|
|
implementation 'org.kde.invent.sredman:android-smsmms:kdeconnect-1-21-0'
|
|
implementation 'com.klinkerapps:logger:1.0.3'
|
|
|
|
implementation 'commons-io:commons-io:2.8.0' // newer versions don't work on Android 7: https://stackoverflow.com/questions/73604534/no-static-method-threadlocal-withinitial-commons-io-dependency
|
|
implementation 'org.apache.commons:commons-collections4:4.4'
|
|
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
|
|
|
// Kotlin
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
|
|
|
|
// Testing
|
|
testImplementation 'junit:junit:4.13.2'
|
|
testImplementation 'org.powermock:powermock-core:2.0.0'
|
|
testImplementation 'org.powermock:powermock-module-junit4:2.0.0'
|
|
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0'
|
|
testImplementation 'org.mockito:mockito-core:3.12.4' // powermock isn't compatible with mockito 4
|
|
testImplementation 'org.skyscreamer:jsonassert:1.5.1'
|
|
|
|
// For device controls
|
|
implementation 'org.reactivestreams:reactive-streams:1.0.4'
|
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
|
|
}
|
|
|
|
licenseReport {
|
|
configurations = ALL
|
|
renderers = [new TextReportRenderer()]
|
|
}
|
|
generateLicenseReport.doLast {
|
|
def target = new File(licenseResDir, "raw/license")
|
|
target.parentFile.mkdirs()
|
|
target.text =
|
|
files("COPYING", "$projectDir/build/reports/dependency-license/THIRD-PARTY-NOTICES.txt")
|
|
.collect { it.getText() }.join('\n')
|
|
}
|
|
preBuild.dependsOn(generateLicenseReport)
|