From 3673391df3f449fd3490c7b2b66ff3bf35c621d7 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 27 Jan 2017 13:51:32 -0800 Subject: [PATCH] update to build 0.7.0 (#128) --- CHANGELOG.md | 10 +++++++--- lib/generators/json_literal_generator.dart | 4 ++-- lib/src/builder.dart | 20 +++++++------------- pubspec.yaml | 8 ++++---- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a92e97d5..d3b73935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.4 + +* Update to latest `build`, `build_runner`, and `build_test` releases. + ## 0.5.3+2 * BugFix: Always release the Resolver instance, even when generation does not @@ -55,7 +59,7 @@ ## 0.5.1 -* Added GeneratorBuilder option isStandalone to generate files that aren't +* Added GeneratorBuilder option isStandalone to generate files that aren't part of source file. ## 0.5.0+3 @@ -86,7 +90,7 @@ files via the `BuildStep` class, and that is now also provided to `Generator#generate` and `GeneratorForAnnotation#generateForAnnotatedElement` as a second argument. - + * Timestamps are no longer included in generated code. * There is no longer a need to specify the files related to an individual @@ -102,7 +106,7 @@ ## 0.4.7+2 -* Upgrade to `analyzer '^0.27.1'` and removed a work-around for a fixed +* Upgrade to `analyzer '^0.27.1'` and removed a work-around for a fixed `analyzer` issue. ## 0.4.7+1 diff --git a/lib/generators/json_literal_generator.dart b/lib/generators/json_literal_generator.dart index 4729ee48..70c293a6 100644 --- a/lib/generators/json_literal_generator.dart +++ b/lib/generators/json_literal_generator.dart @@ -24,9 +24,9 @@ class JsonLiteralGenerator extends GeneratorForAnnotation { throw 'must be relative path to the source file'; } - var sourcePathDir = p.dirname(buildStep.input.id.path); + var sourcePathDir = p.dirname(buildStep.inputId.path); var fileId = new AssetId( - buildStep.input.id.package, p.join(sourcePathDir, annotation.path)); + buildStep.inputId.package, p.join(sourcePathDir, annotation.path)); var content = JSON.decode(await buildStep.readAsString(fileId)); var thing = JSON.encode(content); diff --git a/lib/src/builder.dart b/lib/src/builder.dart index e663306c..48d5b418 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -28,15 +28,10 @@ class GeneratorBuilder extends Builder { @override Future build(BuildStep buildStep) async { - var id = buildStep.input.id; - var resolver = await buildStep.resolve(id, resolveAllConstants: false); - try { - var lib = resolver.getLibrary(id); - if (lib == null) return; - await _generateForLibrary(lib, buildStep); - } finally { - resolver.release(); - } + var resolver = await buildStep.resolver; + if (!resolver.isLibrary(buildStep.inputId)) return; + var lib = resolver.getLibrary(buildStep.inputId); + await _generateForLibrary(lib, buildStep); } @override @@ -50,7 +45,7 @@ class GeneratorBuilder extends Builder { Future _generateForLibrary( LibraryElement library, BuildStep buildStep) async { - buildStep.logger.fine('Running $generators for ${buildStep.input.id}'); + buildStep.logger.fine('Running $generators for ${buildStep.inputId}'); var generatedOutputs = await _generate(library, generators, buildStep).toList(); @@ -91,9 +86,8 @@ if approppriate.""", stack); } - var outputId = _generatedFile(buildStep.input.id); - var output = new Asset(outputId, '$_topHeader$genPartContent'); - buildStep.writeAsString(output); + buildStep.writeAsString( + _generatedFile(buildStep.inputId), '$_topHeader$genPartContent'); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 68adc7c4..0fb9e7cb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: source_gen -version: 0.5.3+2 +version: 0.5.4 author: Dart Team description: Automatic sourcecode generation for Dart homepage: https://github.com/dart-lang/source_gen @@ -7,12 +7,12 @@ environment: sdk: '>=1.12.0 <2.0.0' dependencies: analyzer: ^0.29.2 - build: '>=0.2.1 <0.7.0' + build: ^0.7.0 dart_style: '>=0.1.7 <0.3.0' path: ^1.3.2 dev_dependencies: - build_runner: ^0.1.0 - build_test: ^0.3.0 + build_runner: ^0.2.0 + build_test: ^0.4.0 cli_util: ^0.0.1 collection: ^1.1.2 mockito: '>=0.11.0 <2.0.0'