Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

6.3 KB
Raw Blame
plugins {
    id "com.google.gms.google-services" version "4.4.4" apply false
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id 'org.jetbrains.kotlin.plugin.serialization' version '2.2.20'
}

if (file("google-services.json").exists()) {
    apply plugin: "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

// Ente's custom prebuilt ONNX Runtime AAR is resolved straight from its
// GitHub release through an Ivy repository; its SHA-256 is pinned in
// gradle/verification-metadata.xml.
repositories {
    exclusiveContent {
        forRepository {
            ivy {
                name = 'enteOnnxRuntimePackaging'
                url = 'https://github.com/ente/ort-packaging/releases/download'
                patternLayout {
                    artifact 'ort-[revision]/[artifact]-[revision].[ext]'
                }
                metadataSources { artifact() }
            }
        }
        filter { includeGroup 'io.ente.onnxruntime' }
    }
}

android {
    namespace = "io.ente.photos"

    compileOptions {
        coreLibraryDesugaringEnabled = true
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
        warningsAsErrors false
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId = "io.ente.photos"
        minSdk = 26
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        consumerProguardFiles 'proguard-rules.pro'
        ndk {
            abiFilters.clear()
            abiFilters "armeabi-v7a", "arm64-v8a"
        }
    }

    signingConfigs {
       release {
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : System.getenv("SIGNING_KEY_PATH") ? file(System.getenv("SIGNING_KEY_PATH")) : null
           keyAlias keystoreProperties['keyAlias'] ? keystoreProperties['keyAlias'] : System.getenv("SIGNING_KEY_ALIAS")
           keyPassword keystoreProperties['keyPassword'] ? keystoreProperties['keyPassword'] : System.getenv("SIGNING_KEY_PASSWORD")
           storePassword keystoreProperties['storePassword'] ? keystoreProperties['storePassword'] : System.getenv("SIGNING_STORE_PASSWORD")
       }
    }

    flavorDimensions "default"
    productFlavors {
        independent {
            dimension "default"
            applicationIdSuffix ".independent"
        }
        dev {
            dimension "default"
            applicationIdSuffix ".dev"
        }
        playstore {
            dimension "default"
        }
        fdroid {
            dimension "default"
            applicationIdSuffix ".fdroid"
        }
    }

    packagingOptions {
        pickFirst 'lib/*/libc++_shared.so'
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile(
                "proguard-android-optimize.txt",
            ), "proguard-rules.pro"
        }
        debug {
          applicationIdSuffix '.debug'
          versionNameSuffix "-debug"
          ndk {
            abiFilters "x86_64"
          }
          externalNativeBuild {
            cmake {
              arguments "-DANDROID_PACKAGE_NAME=${android.defaultConfig.applicationId}${applicationIdSuffix}"
            }
          }
        }
    }

    packagingOptions {
        jniLibs {
            pickFirsts += ['**/libc++_shared.so']
            useLegacyPackaging = false
        }
    }

    android.applicationVariants.all { variant ->
        if (variant.flavorName == "fdroid") {
            variant.outputs.all { output ->
                output.outputFileName = "app-fdroid-release.apk"
            }
        }
    }
}

rootProject.allprojects {
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.github.bumptech.glide'
                        && details.requested.name.contains('glide')) {
                    details.useVersion "4.15.1"
            }
          }
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    implementation 'androidx.exifinterface:exifinterface:1.3.7'
    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    // Custom WebGPU/XNNPACK build required by Rust ML, which dynamically
    // loads libonnxruntime.so.
    implementation 'io.ente.onnxruntime:onnxruntime-webgpu-android:1.31.0-r1@aar'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")

    constraints {
        // TODO: Remove this once https://github.com/ABausG/home_widget/issues/417
        // is closed and the fix is available in a stable home_widget release.
        implementation("androidx.glance:glance-appwidget") {
            version {
                strictly "1.1.1"
            }
            because("home_widget requests 1.+, which can resolve to pre-release Glance versions requiring newer Android tooling")
        }
        implementation("androidx.work:work-runtime:2.8.1") {
            because("Align work-runtime versions")
        }
        implementation("androidx.work:work-runtime-ktx:2.8.1") {
            because("Align work-runtime-ktx versions")
        }
    }
}