From bcef4edfc8870dcfed519412298290b27890b807 Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Mon, 10 Feb 2020 16:03:02 -0800 Subject: [PATCH] Make the template plugin example depend on the plugin as a real dependency (#50485) --- .../templates/app/pubspec.yaml.tmpl | 10 +++++----- .../commands.shard/permeable/create_test.dart | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl index 06ea6c9208..2f733e5d8e 100644 --- a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl @@ -25,6 +25,11 @@ dependencies: flutter: sdk: flutter +{{#withPluginHook}} + {{pluginProjectName}}: + path: ../ +{{/withPluginHook}} + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 @@ -38,11 +43,6 @@ dev_dependencies: test: 1.9.4 {{/withDriverTest}} -{{#withPluginHook}} - {{pluginProjectName}}: - path: ../ -{{/withPluginHook}} - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index e815b9b83e..ddd01d7d8b 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -23,6 +23,7 @@ import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -325,6 +326,25 @@ void main() { Pub: () => const Pub(), }); + testUsingContext('plugin example app depends on plugin', () async { + await _createProject( + projectDir, + ['--template=plugin', '-i', 'objc', '-a', 'java'], + [ + 'example/pubspec.yaml', + ], + ); + final String rawPubspec = await projectDir.childDirectory('example').childFile('pubspec.yaml').readAsString(); + final Pubspec pubspec = Pubspec.parse(rawPubspec); + final String pluginName = projectDir.basename; + expect(pubspec.dependencies, contains(pluginName)); + expect(pubspec.dependencies[pluginName] is PathDependency, isTrue); + final PathDependency pathDependency = pubspec.dependencies[pluginName] as PathDependency; + expect(pathDependency.path, '../'); + }, overrides: { + Pub: () => const Pub(), + }); + testUsingContext('kotlin/swift plugin project', () async { return _createProject( projectDir,