From fffde14f64f93c42c549d2cdd595b9092b50e9ba Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Fri, 16 Sep 2016 11:06:17 -0700 Subject: [PATCH] Update tools to use `analyzer` from vended Dart SDK. (#5900) * Update tools to use `analyzer` from vended Dart SDK. * updates `flutter_tools` and `flutter_test` to use the SDK-vended `analyzer` package * tweaks dependency tracking logic to only record the SDK-vended `analyzer` so as not to crash on spurious conflicts (due to transitive dependencies) * Review fixes. --- dev/devicelab/pubspec.yaml | 13 +++++++++---- packages/flutter_test/pubspec.yaml | 10 +++++++--- .../flutter_tools/lib/src/commands/analyze.dart | 11 +++++++++-- packages/flutter_tools/pubspec.yaml | 8 ++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dev/devicelab/pubspec.yaml b/dev/devicelab/pubspec.yaml index bab13d3919..e8b5a6b742 100644 --- a/dev/devicelab/pubspec.yaml +++ b/dev/devicelab/pubspec.yaml @@ -13,10 +13,15 @@ dependencies: path: ^1.3.0 stack_trace: ^1.4.0 vm_service_client: '^0.2.0' - - # See packages/flutter_test/pubspec.yaml for why we're pinning this version - analyzer: 0.28.2-alpha.0 + + # Pulled in via dependency_override below. + analyzer: any dev_dependencies: - # See packages/flutter_test/pubspec.yaml for why we're pinning this version + # See packages/flutter_test/pubspec.yaml for why we're pinning this version. test: 0.12.15+4 + +# See packages/flutter_test/pubspec.yaml for why we're using an override. +dependency_overrides: + analyzer: + path: ../../bin/cache/dart-sdk/lib/analyzer diff --git a/packages/flutter_test/pubspec.yaml b/packages/flutter_test/pubspec.yaml index 8344b0e5c3..f3f423ea68 100644 --- a/packages/flutter_test/pubspec.yaml +++ b/packages/flutter_test/pubspec.yaml @@ -8,9 +8,13 @@ dependencies: test: 0.12.15+4 # We don't actually depend on 'analyzer', but 'test' and 'flutter_tools' do. - # We pin the version of analyzer we depend on to avoid version skew across our - # packages. - analyzer: 0.28.2-alpha.0 + # Like 'flutter_tools', we use the version of the analyzer in the vended Dart + # SDK as defined in the `dependency_overrides` below. + analyzer: any flutter: path: ../flutter + +dependency_overrides: + analyzer: + path: ../../bin/cache/dart-sdk/lib/analyzer diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 86f1423a7e..0fe5cca8c4 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -179,8 +179,15 @@ class AnalyzeCommand extends FlutterCommand { .where((String line) => !line.startsWith(new RegExp(r'^ *#'))) .forEach((String line) { int colon = line.indexOf(':'); - if (colon > 0) - dependencies.add(line.substring(0, colon), path.normalize(path.absolute(directory.path, path.fromUri(line.substring(colon+1)))), dotPackagesPath); + if (colon > 0) { + String packageName = line.substring(0, colon); + String packagePath = path.fromUri(line.substring(colon+1)); + // Ensure that we only add the `analyzer` package defined in the vended SDK (and referred to with a local path directive). + // Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored since they would produce + // spurious conflicts. + if (packageName != 'analyzer' || packagePath.startsWith('..')) + dependencies.add(packageName, path.normalize(path.absolute(directory.path, path.fromUri(packagePath))), dotPackagesPath); + } }); } } diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index 41b927d7fd..db17fb444f 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -38,8 +38,8 @@ dependencies: # precisely. test: 0.12.15+4 - # Pinned in flutter_test as well. - analyzer: 0.28.2-alpha.0 + # Version from the vended Dart SDK as defined in `dependency_overrides`. + analyzer: any dev_dependencies: mockito: ^1.0.0 @@ -47,3 +47,7 @@ dev_dependencies: # Exclude this package from the hosted API docs. dartdoc: nodoc: true + +dependency_overrides: + analyzer: + path: ../../bin/cache/dart-sdk/lib/analyzer