Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions dev/devicelab/bin/tasks/android_engine_dependency_proxy_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path;

final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';

/// Tests that we respect storage proxy URLs in gradle dependencies.
Future<void> main() async {
await task(() async {
section('Find Java');

final String javaHome = await findJavaHome();
if (javaHome == null)
return TaskResult.failure('Could not find Java');
print('\nUsing JAVA_HOME=$javaHome');

section('Create project');
await runProjectTest((FlutterProject flutterProject) async {
await inDirectory(path.join(flutterProject.rootPath, 'android'), () async {
section('Insert gradle testing script');
final File build = File(path.join(
flutterProject.rootPath, 'android', 'app', 'build.gradle'));
build.writeAsStringSync(
'''
task printEngineMavenUrl() {
doLast {
println project.repositories.find { it.name == 'maven' }.url
}
}
''',
mode: FileMode.append,
flush: true,
);

section('Checking default maven URL');
String mavenUrl = await eval(
gradlewExecutable,
<String>['printEngineMavenUrl', '-q'],
);

if (mavenUrl != 'https://storage.googleapis.com/download.flutter.io') {
throw TaskResult.failure('Expected Android engine maven dependency URL to '
'resolve to https://storage.googleapis.com/download.flutter.io. Got '
'$mavenUrl instead');
}

section('Checking overriden maven URL');
mavenUrl = await eval(
gradlewExecutable,
<String>['printEngineMavenUrl', '-q'],
environment: <String, String>{
'FLUTTER_STORAGE_BASE_URL': 'my.special.proxy',
}
);

if (mavenUrl != 'https://my.special.proxy/download.flutter.io') {
throw TaskResult.failure('Expected overriden Android engine maven '
'dependency URL to resolve to proxy location '
'https://my.special.proxy/download.flutter.io. Got '
'$mavenUrl instead');
}
});
});
return TaskResult.success(null);
});
}
3 changes: 2 additions & 1 deletion packages/flutter_tools/gradle/aar_init_script.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ void configureProject(Project project, String outputDir) {
"See: https://github.com/flutter/flutter/issues/40866")
}

String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "storage.googleapis.com"
// This is a Flutter plugin project. Plugin projects don't apply the Flutter Gradle plugin,
// as a result, add the dependency on the embedding.
project.repositories {
maven {
url "https://storage.googleapis.com/download.flutter.io"
url "https://$storageUrl/download.flutter.io"
}
}
String engineVersion = Paths.get(getFlutterRoot(project), "bin", "internal", "engine.version")
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_tools/gradle/flutter.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
apply plugin: FlutterPlugin

class FlutterPlugin implements Plugin<Project> {
private static final String MAVEN_REPO = "https://storage.googleapis.com/download.flutter.io";
private static final String DEFAULT_MAVEN_HOST = "storage.googleapis.com";

// The platforms that can be passed to the `--Ptarget-platform` flag.
private static final String PLATFORM_ARM32 = "android-arm";
Expand Down Expand Up @@ -200,10 +200,10 @@ class FlutterPlugin implements Plugin<Project> {
if (!supportsBuildMode(flutterBuildMode)) {
return
}
String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOST
String repository = useLocalEngine()
? project.property('local-engine-repo')
: MAVEN_REPO

: "https://$hostedRepository/download.flutter.io"
project.rootProject.allprojects {
repositories {
maven {
Expand Down
4 changes: 3 additions & 1 deletion packages/flutter_tools/gradle/resolve_dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

import java.nio.file.Paths

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

repositories {
google()
jcenter()
maven {
url "https://storage.googleapis.com/download.flutter.io"
url "https://$storageUrl/download.flutter.io"
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/flutter_tools/lib/src/android/gradle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,13 @@ void printHowToConsumeAar({
1. Open ${fileSystem.path.join('<host>', 'app', 'build.gradle')}
2. Ensure you have the repositories configured, otherwise add them:

String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "storage.googleapis.com"
repositories {
maven {
url '${repoDirectory.path}'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
url 'https://\$storageUrl/download.flutter.io'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2343,12 +2343,13 @@ plugin1=${plugin1.path}
' 1. Open <host>/app/build.gradle\n'
' 2. Ensure you have the repositories configured, otherwise add them:\n'
'\n'
' String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "storage.googleapis.com"\n'
' repositories {\n'
' maven {\n'
" url 'build/'\n"
' }\n'
' maven {\n'
" url 'https://storage.googleapis.com/download.flutter.io'\n"
" url 'https://\$storageUrl/download.flutter.io'\n"
' }\n'
' }\n'
'\n'
Expand Down Expand Up @@ -2393,12 +2394,13 @@ plugin1=${plugin1.path}
' 1. Open <host>/app/build.gradle\n'
' 2. Ensure you have the repositories configured, otherwise add them:\n'
'\n'
' String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "storage.googleapis.com"\n'
' repositories {\n'
' maven {\n'
" url 'build/'\n"
' }\n'
' maven {\n'
" url 'https://storage.googleapis.com/download.flutter.io'\n"
" url 'https://\$storageUrl/download.flutter.io'\n"
' }\n'
' }\n'
'\n'
Expand Down Expand Up @@ -2430,12 +2432,13 @@ plugin1=${plugin1.path}
' 1. Open <host>/app/build.gradle\n'
' 2. Ensure you have the repositories configured, otherwise add them:\n'
'\n'
' String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "storage.googleapis.com"\n'
' repositories {\n'
' maven {\n'
" url 'build/'\n"
' }\n'
' maven {\n'
" url 'https://storage.googleapis.com/download.flutter.io'\n"
" url 'https://\$storageUrl/download.flutter.io'\n"
' }\n'
' }\n'
'\n'
Expand Down Expand Up @@ -2468,12 +2471,13 @@ plugin1=${plugin1.path}
' 1. Open <host>/app/build.gradle\n'
' 2. Ensure you have the repositories configured, otherwise add them:\n'
'\n'
' String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "storage.googleapis.com"\n'
' repositories {\n'
' maven {\n'
" url 'build/'\n"
' }\n'
' maven {\n'
" url 'https://storage.googleapis.com/download.flutter.io'\n"
" url 'https://\$storageUrl/download.flutter.io'\n"
' }\n'
' }\n'
'\n'
Expand Down