Reputation: 9808
I'm trying out inject.dart in my side project, but have been unsuccessful in getting my app to compile.
If it helps, you can see my project here.
I've copied the inject
and inject_generator
packages into my project since there's currently no official release. Then, I run:
pub run build_runner build
(or flutter packages pub run build_runner build
)
I see the generated files all being created in .dart_tools/build/generated
successfully, however my files in lib/
can't reference the generated files. Hence I just get a compilation error every time I try to run my app.
Has anyone got any clues as to what I am (or might be) doing wrong? Am I even supposed to be able to reference files in this folder?
Upvotes: 2
Views: 1554
Reputation: 657821
You might be able to get the desired result by specifying build_to: source
like shown in this example
https://github.com/dart-lang/build/blob/10667edc1ed4f3e5d15fcfd2d0a447113f89e982/example/build.yaml
builders:
copyBuilder:
import: "package:example/builder.dart"
builder_factories: ["copyBuilder"]
build_extensions: {".txt": [".txt.copy"]}
build_to: source
auto_apply: root_package
There is some explanation in https://github.com/dart-lang/build/blob/dff811be8b99e0ac7b15a8c7b9ad7bd2b5027a1d/build_config/README.md
- build_to: Optional. The location that generated assets should be output to. The possibilities are:
"source"
: Outputs go to the source tree next to their primary inputs."cache"
: Outputs go to a hidden build cache and won't be published. The default is "cache". If a Builder specifies that it outputs to "source" it will never run on any package other than the root - but does not necessarily need to use the "root_package" value for "auto_apply". If it would otherwise run on a non-root package it will be filtered out.
Upvotes: 2