2019-11-27 23:04:02 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2019-07-23 16:27:42 +00:00
|
|
|
// 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';
|
|
|
|
|
2019-07-30 20:38:06 +00:00
|
|
|
import 'package:flutter_devicelab/framework/apk_utils.dart';
|
2019-07-23 16:27:42 +00:00
|
|
|
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';
|
2019-10-21 23:42:46 +00:00
|
|
|
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
2019-07-23 16:27:42 +00:00
|
|
|
|
|
|
|
/// Tests that AARs can be built on module projects.
|
|
|
|
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 module project');
|
|
|
|
|
|
|
|
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
|
|
|
|
final Directory projectDir = Directory(path.join(tempDir.path, 'hello'));
|
|
|
|
try {
|
|
|
|
await inDirectory(tempDir, () async {
|
|
|
|
await flutter(
|
|
|
|
'create',
|
|
|
|
options: <String>['--org', 'io.flutter.devicelab', '--template', 'module', 'hello'],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
section('Add plugins');
|
|
|
|
|
|
|
|
final File pubspec = File(path.join(projectDir.path, 'pubspec.yaml'));
|
|
|
|
String content = pubspec.readAsStringSync();
|
|
|
|
content = content.replaceFirst(
|
|
|
|
'\ndependencies:\n',
|
2019-11-02 16:46:25 +00:00
|
|
|
'\ndependencies:\n device_info: 0.4.1\n package_info: 0.4.0+9\n',
|
2019-07-23 16:27:42 +00:00
|
|
|
);
|
|
|
|
pubspec.writeAsStringSync(content, flush: true);
|
|
|
|
await inDirectory(projectDir, () async {
|
|
|
|
await flutter(
|
|
|
|
'packages',
|
|
|
|
options: <String>['get'],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
section('Build release AAR');
|
|
|
|
|
|
|
|
await inDirectory(projectDir, () async {
|
|
|
|
await flutter(
|
|
|
|
'build',
|
2020-01-16 17:59:33 +00:00
|
|
|
options: <String>['aar', '--release', '--verbose'],
|
2019-07-23 16:27:42 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
final String repoPath = path.join(
|
|
|
|
projectDir.path,
|
|
|
|
'build',
|
|
|
|
'host',
|
|
|
|
'outputs',
|
|
|
|
'repo',
|
|
|
|
);
|
|
|
|
|
2019-11-02 16:46:25 +00:00
|
|
|
section('Check release Maven artifacts');
|
|
|
|
|
2019-07-23 16:27:42 +00:00
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
|
|
|
'flutter_release',
|
|
|
|
'1.0',
|
|
|
|
'flutter_release-1.0.aar',
|
|
|
|
));
|
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
final String releasePom = path.join(
|
2019-07-23 16:27:42 +00:00
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
|
|
|
'flutter_release',
|
|
|
|
'1.0',
|
|
|
|
'flutter_release-1.0.pom',
|
2019-10-09 23:29:20 +00:00
|
|
|
);
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
checkFileExists(releasePom);
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-11-02 16:46:25 +00:00
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'deviceinfo',
|
|
|
|
'device_info_release',
|
|
|
|
'1.0',
|
|
|
|
'device_info_release-1.0.aar',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'deviceinfo',
|
|
|
|
'device_info_release',
|
|
|
|
'1.0',
|
|
|
|
'device_info_release-1.0.pom',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'packageinfo',
|
|
|
|
'package_info_release',
|
|
|
|
'1.0',
|
|
|
|
'package_info_release-1.0.aar',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'packageinfo',
|
|
|
|
'package_info_release',
|
|
|
|
'1.0',
|
|
|
|
'package_info_release-1.0.pom',
|
|
|
|
));
|
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
section('Check AOT blobs in release POM');
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
checkFileContains(<String>[
|
|
|
|
'flutter_embedding_release',
|
|
|
|
'armeabi_v7a_release',
|
|
|
|
'arm64_v8a_release',
|
2019-11-02 16:46:25 +00:00
|
|
|
'x86_64_release',
|
|
|
|
'package_info_release',
|
|
|
|
'device_info_release',
|
2019-10-09 23:29:20 +00:00
|
|
|
], releasePom);
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-07-30 20:38:06 +00:00
|
|
|
section('Check assets in release AAR');
|
|
|
|
|
2019-11-07 21:12:56 +00:00
|
|
|
checkCollectionContains<String>(
|
2019-10-09 23:29:20 +00:00
|
|
|
<String>[
|
|
|
|
...flutterAssets,
|
|
|
|
// AOT snapshots
|
|
|
|
'jni/arm64-v8a/libapp.so',
|
|
|
|
'jni/armeabi-v7a/libapp.so',
|
2019-11-02 16:46:25 +00:00
|
|
|
'jni/x86_64/libapp.so',
|
2019-10-09 23:29:20 +00:00
|
|
|
],
|
|
|
|
await getFilesInAar(
|
|
|
|
path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
|
|
|
'flutter_release',
|
|
|
|
'1.0',
|
|
|
|
'flutter_release-1.0.aar',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2019-07-30 20:38:06 +00:00
|
|
|
|
2019-07-23 16:27:42 +00:00
|
|
|
section('Build debug AAR');
|
|
|
|
|
|
|
|
await inDirectory(projectDir, () async {
|
|
|
|
await flutter(
|
|
|
|
'build',
|
|
|
|
options: <String>['aar', '--verbose', '--debug'],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-11-02 16:46:25 +00:00
|
|
|
section('Check debug Maven artifacts');
|
|
|
|
|
2019-07-23 16:27:42 +00:00
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
2019-07-30 20:38:06 +00:00
|
|
|
'flutter_debug',
|
2019-07-23 16:27:42 +00:00
|
|
|
'1.0',
|
2019-07-30 20:38:06 +00:00
|
|
|
'flutter_debug-1.0.aar',
|
2019-07-23 16:27:42 +00:00
|
|
|
));
|
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
final String debugPom = path.join(
|
2019-07-23 16:27:42 +00:00
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
|
|
|
'flutter_debug',
|
|
|
|
'1.0',
|
|
|
|
'flutter_debug-1.0.pom',
|
2019-10-09 23:29:20 +00:00
|
|
|
);
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
checkFileExists(debugPom);
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-11-02 16:46:25 +00:00
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'deviceinfo',
|
|
|
|
'device_info_debug',
|
|
|
|
'1.0',
|
|
|
|
'device_info_debug-1.0.aar',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'deviceinfo',
|
|
|
|
'device_info_debug',
|
|
|
|
'1.0',
|
|
|
|
'device_info_debug-1.0.pom',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'packageinfo',
|
|
|
|
'package_info_debug',
|
|
|
|
'1.0',
|
|
|
|
'package_info_debug-1.0.aar',
|
|
|
|
));
|
|
|
|
|
|
|
|
checkFileExists(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'plugins',
|
|
|
|
'packageinfo',
|
|
|
|
'package_info_debug',
|
|
|
|
'1.0',
|
|
|
|
'package_info_debug-1.0.pom',
|
|
|
|
));
|
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
section('Check AOT blobs in debug POM');
|
2019-07-23 16:27:42 +00:00
|
|
|
|
2019-10-09 23:29:20 +00:00
|
|
|
checkFileContains(<String>[
|
|
|
|
'flutter_embedding_debug',
|
|
|
|
'x86_debug',
|
|
|
|
'x86_64_debug',
|
|
|
|
'armeabi_v7a_debug',
|
|
|
|
'arm64_v8a_debug',
|
2019-11-02 16:46:25 +00:00
|
|
|
'package_info_debug',
|
|
|
|
'device_info_debug',
|
2019-10-09 23:29:20 +00:00
|
|
|
], debugPom);
|
2019-07-30 20:38:06 +00:00
|
|
|
|
|
|
|
section('Check assets in debug AAR');
|
|
|
|
|
|
|
|
final Iterable<String> debugAar = await getFilesInAar(path.join(
|
|
|
|
repoPath,
|
|
|
|
'io',
|
|
|
|
'flutter',
|
|
|
|
'devicelab',
|
|
|
|
'hello',
|
|
|
|
'flutter_debug',
|
|
|
|
'1.0',
|
|
|
|
'flutter_debug-1.0.aar',
|
|
|
|
));
|
|
|
|
|
2019-11-07 21:12:56 +00:00
|
|
|
checkCollectionContains<String>(<String>[
|
2019-10-09 23:29:20 +00:00
|
|
|
...flutterAssets,
|
2019-10-21 23:42:46 +00:00
|
|
|
...debugAssets,
|
2019-07-30 20:38:06 +00:00
|
|
|
], debugAar);
|
|
|
|
|
2019-07-23 16:27:42 +00:00
|
|
|
return TaskResult.success(null);
|
2019-07-30 20:38:06 +00:00
|
|
|
} on TaskResult catch (taskResult) {
|
|
|
|
return taskResult;
|
2019-07-23 16:27:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
return TaskResult.failure(e.toString());
|
|
|
|
} finally {
|
|
|
|
rmTree(tempDir);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|