google / google/grinder.dart

Cannot use TaskInvocation in Depends annotation.

Open
#318 4 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
266
Forks
36
Avg merge
23h 25m
Merged PRs (30d)
2

Description

The [Depends documentation](https://www.dartdocs.org/documentation/grinder/0.8.1/grinder/Depends-class.html) states that a `TaskInvocation` can be used instead of a `Function` or `String` in order to pass arguments to a dependent task. However, when trying to pass an instance of `TaskInvocation` to `Depends`, dart throws an error for it not being a compile-time constant.

`error: line 11 pos 10: expression is not a valid compile-time constant @Depends(new TaskInvocation('print'))`

When I try to make a constant `TaskInvocation` dart throws an error because it isn't a const constructor.

`error: line 11 pos 39: non-const constructor 'TaskInvocation' cannot be used in const object creation @Depends(const TaskInvocation('print'))`

This is my `grind.dart` file. Am I using this correctly?
```
import 'package:grinder/grinder.dart';

void main(List args) => grind(args);

@DefaultTask()
void print() {
log(context.invocation.arguments.arguments.toString());
}

@Task()
@Depends(const TaskInvocation('print'))
void printTest() {

}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.