Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reland #39157 #39798

Merged
merged 15 commits into from Sep 17, 2019
Merged
2 changes: 0 additions & 2 deletions dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
Expand Up @@ -52,7 +52,6 @@ Future<void> main() async {
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
'lib/armeabi-v7a/libflutter.so',
// Debug mode intentionally includes `x86` and `x86_64`.
'lib/x86/libflutter.so',
'lib/x86_64/libflutter.so',
Expand All @@ -79,7 +78,6 @@ Future<void> main() async {
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
'lib/armeabi-v7a/libflutter.so',
// Debug mode intentionally includes `x86` and `x86_64`.
'lib/x86/libflutter.so',
'lib/x86_64/libflutter.so',
Expand Down
4 changes: 2 additions & 2 deletions examples/platform_view/android/app/build.gradle
Expand Up @@ -57,6 +57,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
319 changes: 143 additions & 176 deletions packages/flutter_tools/gradle/flutter.gradle

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions packages/flutter_tools/gradle/resolve_dependencies.gradle
@@ -0,0 +1,64 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
// 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

repositories {
google()
jcenter()
maven {
url "http://download.flutter.io"
}
}

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()
}
}
}
2 changes: 1 addition & 1 deletion packages/flutter_tools/lib/executable.dart
Expand Up @@ -84,7 +84,7 @@ Future<void> main(List<String> args) async {
LogsCommand(),
MakeHostAppEditableCommand(),
PackagesCommand(),
PrecacheCommand(),
PrecacheCommand(verboseHelp: verboseHelp),
RunCommand(verboseHelp: verboseHelp),
ScreenshotCommand(),
ShellCompletionCommand(),
Expand Down
17 changes: 9 additions & 8 deletions packages/flutter_tools/lib/src/android/gradle.dart
Expand Up @@ -127,7 +127,7 @@ Future<void> checkGradleDependencies() async {
await runCheckedAsync(
<String>[gradle, 'dependencies'],
workingDirectory: flutterProject.android.hostAppGradleRoot.path,
environment: _gradleEnv,
environment: gradleEnv,
);
androidSdk.reinitialize();
progress.stop();
Expand Down Expand Up @@ -215,12 +215,12 @@ Future<GradleProject> _readGradleProject({bool isLibrary = false}) async {
final RunResult propertiesRunResult = await runCheckedAsync(
<String>[gradle, isLibrary ? 'properties' : 'app:properties'],
workingDirectory: hostAppGradleRoot.path,
environment: _gradleEnv,
environment: gradleEnv,
);
final RunResult tasksRunResult = await runCheckedAsync(
<String>[gradle, isLibrary ? 'tasks': 'app:tasks', '--all', '--console=auto'],
workingDirectory: hostAppGradleRoot.path,
environment: _gradleEnv,
environment: gradleEnv,
);
project = GradleProject.fromAppProperties(propertiesRunResult.stdout, tasksRunResult.stdout);
} catch (exception) {
Expand Down Expand Up @@ -294,7 +294,7 @@ Future<String> _initializeGradle(FlutterProject project) async {
printTrace('Using gradle from $gradle.');
// Validates the Gradle executable by asking for its version.
// Makes Gradle Wrapper download and install Gradle distribution, if needed.
await runCheckedAsync(<String>[gradle, '-v'], environment: _gradleEnv);
await runCheckedAsync(<String>[gradle, '-v'], environment: gradleEnv);
status.stop();
return gradle;
}
Expand Down Expand Up @@ -576,7 +576,7 @@ Future<void> buildGradleAar({
command,
workingDirectory: project.android.hostAppGradleRoot.path,
allowReentrantFlutter: true,
environment: _gradleEnv,
environment: gradleEnv,
mapFunction: (String line) {
// Always print the full line in verbose mode.
if (logger.isVerbose) {
Expand Down Expand Up @@ -613,7 +613,7 @@ Future<void> _buildGradleProjectV1(FlutterProject project, String gradle) async
<String>[fs.file(gradle).absolute.path, 'build'],
workingDirectory: project.android.hostAppGradleRoot.path,
allowReentrantFlutter: true,
environment: _gradleEnv,
environment: gradleEnv,
);
status.stop();
flutterUsage.sendTiming('build', 'gradle-v1', Duration(milliseconds: sw.elapsedMilliseconds));
Expand Down Expand Up @@ -734,7 +734,7 @@ Future<void> _buildGradleProjectV2(
command,
workingDirectory: flutterProject.android.hostAppGradleRoot.path,
allowReentrantFlutter: true,
environment: _gradleEnv,
environment: gradleEnv,
// TODO(mklim): if AndroidX warnings are no longer required, this
// mapFunction and all its associated variabled can be replaced with just
// `filter: ndkMessagefilter`.
Expand Down Expand Up @@ -870,7 +870,8 @@ File findBundleFile(GradleProject project, BuildInfo buildInfo) {
return null;
}

Map<String, String> get _gradleEnv {
/// The environment variables needed to run Gradle.
Map<String, String> get gradleEnv {
zanderso marked this conversation as resolved.
Show resolved Hide resolved
final Map<String, String> env = Map<String, String>.from(platform.environment);
if (javaPath != null) {
// Use java bundled with Android Studio.
Expand Down