Something like this should work [1]. The main issue is that you have to escape the '$' in ${project.version}, otherwise copybara confuses it with a regex_group var.
#!/bin/bash
d="$(mktemp -d)"
echo "$d"
cd "$d"
cat > copy.bara.sky <<'EOF'
core.workflow(
name = "default",
origin = folder.origin(),
destination = folder.destination(),
authoring = authoring.overwrite("Foo <
f...@example.com>"),
transformations = [
core.replace(before = "<dependency>${ws}<groupId>org.openhab.core.bundles</groupId>${ws}<artifactId>org.openhab.core.ephemeris</artifact\
Id>${ws}<version>$${${id}}</version>${ws2}</dependency>",
after = "REMOVED",
multiline = True,
repeated_groups = True,
regex_groups = {
"ws": "(\\n| |\\t)*",
"ws2": "(\\n| |\\t)*",
"id": "[^}]+"
})
],
)
EOF
mkdir in
mkdir out
cat > in/file.xml <<'EOF'
<dependency>
<groupId>org.openhab.core.OTHER</groupId>