resolve_dependencies.gradle 2.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// This script is used to warm the Gradle cache by downloading the Flutter dependencies
// used during the build. This script is invoked when `flutter precache` is run.
//
// Command:
//  gradle -b <flutter-sdk>packages/flutter_tools/gradle/resolve_dependencies.gradle
//      resolveDependencies
//
// This way, Gradle can run with the `--offline` flag later on to eliminate any
// network request during the build process.
//
// This includes:
//   1. The embedding
//   2. libflutter.so

import java.nio.file.Paths

17
String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "https://storage.googleapis.com"
18

19 20 21 22 23 24
String engineRealm = Paths.get(flutterRoot.absolutePath, "bin", "internal", "engine.realm")
        .toFile().text.trim()
if (engineRealm) {
    engineRealm = engineRealm + "/"
}

25 26
repositories {
    google()
27
    mavenCentral()
28
    maven {
29
        url "$storageUrl/${engineRealm}download.flutter.io"
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    }
}

File flutterRoot = projectDir.parentFile.parentFile.parentFile

assert flutterRoot.isDirectory()
String engineVersion = Paths.get(flutterRoot.absolutePath, "bin", "internal", "engine.version")
        .toFile().text.trim()

configurations {
    flutterRelease.extendsFrom releaseImplementation
    flutterDebug.extendsFrom debugImplementation
    flutterProfile.extendsFrom debugImplementation
}

dependencies {
    flutterRelease "io.flutter:flutter_embedding_release:1.0.0-$engineVersion"
    flutterRelease "io.flutter:armeabi_v7a_release:1.0.0-$engineVersion"
    flutterRelease "io.flutter:arm64_v8a_release:1.0.0-$engineVersion"

    flutterProfile "io.flutter:flutter_embedding_profile:1.0.0-$engineVersion"
    flutterProfile "io.flutter:armeabi_v7a_profile:1.0.0-$engineVersion"
    flutterProfile "io.flutter:arm64_v8a_profile:1.0.0-$engineVersion"

    flutterDebug "io.flutter:flutter_embedding_debug:1.0.0-$engineVersion"
    flutterDebug "io.flutter:armeabi_v7a_debug:1.0.0-$engineVersion"
    flutterDebug "io.flutter:arm64_v8a_debug:1.0.0-$engineVersion"
    flutterDebug "io.flutter:x86_debug:1.0.0-$engineVersion"
    flutterDebug "io.flutter:x86_64_debug:1.0.0-$engineVersion"
}

task resolveDependencies {
    configurations.each { configuration ->
        if (configuration.name.startsWith("flutter")) {
            configuration.resolve()
        }
    }
}