Skip to content

Folder Origin & Destination

Folder-based origins and destinations work with the local filesystem, useful for testing and development.

Read from a local directory:

origin = folder.origin()
ParameterDescription
materialize_outside_symlinksHandle symlinks pointing outside
Terminal window
# Run with local folder
java -jar copybara.jar migrate copy.bara.sky workflow --folder-origin /path/to/source

Write to a local directory:

destination = folder.destination()
Terminal window
# Run with local destination
java -jar copybara.jar migrate copy.bara.sky workflow --folder-destination /path/to/output

Use folder origin/destination to test transformations locally:

test.bara.sky
core.workflow(
name = "test",
origin = folder.origin(),
destination = folder.destination(),
authoring = authoring.overwrite("Test <test@example.com>"),
transformations = [
core.move("src/", "lib/"),
core.replace("old", "new"),
],
)
Terminal window
# Test the workflow
java -jar copybara.jar migrate test.bara.sky test \
--folder-origin /path/to/source \
--folder-destination /tmp/output
# Inspect the output
ls /tmp/output

A common pattern during development:

  1. Create test workflow:

    core.workflow(
    name = "test-local",
    origin = folder.origin(),
    destination = folder.destination(),
    ...
    )
  2. Test locally:

    Terminal window
    java -jar copybara.jar migrate copy.bara.sky test-local \
    --folder-origin . \
    --folder-destination /tmp/test
  3. Verify output:

    Terminal window
    diff -r /tmp/test expected/
  4. Switch to Git when ready:

    core.workflow(
    name = "production",
    origin = git.origin(...),
    destination = git.destination(...),
    ...
    )

Use folder destination to preview what Copybara would produce:

# Same transformations, different destination
core.workflow(
name = "preview",
origin = git.origin(url = "...", ref = "main"),
destination = folder.destination(), # Local output
transformations = [...],
)
Terminal window
java -jar copybara.jar migrate copy.bara.sky preview \
--folder-destination /tmp/preview
# Review the output before running production workflow
  • No state tracking: Folder operations don’t track what’s been synced
  • No Git history: Output is just files, no commits
  • CLI paths: Source/destination paths must be provided via CLI