From 9223a44b8a9e88f3207e023b4ad68d12b1f63f74 Mon Sep 17 00:00:00 2001 From: Josh Burton Date: Sat, 8 Jun 2019 11:09:21 +1200 Subject: [PATCH] =?UTF-8?q?Adds=20the=20androidX=20flag=20to=20a=20modules?= =?UTF-8?q?=20pubspec.yaml=20template=20so=20it=20is=20se=E2=80=A6=20(#340?= =?UTF-8?q?66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a small follow up to the previous AndroidX PR: https://github.com/flutter/flutter/pull/31028 This fixes an issue mentioned [here](https://github.com/flutter/flutter/issues/28805) where the androidX flag for a module is not set when creating a new project: `flutter create --androidx -t module my_flutter` --- .../templates/module/common/pubspec.yaml.tmpl | 1 + .../test/commands/create_test.dart | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl index 7baedbe46f..08f05c5738 100644 --- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl @@ -85,5 +85,6 @@ flutter: # They also do not have any bearing on your native host application's # identifiers, which may be completely independent or the same as these. module: + androidX: {{androidX}} androidPackage: {{androidIdentifier}} iosBundleIdentifier: {{iosIdentifier}} diff --git a/packages/flutter_tools/test/commands/create_test.dart b/packages/flutter_tools/test/commands/create_test.dart index 3b5eee55f6..3707b62a92 100644 --- a/packages/flutter_tools/test/commands/create_test.dart +++ b/packages/flutter_tools/test/commands/create_test.dart @@ -421,6 +421,40 @@ void main() { expect(actualContents.contains('useAndroidX'), false); }, timeout: allowForCreateFlutterProject); + testUsingContext('androidx app module', () async { + Cache.flutterRoot = '../..'; + when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); + when(mockFlutterVersion.channel).thenReturn(frameworkChannel); + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--template=module', '--no-pub', '--androidx', projectDir.path]); + + final FlutterProject project = FlutterProject.fromDirectory(projectDir); + expect( + project.usesAndroidX, + true, + ); + }, timeout: allowForCreateFlutterProject); + + testUsingContext('non androidx app module', () async { + Cache.flutterRoot = '../..'; + when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); + when(mockFlutterVersion.channel).thenReturn(frameworkChannel); + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--template=module', '--no-pub', '--no-androidx', projectDir.path]); + + final FlutterProject project = FlutterProject.fromDirectory(projectDir); + expect( + project.usesAndroidX, + false, + ); + }, timeout: allowForCreateFlutterProject); + testUsingContext('androidx plugin project', () async { Cache.flutterRoot = '../..'; when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);