acquire method

Future<Workspace> acquire(
  1. String platform
)

Locks a free workspace for platform (creating one if needed) and syncs the project into it.

Implementation

Future<Workspace> acquire(String platform) async {
  root.createSync(recursive: true);
  for (var n = 1;; n++) {
    final dir = Directory(p.join(root.path, '$platform-$n'));
    dir.createSync(recursive: true);
    final lock = File(p.join(dir.path, _lockName));
    if (_tryLock(lock)) {
      final ws = Workspace(dir, lock);
      try {
        await sync(Directory(projectDir), dir);
        rewriteExternalPathDependencies(dir.path);
      } catch (e) {
        ws.release();
        throw BuildException(
            'Could not prepare a build workspace at ${dir.path}: $e',
            fix:
                'Check free disk space, or run "udara_cli clean --workspaces" to reset them.');
      }
      return ws;
    }
  }
}