Unverified Commit 762c92ea authored by Gary Qian's avatar Gary Qian Committed by GitHub

Remove doc for --ignore-deprecation and check for pubspec before v1 embedding check (#108523)

parent 7cfbdadc
...@@ -377,7 +377,7 @@ class FlutterProject { ...@@ -377,7 +377,7 @@ class FlutterProject {
} }
void checkForDeprecation({DeprecationBehavior deprecationBehavior = DeprecationBehavior.none}) { void checkForDeprecation({DeprecationBehavior deprecationBehavior = DeprecationBehavior.none}) {
if (android.existsSync()) { if (android.existsSync() && pubspecFile.existsSync()) {
android.checkForDeprecation(deprecationBehavior: deprecationBehavior); android.checkForDeprecation(deprecationBehavior: deprecationBehavior);
} }
} }
...@@ -599,14 +599,11 @@ class AndroidProject extends FlutterProjectPlatform { ...@@ -599,14 +599,11 @@ class AndroidProject extends FlutterProjectPlatform {
Warning Warning
────────────────────────────────────────────────────────────────────────────── ──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the embedding. It is being deprecated in favor of Android embedding v2. To migrate
steps at your project, follow the steps at:
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was: The detected reason was:
......
...@@ -191,7 +191,7 @@ void main() { ...@@ -191,7 +191,7 @@ void main() {
_testInMemory('checkForDeprecation fails on invalid android app manifest file', () async { _testInMemory('checkForDeprecation fails on invalid android app manifest file', () async {
// This is not a valid Xml document // This is not a valid Xml document
const String invalidManifest = '<manifest></application>'; const String invalidManifest = '<manifest></application>';
final FlutterProject project = await someProject(androidManifestOverride: invalidManifest); final FlutterProject project = await someProject(androidManifestOverride: invalidManifest, includePubspec: true);
expect( expect(
() => project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore), () => project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore),
...@@ -199,7 +199,7 @@ void main() { ...@@ -199,7 +199,7 @@ void main() {
); );
}); });
_testInMemory('Android project not on v2 embedding shows a warning', () async { _testInMemory('Android project not on v2 embedding shows a warning', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject(includePubspec: true);
// The default someProject with an empty <manifest> already indicates // The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data // v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />. // android:name="flutterEmbedding" android:value="2" />.
...@@ -208,7 +208,7 @@ void main() { ...@@ -208,7 +208,7 @@ void main() {
expect(testLogger.statusText, contains('https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects')); expect(testLogger.statusText, contains('https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects'));
}); });
_testInMemory('Android project not on v2 embedding exits', () async { _testInMemory('Android project not on v2 embedding exits', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject(includePubspec: true);
// The default someProject with an empty <manifest> already indicates // The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data // v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />. // android:name="flutterEmbedding" android:value="2" />.
...@@ -221,7 +221,7 @@ void main() { ...@@ -221,7 +221,7 @@ void main() {
expect(testLogger.statusText, contains('No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in ')); expect(testLogger.statusText, contains('No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in '));
}); });
_testInMemory('Project not on v2 embedding does not warn if deprecation status is irrelevant', () async { _testInMemory('Project not on v2 embedding does not warn if deprecation status is irrelevant', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject(includePubspec: true);
// The default someProject with an empty <manifest> already indicates // The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data // v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />. // android:name="flutterEmbedding" android:value="2" />.
...@@ -230,7 +230,7 @@ void main() { ...@@ -230,7 +230,7 @@ void main() {
expect(testLogger.statusText, isEmpty); expect(testLogger.statusText, isEmpty);
}); });
_testInMemory('Android project not on v2 embedding ignore continues', () async { _testInMemory('Android project not on v2 embedding ignore continues', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject(includePubspec: true);
// The default someProject with an empty <manifest> already indicates // The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data // v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />. // android:name="flutterEmbedding" android:value="2" />.
...@@ -238,6 +238,15 @@ void main() { ...@@ -238,6 +238,15 @@ void main() {
project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore); project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore);
expect(testLogger.statusText, contains('https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects')); expect(testLogger.statusText, contains('https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects'));
}); });
_testInMemory('Android project no pubspec continues', () async {
final FlutterProject project = await someProject();
// The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />.
project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore);
expect(testLogger.statusText, isNot(contains('https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects')));
});
_testInMemory('Android plugin project does not throw v1 embedding deprecation warning', () async { _testInMemory('Android plugin project does not throw v1 embedding deprecation warning', () async {
final FlutterProject project = await aPluginProject(); final FlutterProject project = await aPluginProject();
...@@ -781,12 +790,18 @@ apply plugin: 'kotlin-android' ...@@ -781,12 +790,18 @@ apply plugin: 'kotlin-android'
Future<FlutterProject> someProject({ Future<FlutterProject> someProject({
String androidManifestOverride, String androidManifestOverride,
bool includePubspec = false,
}) async { }) async {
final Directory directory = globals.fs.directory('some_project'); final Directory directory = globals.fs.directory('some_project');
directory.childDirectory('.dart_tool') directory.childDirectory('.dart_tool')
.childFile('package_config.json') .childFile('package_config.json')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}'); ..writeAsStringSync('{"configVersion":2,"packages":[]}');
if (includePubspec) {
directory.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(validPubspec);
}
directory.childDirectory('ios').createSync(recursive: true); directory.childDirectory('ios').createSync(recursive: true);
final Directory androidDirectory = directory final Directory androidDirectory = directory
.childDirectory('android') .childDirectory('android')
......
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