|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +// To use, run: |
| 6 | +// $ gradle updateDependencies |
| 7 | +// |
| 8 | +// This script downloads the embedding dependencies into a lib/ directory, |
| 9 | +// extract jar files from AARs, so they can be used in gn. |
| 10 | +def destinationDir = "lib" |
| 11 | + |
| 12 | +buildscript { |
| 13 | + repositories { |
| 14 | + google() |
| 15 | + jcenter() |
| 16 | + } |
| 17 | + dependencies { |
| 18 | + classpath "com.android.tools.build:gradle:3.5.0" |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +allprojects { |
| 23 | + repositories { |
| 24 | + google() |
| 25 | + jcenter() |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +apply plugin: "com.android.application" |
| 30 | + |
| 31 | +configurations { |
| 32 | + // Use this configuration for dependencies required by the embedding. |
| 33 | + embedding |
| 34 | + // Use any of these configurations for dependencies required for testing the embedding. |
| 35 | + embeddingTesting |
| 36 | + embeddingTesting_duplicated |
| 37 | +} |
| 38 | + |
| 39 | +android { |
| 40 | + compileSdkVersion 28 |
| 41 | + |
| 42 | + dependencies { |
| 43 | + embedding "androidx.annotation:annotation:1.1.0" |
| 44 | + embedding "androidx.fragment:fragment:1.1.0" |
| 45 | + |
| 46 | + def lifecycle_version = "2.2.0" |
| 47 | + embedding "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" |
| 48 | + embedding "androidx.lifecycle:lifecycle-livedata:$lifecycle_version" |
| 49 | + embedding "androidx.lifecycle:lifecycle-runtime:$lifecycle_version" |
| 50 | + embedding "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" |
| 51 | + embedding "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" |
| 52 | + embedding "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" |
| 53 | + embedding "androidx.lifecycle:lifecycle-service:$lifecycle_version" |
| 54 | + embedding "androidx.lifecycle:lifecycle-process:$lifecycle_version" |
| 55 | + embedding "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" |
| 56 | + |
| 57 | + // Testing |
| 58 | + embeddingTesting "androidx.arch.core:core-testing:2.1.0" |
| 59 | + embeddingTesting "org.robolectric:android-all:8.1.0-robolectric-4611349" |
| 60 | + // This is required by the robolectric test. |
| 61 | + embeddingTesting_duplicated "org.robolectric:android-all:4.1.2_r1-robolectric-r1" |
| 62 | + embeddingTesting "org.robolectric:robolectric:3.8" |
| 63 | + embeddingTesting "org.robolectric:junit:3.8" |
| 64 | + embeddingTesting "org.robolectric:shadows-framework:3.8" |
| 65 | + embeddingTesting "org.robolectric:resources:3.8" |
| 66 | + embeddingTesting "org.mockito:mockito-all:1.10.19" |
| 67 | + embeddingTesting "junit:junit:4.13-beta-3" |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +task updateDependencies() { |
| 72 | + delete destinationDir |
| 73 | + // Copy the dependencies from the compileOnly configuration into |
| 74 | + // the destination directory. |
| 75 | + copy { |
| 76 | + from configurations.embedding |
| 77 | + from configurations.embeddingTesting |
| 78 | + from configurations.embeddingTesting_duplicated |
| 79 | + into destinationDir |
| 80 | + } |
| 81 | + doLast { |
| 82 | + // Extract classes.jar from aar and rename it as the dependency name .jar |
| 83 | + // since javac doesn't support AARs. |
| 84 | + fileTree(destinationDir) |
| 85 | + .filter { it.name.endsWith(".aar") } |
| 86 | + .collect { aarDependency -> |
| 87 | + def dependencyName = "${aarDependency.name.take(aarDependency.name.lastIndexOf('.'))}"; |
| 88 | + copy { |
| 89 | + into destinationDir |
| 90 | + from(zipTree(aarDependency)) { |
| 91 | + include "classes.jar" |
| 92 | + } |
| 93 | + rename "classes.jar", "${dependencyName}.jar" |
| 94 | + } |
| 95 | + delete aarDependency |
| 96 | + } |
| 97 | + } |
| 98 | + doLast { |
| 99 | + fileTree(destinationDir) |
| 100 | + .collect { dependency -> |
| 101 | + println "\"//third_party/robolectric/lib/${dependency.name}\"," |
| 102 | + } |
| 103 | + } |
| 104 | +} |
0 commit comments