TeamWanari / rosetta

Flutter Localization tool with code generation tool.
MIT License
35 stars 7 forks source link

New keys in json files aren't detected #28

Closed janosroden closed 5 years ago

janosroden commented 5 years ago

Describe the bug I've added a new key to jsons in your flutter_example and the .g.dart file didn't change.

To Reproduce Steps to reproduce the behavior:

  1. Clone this repo (stable branch)
  2. flutter pub get
  3. EDIT: flutter packages pub run build_runner build --delete-conflicting-outputs --verbose
  4. Add a key to json files
  5. flutter packages pub run build_runner build --delete-conflicting-outputs --verbose

Expected behavior The new key should appear in the generated file

Desktop (please complete the following information):

agta1991 commented 5 years ago

Hi!

Nice catch. I forgot to update the build configuration YAML to include the json files in the "watch"-ed assets. The build.yaml in the project root should contain the path to the translation files like this:

targets:
  $default:
    sources:
      include:
      - i18n/**
      - lib/**
    builders:
      rosetta:

Can you check if this solves the issue? I will also try it out, but I currently don't have enough time for it.

janosroden commented 5 years ago

Hi, no, this doesn't solve.

I'm afraid I missed a repro step:

  1. Clone this repo (stable branch)
  2. flutter pub get
  3. flutter packages pub run build_runner build --delete-conflicting-outputs --verbose
  4. Add a key to json files
  5. flutter packages pub run build_runner build --delete-conflicting-outputs --verbose
agta1991 commented 5 years ago

Hi,

Yes using build_runner build will never update the generated file on dependent changes. If you would like to have immeditate code generation, you should use build_runner watch, and of course, the correct build.yaml config described above is also needed.

So, if using the stable branch:

  1. Clone this repo (stable)
  2. Update build.yaml as described above
  3. flutter pub get
  4. flutter packages pub run build_runner clean (just to make sure everything is clean)
  5. flutter packages pub run build_runner watch (this will do the initial build, and then watch for dependant filesystem changes, dont kill the process let it run while you edit the source files)
  6. Add a key to JSON
  7. After saving the JSON you should notice the process is triggered (from the logs) and new file(s) are generated.
janosroden commented 5 years ago

I see, okay, so build runner unable to recognize which inputs are changed without watch (like a make). I don't want to watch, but it's okay, I can live with the clean && build commands.

Thank you for your help! Cheers