I want to create a Builder
that would create Env
class on the fly. That class should be available for import anywhere in my project. It is as container for environment constants defined in build.yml
Builder itself works fine, it generates desired output, however when I run
pub run build_runner build
build fails with following message
[SEVERE] build_web_compilers:entrypoint on web/main.dart: Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).
Please check the following imports:
import '../.dart_tool/build/generated/buildertest/lib/environment.g.dart';
from buildertest|web/main.dart at 2:1[INFO] Running build completed, took 4.1s [INFO] Caching finalized dependency graph completed, took 450ms [SEVERE] Failed after 4.6s
import by itself is ok, as it works fine when I run following snippet
import '../.dart_tool/build/generated/buildertest/lib/environment.g.dart';
void main() {
print("Name:${Environment.name}");
print("Endpoint:${Environment.endpoint}");
}
with
dart web/main.dar
t
What should be done to make this import valid??
Here is build.yaml
targets:
$default:
builders:
angular_components|scss_builder:
enabled: True
env|builder:
options:
name: "default"
endpoint: "http://example.org"
enabled: true
builders:
env|builder:
import: "env/EnvBuilder.dart"
builder_factories: ["builderFactory"]
is_optional: false
build_extensions:
"$lib$": ["environment.g.dart"]
auto_apply: root_package
runs_before: ["build_test:test_bootstrap","build_modules:module_library","build_modules:dartdevc","build_web_compilers:ddc","build_modules:vm","build_modules:dart2js","build_web_compilers:entrypoint"]