Unverified Commit fdbd1b14 authored by zsunkun's avatar zsunkun Committed by GitHub

fix pom file not found when run app with local engine (#51468)

parent 8df3e057
...@@ -297,6 +297,13 @@ Future<void> buildGradleApp({ ...@@ -297,6 +297,13 @@ Future<void> buildGradleApp({
command.add('-Plocal-engine-repo=${localEngineRepo.path}'); command.add('-Plocal-engine-repo=${localEngineRepo.path}');
command.add('-Plocal-engine-build-mode=${buildInfo.modeName}'); command.add('-Plocal-engine-build-mode=${buildInfo.modeName}');
command.add('-Plocal-engine-out=${localEngineArtifacts.engineOutPath}'); command.add('-Plocal-engine-out=${localEngineArtifacts.engineOutPath}');
command.add('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath(
localEngineArtifacts.engineOutPath)}');
} else if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo
.targetArchs
.map(getPlatformNameForAndroidArch).join(',');
command.add('-Ptarget-platform=$targetPlatforms');
} }
if (target != null) { if (target != null) {
command.add('-Ptarget=$target'); command.add('-Ptarget=$target');
...@@ -322,12 +329,6 @@ Future<void> buildGradleApp({ ...@@ -322,12 +329,6 @@ Future<void> buildGradleApp({
if (androidBuildInfo.shrink) { if (androidBuildInfo.shrink) {
command.add('-Pshrink=true'); command.add('-Pshrink=true');
} }
if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo
.targetArchs
.map(getPlatformNameForAndroidArch).join(',');
command.add('-Ptarget-platform=$targetPlatforms');
}
if (shouldBuildPluginAsAar) { if (shouldBuildPluginAsAar) {
// Pass a system flag instead of a project flag, so this flag can be // Pass a system flag instead of a project flag, so this flag can be
// read from include_flutter.groovy. // read from include_flutter.groovy.
...@@ -537,11 +538,6 @@ Future<void> buildGradleAar({ ...@@ -537,11 +538,6 @@ Future<void> buildGradleAar({
command.add('-Ptarget=$target'); command.add('-Ptarget=$target');
} }
if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo.targetArchs
.map(getPlatformNameForAndroidArch).join(',');
command.add('-Ptarget-platform=$targetPlatforms');
}
if (globals.artifacts is LocalEngineArtifacts) { if (globals.artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts; final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final Directory localEngineRepo = _getLocalEngineRepo( final Directory localEngineRepo = _getLocalEngineRepo(
...@@ -571,6 +567,12 @@ Future<void> buildGradleAar({ ...@@ -571,6 +567,12 @@ Future<void> buildGradleAar({
'in ${outputDirectory.path}' 'in ${outputDirectory.path}'
); );
} }
command.add('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath(
localEngineArtifacts.engineOutPath)}');
} else if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo.targetArchs
.map(getPlatformNameForAndroidArch).join(',');
command.add('-Ptarget-platform=$targetPlatforms');
} }
command.add(aarTask); command.add(aarTask);
...@@ -928,7 +930,7 @@ Directory _getLocalEngineRepo({ ...@@ -928,7 +930,7 @@ Directory _getLocalEngineRepo({
assert(engineOutPath != null); assert(engineOutPath != null);
assert(androidBuildInfo != null); assert(androidBuildInfo != null);
final String abi = getEnumName(androidBuildInfo.targetArchs.first); final String abi = _getAbiByLocalEnginePath(engineOutPath);
final Directory localEngineRepo = globals.fs.systemTempDirectory final Directory localEngineRepo = globals.fs.systemTempDirectory
.createTempSync('flutter_tool_local_engine_repo.'); .createTempSync('flutter_tool_local_engine_repo.');
...@@ -979,3 +981,27 @@ Directory _getLocalEngineRepo({ ...@@ -979,3 +981,27 @@ Directory _getLocalEngineRepo({
} }
return localEngineRepo; return localEngineRepo;
} }
String _getAbiByLocalEnginePath(String engineOutPath) {
String result = 'armeabi_v7a';
if (engineOutPath.contains('x86')) {
result = 'x86';
} else if (engineOutPath.contains('x64')) {
result = 'x86_64';
} else if (engineOutPath.contains('arm64')) {
result = 'arm64_v8a';
}
return result;
}
String _getTargetPlatformByLocalEnginePath(String engineOutPath) {
String result = 'android-arm';
if (engineOutPath.contains('x86')) {
result = 'android-x86';
} else if (engineOutPath.contains('x64')) {
result = 'android-x64';
} else if (engineOutPath.contains('arm64')) {
result = 'android-arm64';
}
return result;
}
...@@ -214,10 +214,10 @@ void main() { ...@@ -214,10 +214,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -242,10 +242,10 @@ void main() { ...@@ -242,10 +242,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Psplit-debug-info=${tempDir.path}', '-Psplit-debug-info=${tempDir.path}',
'assembleRelease', 'assembleRelease',
], ],
...@@ -274,9 +274,9 @@ void main() { ...@@ -274,9 +274,9 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -297,10 +297,10 @@ void main() { ...@@ -297,10 +297,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -352,10 +352,10 @@ void main() { ...@@ -352,10 +352,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -403,10 +403,10 @@ void main() { ...@@ -403,10 +403,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true', '-Ptrack-widget-creation=true',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
......
...@@ -200,10 +200,10 @@ void main() { ...@@ -200,10 +200,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false', '-Ptrack-widget-creation=false',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'bundleRelease', 'bundleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -233,9 +233,9 @@ void main() { ...@@ -233,9 +233,9 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false', '-Ptrack-widget-creation=false',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'bundleRelease', 'bundleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -256,10 +256,10 @@ void main() { ...@@ -256,10 +256,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false', '-Ptrack-widget-creation=false',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'bundleRelease', 'bundleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -311,10 +311,10 @@ void main() { ...@@ -311,10 +311,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false', '-Ptrack-widget-creation=false',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
...@@ -362,10 +362,10 @@ void main() { ...@@ -362,10 +362,10 @@ void main() {
<String>[ <String>[
gradlew, gradlew,
'-q', '-q',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false', '-Ptrack-widget-creation=false',
'-Pshrink=true', '-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease', 'assembleRelease',
], ],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment