2021-07-29 18:09:15 +02:00
|
|
|
import java.nio.file.Files
|
|
|
|
|
2018-03-20 18:44:23 +01:00
|
|
|
apply plugin: "com.android.application"
|
2021-07-20 12:08:12 +02:00
|
|
|
apply plugin: 'com.google.protobuf'
|
2016-08-30 01:25:43 +02:00
|
|
|
|
|
|
|
tasks.withType(Test) {
|
2018-03-20 18:44:23 +01:00
|
|
|
systemProperty "MiFirmwareDir", System.getProperty("MiFirmwareDir", null)
|
|
|
|
systemProperty "logback.configurationFile", System.getProperty("user.dir", null) + "/app/src/main/assets/logback.xml"
|
2021-07-29 18:09:15 +02:00
|
|
|
systemProperty "GB_LOGFILES_DIR", Files.createTempDirectory("gblog").toString()
|
2016-08-30 01:25:43 +02:00
|
|
|
}
|
2023-08-09 20:52:03 +02:00
|
|
|
|
2022-01-27 18:00:22 +01:00
|
|
|
def getVersionCode = { ->
|
|
|
|
try {
|
2024-06-30 21:41:02 +02:00
|
|
|
def commitCount = providers.exec {
|
|
|
|
commandLine('git', 'rev-list', 'HEAD', '--count')
|
|
|
|
}.standardOutput.asText.get().trim()
|
|
|
|
return Integer.valueOf(commitCount)
|
2022-01-27 18:00:22 +01:00
|
|
|
} catch (ignored) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
2016-03-17 23:41:41 +01:00
|
|
|
|
2023-08-09 20:52:03 +02:00
|
|
|
def buildGitChangelog = {
|
2024-06-30 21:41:02 +02:00
|
|
|
def allCommits = providers.exec {
|
|
|
|
commandLine('git', 'log', '--pretty=format:%h %s')
|
|
|
|
}.standardOutput.asText.get()
|
2023-08-09 20:52:03 +02:00
|
|
|
|
|
|
|
def commitVersionCode = getVersionCode()
|
2023-09-17 16:40:14 +02:00
|
|
|
def includedCommits = 0
|
2023-08-09 20:52:03 +02:00
|
|
|
def changelogNode = new Node(null, 'changelog')
|
|
|
|
|
2024-06-30 21:41:02 +02:00
|
|
|
allCommits.trim().eachLine { line ->
|
2023-09-17 16:40:14 +02:00
|
|
|
if (includedCommits > 100) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-08-09 20:52:03 +02:00
|
|
|
def (commitHash, commitMessage) = line.split(" ", 2)
|
2023-09-17 16:40:14 +02:00
|
|
|
if (commitMessage.contains("Translated using Weblate")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-08-09 20:52:03 +02:00
|
|
|
def releaseNode = new Node(changelogNode, 'release', [version: commitHash, versioncode: commitVersionCode--])
|
|
|
|
def _ = new Node(releaseNode, 'change', [:], commitMessage)
|
2023-09-17 16:40:14 +02:00
|
|
|
includedCommits++
|
2023-08-09 20:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def changelogFile = new File("${project.rootDir}/app/build/generated/res/changelog/xml/changelog_git.xml")
|
|
|
|
changelogFile.getParentFile().mkdirs()
|
|
|
|
changelogFile.write(groovy.xml.XmlUtil.serialize(changelogNode))
|
|
|
|
}
|
|
|
|
|
2021-12-30 08:21:37 +01:00
|
|
|
def getGitHashShort = { ->
|
|
|
|
try {
|
2024-06-30 21:41:02 +02:00
|
|
|
return providers.exec {
|
|
|
|
commandLine('git', 'rev-parse', '--short', 'HEAD')
|
|
|
|
}.standardOutput.asText.get().trim()
|
2024-02-05 18:19:15 +01:00
|
|
|
} catch (ignored) {
|
2021-12-30 08:21:37 +01:00
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
android {
|
2016-08-26 23:27:53 +02:00
|
|
|
compileOptions {
|
2024-07-04 21:20:00 +02:00
|
|
|
coreLibraryDesugaringEnabled true
|
|
|
|
|
2022-09-09 19:58:34 +02:00
|
|
|
// for Android 5+
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
2016-08-26 23:27:53 +02:00
|
|
|
}
|
2024-01-19 18:49:37 +01:00
|
|
|
|
|
|
|
namespace 'nodomain.freeyourgadget.gadgetbridge'
|
2015-01-07 14:00:18 +01:00
|
|
|
|
|
|
|
defaultConfig {
|
2016-04-29 23:24:12 +02:00
|
|
|
applicationId "nodomain.freeyourgadget.gadgetbridge"
|
2024-01-19 18:49:37 +01:00
|
|
|
|
2024-02-05 18:19:15 +01:00
|
|
|
//noinspection OldTargetApi
|
2023-06-02 17:57:44 +02:00
|
|
|
targetSdkVersion 33
|
2024-01-19 18:49:37 +01:00
|
|
|
compileSdk 33
|
2024-02-05 18:19:15 +01:00
|
|
|
minSdkVersion 21
|
2015-12-07 18:10:00 +01:00
|
|
|
|
2018-03-20 18:44:23 +01:00
|
|
|
// Note: always bump BOTH versionCode and versionName!
|
2024-06-28 16:54:30 +02:00
|
|
|
versionName "0.81.0"
|
|
|
|
versionCode 232
|
2016-10-21 13:01:30 +02:00
|
|
|
vectorDrawables.useSupportLibrary = true
|
2021-12-30 08:21:37 +01:00
|
|
|
buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\""
|
2022-03-31 11:36:26 +02:00
|
|
|
buildConfigField "boolean", "INTERNET_ACCESS", "false"
|
2022-01-27 18:00:22 +01:00
|
|
|
}
|
2024-02-05 18:19:15 +01:00
|
|
|
|
2022-01-27 18:00:22 +01:00
|
|
|
signingConfigs {
|
|
|
|
nightly {
|
|
|
|
if (System.getProperty("nightly_store_file") != null) {
|
|
|
|
storeFile file(System.getProperty("nightly_store_file"))
|
|
|
|
storePassword System.getProperty("nightly_store_password")
|
|
|
|
keyAlias System.getProperty("nightly_key_alias")
|
|
|
|
keyPassword System.getProperty("nightly_key_password")
|
|
|
|
}
|
|
|
|
}
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
2022-08-10 22:16:32 +02:00
|
|
|
|
|
|
|
flavorDimensions "device_type"
|
|
|
|
productFlavors {
|
2024-01-19 18:49:37 +01:00
|
|
|
mainline {
|
|
|
|
// Ensure that when starting from scratch, 'mainline' is selected, not 'banglejs'
|
2022-08-10 22:16:32 +02:00
|
|
|
getIsDefault().set(true)
|
|
|
|
// the default build product flavor
|
|
|
|
dimension "device_type"
|
|
|
|
//applicationIdSuffix ""
|
|
|
|
//versionNameSuffix ""
|
|
|
|
}
|
2024-02-05 18:19:15 +01:00
|
|
|
|
2022-08-10 22:16:32 +02:00
|
|
|
banglejs {
|
|
|
|
dimension "device_type"
|
|
|
|
applicationId "com.espruino.gadgetbridge"
|
|
|
|
applicationIdSuffix ".banglejs"
|
|
|
|
versionNameSuffix "-banglejs"
|
|
|
|
buildConfigField "boolean", "INTERNET_ACCESS", "true"
|
2023-06-02 17:57:44 +02:00
|
|
|
targetSdkVersion 33
|
|
|
|
// Note: app/src/banglejs/AndroidManifest.xml contains some extra permissions
|
2022-08-10 22:16:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-09 20:52:03 +02:00
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
res.srcDirs += "build/generated/res/changelog"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
buildTypes {
|
|
|
|
release {
|
2020-10-11 16:10:35 +02:00
|
|
|
minifyEnabled true
|
2018-03-20 18:44:23 +01:00
|
|
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
2022-01-27 18:00:22 +01:00
|
|
|
|
|
|
|
nightly {
|
|
|
|
applicationIdSuffix ".nightly"
|
|
|
|
versionNameSuffix "-${getGitHashShort}"
|
|
|
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
2024-02-05 18:19:15 +01:00
|
|
|
minifyEnabled true
|
2024-06-29 22:56:04 +02:00
|
|
|
debuggable false
|
2022-08-10 22:16:32 +02:00
|
|
|
|
|
|
|
if (System.getProperty("nightly_store_file") != null) {
|
|
|
|
signingConfig signingConfigs.nightly
|
|
|
|
} else {
|
|
|
|
signingConfig signingConfigs.debug
|
|
|
|
}
|
2022-01-27 18:00:22 +01:00
|
|
|
}
|
2024-02-05 18:19:15 +01:00
|
|
|
|
2022-01-27 18:00:22 +01:00
|
|
|
nopebble {
|
|
|
|
applicationIdSuffix ".nightly_nopebble"
|
|
|
|
versionNameSuffix "-${getGitHashShort}"
|
2024-02-05 18:19:15 +01:00
|
|
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
2022-01-27 18:00:22 +01:00
|
|
|
minifyEnabled true
|
2024-06-29 22:56:04 +02:00
|
|
|
debuggable false
|
2024-02-05 18:19:15 +01:00
|
|
|
|
2022-01-27 18:00:22 +01:00
|
|
|
if (System.getProperty("nightly_store_file") != null) {
|
|
|
|
signingConfig signingConfigs.nightly
|
|
|
|
} else {
|
|
|
|
signingConfig signingConfigs.debug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
applicationVariants.all { variant ->
|
|
|
|
variant.resValue "string", "applicationId", variant.applicationId
|
2023-08-09 20:52:03 +02:00
|
|
|
buildGitChangelog()
|
2022-01-27 18:00:22 +01:00
|
|
|
|
|
|
|
if (variant.buildType.name == 'nightly' || variant.buildType.name == 'nopebble') {
|
|
|
|
variant.outputs.all {
|
|
|
|
setVersionCodeOverride(getVersionCode())
|
|
|
|
//setVersionNameOverride(getGitHashShort())
|
|
|
|
setVersionNameOverride(variant.versionName)
|
|
|
|
outputFileName = "${applicationId}_${variant.versionName}.apk"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
2015-08-15 22:36:45 +02:00
|
|
|
|
2024-01-19 18:49:37 +01:00
|
|
|
lint {
|
2024-06-29 22:56:04 +02:00
|
|
|
abortOnError true
|
2024-01-19 18:49:37 +01:00
|
|
|
lintConfig file("$rootDir/app/src/main/lint.xml")
|
2023-09-11 11:17:04 +02:00
|
|
|
// If true, generate an HTML report (with issue explanations, sourcecode, etc)
|
2015-08-15 22:36:45 +02:00
|
|
|
htmlReport true
|
2023-09-11 11:17:04 +02:00
|
|
|
// Optional path to report (default will be lint-results.html in the builddir)
|
2015-08-15 22:36:45 +02:00
|
|
|
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
2023-09-11 11:17:04 +02:00
|
|
|
// Ignore checks present in the snapshot
|
|
|
|
baseline file("lint-baseline.xml")
|
2015-08-15 22:36:45 +02:00
|
|
|
}
|
2015-08-22 01:08:46 +02:00
|
|
|
|
|
|
|
testOptions {
|
2018-03-22 21:01:59 +01:00
|
|
|
unitTests {
|
|
|
|
returnDefaultValues = true
|
|
|
|
includeAndroidResources = true
|
|
|
|
}
|
2015-08-22 01:08:46 +02:00
|
|
|
}
|
2024-06-29 22:56:04 +02:00
|
|
|
buildFeatures {
|
|
|
|
aidl true
|
|
|
|
buildConfig true
|
|
|
|
}
|
2016-08-26 22:27:17 +02:00
|
|
|
}
|
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
dependencies {
|
2024-07-04 21:20:00 +02:00
|
|
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
|
|
|
|
2024-07-03 01:11:06 +02:00
|
|
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
2024-05-05 21:14:42 +02:00
|
|
|
implementation "androidx.camera:camera-core:1.2.3"
|
|
|
|
implementation "androidx.camera:camera-camera2:1.2.3"
|
|
|
|
implementation 'androidx.camera:camera-view:1.2.3'
|
|
|
|
implementation 'androidx.camera:camera-lifecycle:1.2.3'
|
2024-07-03 20:00:52 +02:00
|
|
|
|
2022-09-10 22:38:57 +02:00
|
|
|
testImplementation "junit:junit:4.13.2"
|
2024-07-03 19:51:46 +02:00
|
|
|
testImplementation "org.mockito:mockito-core:5.12.0"
|
2024-07-03 01:09:38 +02:00
|
|
|
testImplementation "org.robolectric:robolectric:4.12.2"
|
2024-04-16 00:45:55 +02:00
|
|
|
testImplementation "org.hamcrest:hamcrest-library:2.2"
|
2018-03-20 18:44:23 +01:00
|
|
|
|
2023-10-04 13:40:28 +02:00
|
|
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
|
|
|
implementation "androidx.preference:preference:1.2.1"
|
2019-01-26 15:52:40 +01:00
|
|
|
implementation "androidx.cardview:cardview:1.0.0"
|
2024-04-04 21:28:04 +02:00
|
|
|
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
2019-01-26 15:52:40 +01:00
|
|
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
|
|
|
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
|
|
|
implementation "androidx.palette:palette:1.0.0"
|
2023-10-04 13:40:28 +02:00
|
|
|
implementation "androidx.activity:activity:1.7.2"
|
2024-04-04 21:28:04 +02:00
|
|
|
implementation "androidx.fragment:fragment:1.6.2"
|
2024-04-08 22:23:34 +02:00
|
|
|
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
2021-04-21 16:48:41 +02:00
|
|
|
|
2023-10-04 13:40:28 +02:00
|
|
|
implementation "com.google.android.material:material:1.9.0"
|
2021-05-26 13:26:34 +02:00
|
|
|
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
2023-10-04 13:40:28 +02:00
|
|
|
implementation "com.google.code.gson:gson:2.8.9"
|
2021-04-21 16:48:41 +02:00
|
|
|
|
2023-07-14 16:08:24 +02:00
|
|
|
implementation "no.nordicsemi.android:dfu:1.12.0"
|
2024-07-03 00:58:41 +02:00
|
|
|
implementation "com.github.tony19:logback-android:3.0.0"
|
|
|
|
implementation "org.slf4j:slf4j-api:2.0.13"
|
2024-07-04 22:21:43 +02:00
|
|
|
implementation "com.github.PhilJay:MPAndroidChart:3.1.0"
|
2018-03-20 18:44:23 +01:00
|
|
|
implementation "com.github.pfichtner:durationformatter:0.1.1"
|
|
|
|
implementation "de.cketti.library.changelog:ckchangelog:1.2.2"
|
2024-07-04 22:21:43 +02:00
|
|
|
implementation "net.e175.klaus:solarpositioning:0.1.10"
|
2022-09-19 21:45:58 +02:00
|
|
|
implementation "co.nstant.in:cbor:0.9"
|
2017-04-10 21:36:44 +02:00
|
|
|
// use pristine greendao instead of our custom version, since our custom jitpack-packaged
|
|
|
|
// version contains way too much and our custom patches are in the generator only.
|
2018-03-20 18:44:23 +01:00
|
|
|
implementation "org.greenrobot:greendao:2.2.1"
|
2019-05-23 22:02:25 +02:00
|
|
|
implementation "org.apache.commons:commons-lang3:3.7"
|
2018-03-20 18:44:23 +01:00
|
|
|
implementation "org.cyanogenmod:platform.sdk:6.0"
|
2024-07-03 01:11:30 +02:00
|
|
|
implementation 'com.jaredrummler:colorpicker:1.1.0'
|
2024-07-03 01:12:11 +02:00
|
|
|
implementation 'com.github.wax911:android-emojify:1.9.2'
|
2024-07-03 00:36:46 +02:00
|
|
|
implementation 'com.google.protobuf:protobuf-javalite:4.27.2'
|
2022-03-31 11:36:26 +02:00
|
|
|
implementation 'com.android.volley:volley:1.2.1'
|
2022-10-06 10:22:41 +02:00
|
|
|
|
2023-10-05 11:40:49 +02:00
|
|
|
// Bouncy Castle is included directly in GB, to avoid pulling the entire dependency
|
2024-07-03 20:00:52 +02:00
|
|
|
// It's included in the org.bouncycastle.shaded package, to fix conflicts with roboelectric
|
2023-11-25 22:15:31 +01:00
|
|
|
//implementation 'org.bouncycastle:bcpkix-jdk18on:1.76'
|
|
|
|
//implementation 'org.bouncycastle:bcprov-jdk18on:1.76'
|
2023-10-02 10:48:10 +02:00
|
|
|
|
2022-08-18 23:03:28 +02:00
|
|
|
// Android SDK bundles org.json, but we need an actual implementation to replace the stubs in tests
|
2024-03-31 00:02:31 +01:00
|
|
|
testImplementation 'org.json:json:20240303'
|
2023-10-04 13:40:28 +02:00
|
|
|
|
|
|
|
// Fix Duplicate class build error
|
|
|
|
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
|
2021-04-23 10:11:04 +02:00
|
|
|
|
|
|
|
// Needed for Armenian transliteration
|
2024-07-03 20:00:52 +02:00
|
|
|
implementation 'org.ahocorasick:ahocorasick:0.6.3'
|
2016-03-27 22:13:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
preBuild.dependsOn(":GBDaoGenerator:genSources")
|
2018-03-20 18:44:23 +01:00
|
|
|
|
2016-03-27 22:13:06 +02:00
|
|
|
gradle.beforeProject {
|
|
|
|
preBuild.dependsOn(":GBDaoGenerator:genSources")
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
2015-08-15 22:36:45 +02:00
|
|
|
|
2019-09-19 22:31:49 +02:00
|
|
|
sourceSets {
|
|
|
|
main {
|
2024-02-05 18:19:15 +01:00
|
|
|
java.srcDirs += "${protobuf.generatedFilesBaseDir}"
|
|
|
|
java.srcDirs += "build/generated/source/buildConfig"
|
2019-09-19 22:31:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-29 22:56:04 +02:00
|
|
|
tasks.register('cleanGenerated', Delete) {
|
2022-09-18 13:19:23 +02:00
|
|
|
delete fileTree('src/main/java/nodomain/freeyourgadget/gadgetbridge/entities') {
|
|
|
|
include '**/*.java'
|
|
|
|
exclude '**/Abstract*.java'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.clean.dependsOn(tasks.cleanGenerated)
|
2022-09-09 08:15:38 +02:00
|
|
|
|
2021-07-20 12:08:12 +02:00
|
|
|
protobuf {
|
|
|
|
protoc {
|
2024-07-03 00:36:46 +02:00
|
|
|
artifact = 'com.google.protobuf:protoc:4.27.2'
|
2021-07-20 12:08:12 +02:00
|
|
|
}
|
|
|
|
generateProtoTasks {
|
|
|
|
all().each { task ->
|
|
|
|
task.builtins {
|
2022-09-18 13:19:23 +02:00
|
|
|
java {
|
|
|
|
option 'lite'
|
|
|
|
}
|
2021-07-20 12:08:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|