bwu_grinder_tasks 0.2.0-dev.0 copy "bwu_grinder_tasks: ^0.2.0-dev.0" to clipboard
bwu_grinder_tasks: ^0.2.0-dev.0 copied to clipboard

outdated

A collection of common grinder tasks to reuse in different projects.

BWU Grinder Tasks #

Star this Repo Pub Package Build Status Coverage Status

A set of common reusable Grinder tasks.

Usage #

Simplest case #

Add a dependency to the packages grinder and bwu_grinder_tasks to your dependencies in pubspec.yaml and add the file tool/grind.dart with the following content to your project:

export 'package:bwu_grinder_tasks/bwu_grinder_tasks.dart';

Then you can run it from your project root directory with

grind
# or
grind check
# or
grind format
# ...

Customize (hide tasks) #

If you just want to use a few of the tasks but not all you can hide tasks you don't want to use and also add your own tasks. The following example suppresses browser tests. If you want to customize the tasks, you always need to implement your own main() method (and hide the provided main()).

library bwu_dart_archive_downloader.tool.grind;

export 'package:bwu_utils_dev/grinder/default_tasks.dart' hide main, lint, check, 
    travis;
import 'package:bwu_utils_dev/grinder/default_tasks.dart' show grind;

main(List<String> args) {
  grind(args);
}

@Task('some task')
some() => print('did something');

What doesn't work is to hide a task which is a dependency for another task. You also need to hide the task which depends on the task you want to hide. In the example above we hide the lint task and also need to hide check and travis which depend on lint.

Customize (provide custom implementation) #

Instead of hiding and reimplementing a task you can just assign a custom implementation to a task.

The provided tasks are split in three parts.

  • The delaration with the @Task(), @DefaultTask and @Depends() annotation,
  • A variable which is referenced by a task and itself references the implementation of the task.
  • The implementation of a task
@Task('Run lint checks')
lint() => lintTask();
Function lintTask = lintTaskImpl;
lintTaskImpl() => new PubApp.global('linter')
    .run(['--stats', '-ctool/lintcfg.yaml']..addAll(existingSourceDirs));

If you want to change or extend the behavior of the lint task you can do this like:

library bwu_dart_archive_downloader.tool.grind;

export 'package:bwu_utils_dev/grinder/default_tasks.dart' hide main;
import 'package:bwu_utils_dev/grinder/default_tasks.dart'
    show grind, lintTask, lintTaskImpl;

main(List<String> args) {
  lintTask = () {
    print('before linting');
    testTaskImpl(['vm']);
    print('after linting');
  grind(args);
}

0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A collection of common grinder tasks to reuse in different projects.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

grinder, path, pub_semver, yaml

More

Packages that depend on bwu_grinder_tasks