mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
let the embedding maven engine dependency reference the storage proxy (#56164)
This commit is contained in:
parent
8fbfe1cfbf
commit
f6b47a5f35
@ -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);
|
||||
});
|
||||
}
|
@ -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")
|
||||
|
@ -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";
|
||||
@ -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 {
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'
|
||||
@ -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'
|
||||
@ -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'
|
||||
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user