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

Issue with build/watch on Windows #887

Closed
davidmorgan opened this issue Jan 22, 2018 · 15 comments
Closed

Issue with build/watch on Windows #887

davidmorgan opened this issue Jan 22, 2018 · 15 comments

Comments

@davidmorgan
Copy link
Contributor

Please see issue filed against built_value here:

google/built_value.dart#331

The build runner is failing to find a file, so it always does a full rebuild.

Any ideas, please?

@jakemac53
Copy link
Contributor

I think this is because of an old version of build_runner, see #651.

@jakemac53
Copy link
Contributor

@davidmorgan if you are going to be at dart conf we meet at some point and upgrade built_value to the latest and greatest? There have been a lot of recent features, namely you can set it up such that your users don't have to write a build.dart file any more, or actually do any config whatsoever (similar to the uber generator approach).

@davidmorgan
Copy link
Contributor Author

Sadly not, but I will have a go at switching anyway. Actually I already have an issue open :)

google/built_value.dart#311

Thanks!

@jakemac53
Copy link
Contributor

Ok sounds good, the docs on this part are still quite lacking so you can ask questions directly if you hit roadblocks. You can look at json_serializable as an example.

@davidmorgan
Copy link
Contributor Author

Will do, thanks!

@matanlurey
Copy link
Contributor

@davidmorgan please re-open if you need any more assistance after upgrading.

@davidmorgan
Copy link
Contributor Author

@jakemac53

Me again :) ... so I've been looking into build.yaml. It looks like I probably want "auto_apply: dependents", like the json_serializable example:

https://github.com/dart-lang/json_serializable/blob/master/json_serializable/build.yaml

But, what I need is for package:built_value to trigger the generator under package:built_value_generator. Is this possible, please?

If I understand correctly I would add a built.yaml file to package:built_value, and in that, the target needs to be package:built_value_generator ... but it's not clear how to do that?

The intended effect is that when you add a dep on built_value, the builder from built_value_generator will run.

Thanks!

@jakemac53
Copy link
Contributor

You should be able to add a builders section to your built_value package and provide an import to the other package, at least today that would be the easiest way.

@jakemac53
Copy link
Contributor

You should be able to reference built_value_generator as the target as well, that is only required for bazel anyways.

@davidmorgan
Copy link
Contributor Author

I'll give it a try. Unfortunately it looks like I need to make code_builder work with built_value v5 first. This is rather tricky as it turns out ...

dart-lang/tools#871

@davidmorgan
Copy link
Contributor Author

I'll close this (again) for now, will re-open if I get stuck again. Thanks :)

@davidmorgan
Copy link
Contributor Author

I have built_value working locally with build_runner now ... one (hopefully) last question, please.

I'm wiring things up via build.yaml file in built_value:

https://github.com/google/built_value.dart/pull/342/files#diff-c38a034ddd5c70d971bdb8cf447353dd

This depends on the generator in built_value_generator. If I try to use built_value from another package without also adding a dev_dependencies on built_value_generator, then build_runner fails with:

Unhandled exception:
IsolateSpawnException: Unable to spawn isolate: Unhandled exception:
Could not import "package:built_value_generator/builder.dart" from "file:///usr/local/google/home/davidmorgan/git/built-value-dart/built_value_test/.dart_tool/build/entrypoint/build.dart": Failure getting http://localhost:34381/packages/built_value_generator/builder.dart:

which makes sense--it can't find the builder because there is no dev dependency on it--but I wonder if there is a better way to do this?

It would be ideal if the built_value_generator dev dependency could somehow be picked up via the built_value dependency. (But I don't think it works like that...)

Failing that, would it be possible for build_runner to give a more helpful error message if this happens?

Thanks!

@jakemac53
Copy link
Contributor

jakemac53 commented Feb 5, 2018

It would be ideal if the built_value_generator dev dependency could somehow be picked up via the built_value dependency. (But I don't think it works like that...)

Yes the only way to do that would be to add it to the normal deps of built_value.

With these build_to: source builders you would ideally avoid adding a real dependency on the actual builder package, so that consumers of packages that use built_value wouldn't pick up those dependencies (they may not even need to run any codegen). The only way to make that happen today would be if they have an explicit dev_dependency on built_value_generator in each the package that intends to do codegen - which also effectively means you might as well move the build.yaml to that package.

@natebosch
Copy link
Member

Failing that, would it be possible for build_runner to give a more helpful error message if this happens?

Not easily, but this is an interesting use case that we might be able to improve in the future. #961

@matanlurey
Copy link
Contributor

Closing in favor of the more general #961.

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

4 participants