grinder library

Dart workflows, automated.

See the README for detailed usage information.

Classes

Analyzer
Utility tasks for invoking the analyzer.
Dart
Utility tasks for for getting information about the Dart VM and for running Dart applications.
Dart2js
Utility tasks for invoking dart2js.
DartDoc
Utility class for invoking dartdoc.
DartFmt
Utility class for invoking dartfmt from the SDK. This wrapper requires the dartfmt from SDK 1.9 and greater.
DefaultTask
An annotation to define the default GrinderTask to run when no tasks are specified on the command line.
Depends
An annotation to define a Task's dependencies.
DevCompiler
A class to drive the Dart Dev Compiler (DDC, from the dev_compiler package).
FilePath
A class to make it easier to manipulate file system entites. Once paths or entites are converted into Paths, they can be easily copied, deleted, joined, and their name retrieved.
FileSet
A class to handle defining, composing, and comparing groups of files.
Grinder
A class representing a running instance of a Grinder.
GrinderContext
A GrinderContext is used to give the currently running Grinder task the ability to introspect the running state. It can get the current Grinder instance and get a reference to the current GrinderTask instance (as well as the previous and next tasks, if any).
GrinderTask
Represents a Grinder task. These can be created automatically using the Task and Depends annotations.
Pub
Utility tasks for executing pub commands.
PubApp
A Dart command-line application, installed via pub global activate.
PubGlobal
Access the pub global commands.
RunOptions
Arguments passed to Process.run or Process.start. See Process.run for more details.
Task
An annotation to mark a GrinderTask definition.
TaskArgs
Any arguments passed into the task from the command line.
TaskInvocation
An invocation of a GrinderTask.
TestRunner
A wrapper around the test package. This class is used to run your unit tests.

Properties

binDir Directory
final
buildDir Directory
final
context GrinderContext
Get the GrinderContext for the currently executing task.
no setter
dartVM File
final
defaultTask GrinderTask?
The default task run when no tasks are specified on the command line.
getter/setter pair
existingSourceDirs Set<Directory>
The subset of directories in sourceDirs which actually exist in the current working directory.
no setter
libDir Directory
final
sdkDir Directory
The path to the current Dart SDK.
final
sourceDirs Set<Directory>
A set of common top-level directories according to the Pub package layout convention which usually contain Dart source code.
final
webDir Directory
final

Functions

addTask(GrinderTask task) → void
Programmatically add a task to the global Grinder instance.
baseName(FileSystemEntity entity) String?
Return the first n - 1 segments of the file path.
copy(FileSystemEntity entity, Directory destDir, [GrinderContext? context]) → void
Copy the given entity to the destination directory.
copyDirectory(Directory srcDir, Directory destDir, [GrinderContext? context]) → void
Prefer using copy.
copyFile(File srcFile, Directory destDir, [GrinderContext? context]) → void
Prefer using copy.
defaultClean([GrinderContext? context]) → void
A default implementation of a clean task. This task deletes all generated artifacts in the build/.
delete(FileSystemEntity entity) → void
Delete the given file entity reference.
deleteEntity(FileSystemEntity entity, [GrinderContext? context]) → void
Prefer using delete.
fail(String message) → Never
Halt task execution; throws an exception with the given error message.
fileExt(FileSystemEntity entity) String?
Return the file's extension without the period. This will return null if there is no extension.
fileName(FileSystemEntity entity) String
Return the last segment of the file path.
getDir(String path) Directory
Return the directory pointed to by the given path. This method converts the given path to a platform dependent path.
getFile(String path) File
Return the file pointed to by the given path. This method converts the given path to a platform dependent path.
getSdkDir([List<String>? cliArgs]) Directory
This is deprecated.
grind(List<String> args, {bool verifyProjectRoot = true}) Future
Run the grinder file.
grinderArgs() List<String>
joinDir(Directory dir, List<String> files) Directory
joinFile(Directory dir, List<String> files) File
log(String message) → void
Log an informational message to Grinder's output.
run(String executable, {List<String> arguments = const [], RunOptions? runOptions, bool quiet = false, String? workingDirectory}) String
Synchronously run an executable.
runAsync(String executable, {List<String> arguments = const [], RunOptions? runOptions, bool quiet = false, String? workingDirectory}) Future<String>
Asynchronously run an executable.
runDartScript(String script, {List<String> arguments = const [], bool quiet = false, String? packageRoot, RunOptions? runOptions, String? workingDirectory}) String
Run a dart script using run_lib.run. Returns the stdout.
runProcess(String executable, {List<String> arguments = const [], RunOptions? runOptions, bool quiet = false, String? workingDirectory}) String
Synchronously run an executable.
runProcessAsync(String executable, {List<String> arguments = const [], RunOptions? runOptions, String? workingDirectory, bool quiet = false}) Future<String>
Asynchronously run an executable.
sdkBin(String name) String
Return the path to a binary in the SDK's bin/ directory. This will handle appending .bat or .exe on Windows. This is useful for finding the path to SDK utilities like dartdoc, dart2js, ...
startGrinder(List<String> args, {bool verifyProjectRoot = true}) Future
Start the build process. This should be called at the end of the main() method. If there is a task failure, this method will halt task execution and throw.
task(String name, [Function? taskFunction, List<String> depends = const []]) → void
Add a new task definition to the global Grinder instance. A name is required. If specified, a taskFunction is invoked when the task starts. Any dependencies of the task, that need to run before it, should be passed in via depends.

Typedefs

TaskFunction = dynamic Function(TaskArgs args)
The typedef for grinder task functions.

Exceptions / Errors

GrinderException
An exception class for the Grinder library.
ProcessException
An exception from a process which exited with a non-zero exit code.