let the plugin's output generated in flutter/.android/plugins_build_output/${androidPlugin.name} (#94645)
This commit is contained in:
parent
4e8a28d29d
commit
148a0b264b
@ -9,10 +9,12 @@ import groovy.json.JsonSlurper
|
|||||||
|
|
||||||
def moduleProjectRoot = project(':flutter').projectDir.parentFile.parentFile
|
def moduleProjectRoot = project(':flutter').projectDir.parentFile.parentFile
|
||||||
|
|
||||||
|
def object = null;
|
||||||
|
String flutterModulePath = project(':flutter').projectDir.parentFile.getAbsolutePath()
|
||||||
// Note: if this logic is changed, also change the logic in app_plugin_loader.gradle.
|
// Note: if this logic is changed, also change the logic in app_plugin_loader.gradle.
|
||||||
def pluginsFile = new File(moduleProjectRoot, '.flutter-plugins-dependencies')
|
def pluginsFile = new File(moduleProjectRoot, '.flutter-plugins-dependencies')
|
||||||
if (pluginsFile.exists()) {
|
if (pluginsFile.exists()) {
|
||||||
def object = new JsonSlurper().parseText(pluginsFile.text)
|
object = new JsonSlurper().parseText(pluginsFile.text)
|
||||||
assert object instanceof Map
|
assert object instanceof Map
|
||||||
assert object.plugins instanceof Map
|
assert object.plugins instanceof Map
|
||||||
assert object.plugins.android instanceof List
|
assert object.plugins.android instanceof List
|
||||||
@ -35,6 +37,17 @@ if (pluginsFile.exists()) {
|
|||||||
|
|
||||||
gradle.getGradle().projectsLoaded { g ->
|
gradle.getGradle().projectsLoaded { g ->
|
||||||
g.rootProject.beforeEvaluate { p ->
|
g.rootProject.beforeEvaluate { p ->
|
||||||
|
p.subprojects { subproject ->
|
||||||
|
if (object != null && object.plugins != null && object.plugins.android != null
|
||||||
|
&& object.plugins.android.name.contains(subproject.name)) {
|
||||||
|
File androidPluginBuildOutputDir = new File(flutterModulePath + File.separator
|
||||||
|
+ "plugins_build_output" + File.separator + subproject.name);
|
||||||
|
if (!androidPluginBuildOutputDir.exists()) {
|
||||||
|
androidPluginBuildOutputDir.mkdirs()
|
||||||
|
}
|
||||||
|
subproject.buildDir = androidPluginBuildOutputDir
|
||||||
|
}
|
||||||
|
}
|
||||||
def _mainModuleName = binding.variables['mainModuleName']
|
def _mainModuleName = binding.variables['mainModuleName']
|
||||||
if (_mainModuleName != null && !_mainModuleName.empty) {
|
if (_mainModuleName != null && !_mainModuleName.empty) {
|
||||||
p.ext.mainModuleName = _mainModuleName
|
p.ext.mainModuleName = _mainModuleName
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
// 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:math';
|
||||||
|
|
||||||
|
import 'package:file_testing/file_testing.dart';
|
||||||
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
|
import 'package:flutter_tools/src/cache.dart';
|
||||||
|
|
||||||
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
|
||||||
|
late Directory tempDir;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
Cache.flutterRoot = getFlutterRoot();
|
||||||
|
tempDir = createResolvedTempDirectorySync('android_plugin_new_output_dir_test.');
|
||||||
|
});
|
||||||
|
|
||||||
|
tearDown(() async {
|
||||||
|
tryToDelete(tempDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("error logged when plugin's build output dir was not private.", () async {
|
||||||
|
final String flutterBin = fileSystem.path.join(
|
||||||
|
getFlutterRoot(),
|
||||||
|
'bin',
|
||||||
|
'flutter',
|
||||||
|
);
|
||||||
|
// create flutter module project
|
||||||
|
ProcessResult result = processManager.runSync(<String>[
|
||||||
|
flutterBin,
|
||||||
|
...getLocalEngineArguments(),
|
||||||
|
'create',
|
||||||
|
'--template=module',
|
||||||
|
'flutter_project'
|
||||||
|
], workingDirectory: tempDir.path);
|
||||||
|
|
||||||
|
final String projectPath = fileSystem.path.join(tempDir.path, 'flutter_project');
|
||||||
|
|
||||||
|
final File modulePubspec = fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml'));
|
||||||
|
String pubspecContent = modulePubspec.readAsStringSync();
|
||||||
|
pubspecContent = pubspecContent.replaceFirst(
|
||||||
|
'dependencies:',
|
||||||
|
'''
|
||||||
|
dependencies:
|
||||||
|
image_picker: 0.8.5+3''',
|
||||||
|
);
|
||||||
|
modulePubspec.writeAsStringSync(pubspecContent);
|
||||||
|
|
||||||
|
// Run flutter build apk to build module example project
|
||||||
|
result = processManager.runSync(<String>[
|
||||||
|
flutterBin,
|
||||||
|
...getLocalEngineArguments(),
|
||||||
|
'build',
|
||||||
|
'aar',
|
||||||
|
'--target-platform=android-arm',
|
||||||
|
], workingDirectory: projectPath);
|
||||||
|
|
||||||
|
log(result.exitCode);
|
||||||
|
|
||||||
|
// Check outputDir existed
|
||||||
|
final Directory outputDir = fileSystem.directory(fileSystem.path.join(
|
||||||
|
projectPath, '.android', 'plugins_build_output', 'image_picker_android'
|
||||||
|
));
|
||||||
|
expect(outputDir, exists);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user