summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alan Viverette <alanv@google.com> 2022-08-16 14:47:29 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-08-16 14:47:29 +0000
commit63e738ffe0cb7328d75e288ee0356da5e521c455 (patch)
tree1cf8c07035be95ee6be4ab827b4928b66da719be
parent1ad11e6fbfeb01ed077d0be9395e4ad002738263 (diff)
parentd3be6f588516389ccb68e54d14655b0a8d36ca9f (diff)
Merge "Add support for prepending text from a file"
-rw-r--r--cmd/pom2bp/pom2bp.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index f8844fc94..d4a57bf3f 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -824,6 +824,7 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib
var regen string
var pom2build bool
+ var prepend string
flag.Var(&excludes, "exclude", "Exclude module")
flag.Var(&extraStaticLibs, "extra-static-libs", "Extra static dependencies needed when depending on a module")
@@ -839,6 +840,7 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib
flag.BoolVar(&jetifier, "jetifier", false, "Sets jetifier: true on all modules")
flag.StringVar(&regen, "regen", "", "Rewrite specified file")
flag.BoolVar(&pom2build, "pom2build", false, "If true, will generate a Bazel BUILD file *instead* of a .bp file")
+ flag.StringVar(&prepend, "prepend", "", "Path to a file containing text to insert at the beginning of the generated build file")
flag.Parse()
if regen != "" {
@@ -965,6 +967,15 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib
fmt.Fprintln(buf, commentString, "Automatically generated with:")
fmt.Fprintln(buf, commentString, "pom2bp", strings.Join(proptools.ShellEscapeList(os.Args[1:]), " "))
+ if prepend != "" {
+ contents, err := ioutil.ReadFile(prepend)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Error reading", prepend, err)
+ os.Exit(1)
+ }
+ fmt.Fprintln(buf, string(contents))
+ }
+
depsTemplate := bpDepsTemplate
template := bpTemplate
if pom2build {