Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflectable is not a know builder #308

Open
yhhCh405 opened this issue Feb 1, 2023 · 1 comment
Open

Reflectable is not a know builder #308

yhhCh405 opened this issue Feb 1, 2023 · 1 comment

Comments

@yhhCh405
Copy link

yhhCh405 commented Feb 1, 2023

Whenever I tried to build output with reflectableBuild, I always got this error:
ApplyBuilders: Configuring `reflectable:reflectable` in target but this is not a known Builder. Could anyone plz help me?

In pubspec.yaml

name: reflection
description: A new Flutter project
publish_to: "none"
version: 1.0.0+1

environment:
  sdk: ">=2.19.0 <3.0.0"
dependencies:
  cupertino_icons: ^1.0.2
  flutter:
    sdk: flutter
  reflectable: ^4.0.4

dev_dependencies:
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter
  build_runner: 
flutter:
  uses-material-design: true

In build.yaml

targets:
  $default:
    builders:
      reflectable:
        generate_for: 
          - bin/something.dart
        options:
          formatted: true

In bin/builder.dart

import 'package:reflectable/reflectable_builder.dart';

Future<void> main(List<String> args) async {
  await reflectableBuild(args);
}

In bin/something.dart

import 'package:reflectable/reflectable.dart';

import 'something.reflectable.dart';

void main() {
  initializeReflectable();
  ClassMirror cm = reflector.reflectType(TargetClass) as ClassMirror;
  print(cm.declarations);
}

const reflector = Reflector();

class Reflector extends Reflectable {
  const Reflector() : super(reflectedTypeCapability);
}

@reflector
class TargetClass {
  String name = "foo";
  void someMethod() {}
}

Then I run with this command: dart bin/builder.dart bin/something.dart

I got this output. But there is no expected print result.

[WARNING] ApplyBuilders: Configuring `reflectable:reflectable` in target `reflection:reflection` but this is not a known Builder
[INFO] BuildDefinition: Initializing inputs
[INFO] BuildDefinition: Reading cached asset graph...
[INFO] BuildDefinition: Reading cached asset graph completed, took 27ms

[INFO] BuildDefinition: Checking for updates since last build...
[INFO] BuildDefinition: Checking for updates since last build completed, took 276ms

[INFO] Build: Running build...
[INFO] Build: Running build completed, took 4ms

[INFO] Build: Caching finalized dependency graph...
[INFO] Build: Caching finalized dependency graph completed, took 17ms

[INFO] Build: Succeeded after 25ms with 0 outputs (0 actions)
@eernstg
Copy link
Collaborator

eernstg commented Feb 2, 2023

Hi @yhhCh405, I'd recommend that you do a few things differently, in order to follow the normal usage: You should not need bin/builder.dart at all, and the command used to perform the reflectable code generation step should be

> flutter pub run build_runner build bin

(Actually, the package does not seem to depend on anything in Flutter, so it could be turned into a plain Dart package and use dart pub run build_runner build bin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants