blob: 94e56194371f9b36fa884832455fd7e49253cd31 [file] [log] [blame]
Dan Willemsen2902fa72017-04-27 21:16:35 -07001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
Colin Cross9f5633d2018-04-19 16:52:21 -070018 "bufio"
19 "bytes"
Dan Willemsen2902fa72017-04-27 21:16:35 -070020 "encoding/xml"
21 "flag"
22 "fmt"
Dan Willemsen2902fa72017-04-27 21:16:35 -070023 "io/ioutil"
24 "os"
Colin Cross9f5633d2018-04-19 16:52:21 -070025 "os/exec"
Dan Willemsen2902fa72017-04-27 21:16:35 -070026 "path/filepath"
27 "regexp"
28 "sort"
29 "strings"
30 "text/template"
31
32 "github.com/google/blueprint/proptools"
33)
34
35type RewriteNames []RewriteName
36type RewriteName struct {
37 regexp *regexp.Regexp
38 repl string
39}
40
41func (r *RewriteNames) String() string {
42 return ""
43}
44
45func (r *RewriteNames) Set(v string) error {
46 split := strings.SplitN(v, "=", 2)
47 if len(split) != 2 {
48 return fmt.Errorf("Must be in the form of <regex>=<replace>")
49 }
50 regex, err := regexp.Compile(split[0])
51 if err != nil {
52 return nil
53 }
54 *r = append(*r, RewriteName{
55 regexp: regex,
56 repl: split[1],
57 })
58 return nil
59}
60
Alan Viverette75b95f82017-12-04 16:24:07 -050061func (r *RewriteNames) MavenToMk(groupId string, artifactId string) string {
Dan Willemsen2902fa72017-04-27 21:16:35 -070062 for _, r := range *r {
Alan Viverette75b95f82017-12-04 16:24:07 -050063 if r.regexp.MatchString(groupId + ":" + artifactId) {
64 return r.regexp.ReplaceAllString(groupId+":"+artifactId, r.repl)
65 } else if r.regexp.MatchString(artifactId) {
66 return r.regexp.ReplaceAllString(artifactId, r.repl)
Dan Willemsen2902fa72017-04-27 21:16:35 -070067 }
68 }
Alan Viverette75b95f82017-12-04 16:24:07 -050069 return artifactId
Dan Willemsen2902fa72017-04-27 21:16:35 -070070}
71
72var rewriteNames = RewriteNames{}
73
74type ExtraDeps map[string][]string
75
76func (d ExtraDeps) String() string {
77 return ""
78}
79
80func (d ExtraDeps) Set(v string) error {
81 split := strings.SplitN(v, "=", 2)
82 if len(split) != 2 {
83 return fmt.Errorf("Must be in the form of <module>=<module>[,<module>]")
84 }
85 d[split[0]] = strings.Split(split[1], ",")
86 return nil
87}
88
89var extraDeps = make(ExtraDeps)
90
Colin Cross6b382bc2018-04-19 22:44:16 -070091type Exclude map[string]bool
92
93func (e Exclude) String() string {
94 return ""
95}
96
97func (e Exclude) Set(v string) error {
98 e[v] = true
99 return nil
100}
101
102var excludes = make(Exclude)
103
Dan Willemsen15a8e792017-11-10 14:02:44 -0800104var sdkVersion string
Dan Willemsen47e44a42017-10-05 13:28:16 -0700105var useVersion string
Alan Viverette1593d3d2017-12-11 17:14:26 -0500106var staticDeps bool
Dan Willemsen47e44a42017-10-05 13:28:16 -0700107
Jeff Gaston8f084822018-03-29 14:58:50 -0400108func InList(s string, list []string) bool {
109 for _, l := range list {
110 if l == s {
111 return true
112 }
113 }
114
115 return false
116}
117
Dan Willemsen2902fa72017-04-27 21:16:35 -0700118type Dependency struct {
119 XMLName xml.Name `xml:"dependency"`
120
Alan Viverette1593d3d2017-12-11 17:14:26 -0500121 MakeTarget string `xml:"-"`
122
Dan Willemsen2902fa72017-04-27 21:16:35 -0700123 GroupId string `xml:"groupId"`
124 ArtifactId string `xml:"artifactId"`
125 Version string `xml:"version"`
126 Type string `xml:"type"`
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500127 Scope string `xml:"scope"`
Dan Willemsen2902fa72017-04-27 21:16:35 -0700128}
129
Alan Viverette1593d3d2017-12-11 17:14:26 -0500130func (d Dependency) MkName() string {
131 if d.MakeTarget == "" {
132 d.MakeTarget = rewriteNames.MavenToMk(d.GroupId, d.ArtifactId)
133 }
134 return d.MakeTarget
135}
136
Dan Willemsen2902fa72017-04-27 21:16:35 -0700137type Pom struct {
138 XMLName xml.Name `xml:"http://maven.apache.org/POM/4.0.0 project"`
139
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700140 PomFile string `xml:"-"`
Dan Willemsen2902fa72017-04-27 21:16:35 -0700141 ArtifactFile string `xml:"-"`
Alan Viverette75b95f82017-12-04 16:24:07 -0500142 MakeTarget string `xml:"-"`
Dan Willemsen2902fa72017-04-27 21:16:35 -0700143
144 GroupId string `xml:"groupId"`
145 ArtifactId string `xml:"artifactId"`
146 Version string `xml:"version"`
147 Packaging string `xml:"packaging"`
148
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700149 Dependencies []*Dependency `xml:"dependencies>dependency"`
Dan Willemsen2902fa72017-04-27 21:16:35 -0700150}
151
Alan Viverette1593d3d2017-12-11 17:14:26 -0500152func (p Pom) IsAar() bool {
153 return p.Packaging == "aar"
154}
155
156func (p Pom) IsJar() bool {
157 return p.Packaging == "jar"
158}
159
Dan Willemsen2902fa72017-04-27 21:16:35 -0700160func (p Pom) MkName() string {
Alan Viverette75b95f82017-12-04 16:24:07 -0500161 if p.MakeTarget == "" {
162 p.MakeTarget = rewriteNames.MavenToMk(p.GroupId, p.ArtifactId)
163 }
164 return p.MakeTarget
Dan Willemsen2902fa72017-04-27 21:16:35 -0700165}
166
Alan Viverette1593d3d2017-12-11 17:14:26 -0500167func (p Pom) MkJarDeps() []string {
Jeff Gaston8f084822018-03-29 14:58:50 -0400168 return p.MkDeps("jar", []string{"compile", "runtime"})
Alan Viverette1593d3d2017-12-11 17:14:26 -0500169}
170
171func (p Pom) MkAarDeps() []string {
Jeff Gaston8f084822018-03-29 14:58:50 -0400172 return p.MkDeps("aar", []string{"compile", "runtime"})
Alan Viverette1593d3d2017-12-11 17:14:26 -0500173}
174
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500175// MkDeps obtains dependencies filtered by type and scope. The results of this
176// method are formatted as Make targets, e.g. run through MavenToMk rules.
Jeff Gaston8f084822018-03-29 14:58:50 -0400177func (p Pom) MkDeps(typeExt string, scopes []string) []string {
Dan Willemsen2902fa72017-04-27 21:16:35 -0700178 var ret []string
Jeff Gaston358f25e2018-04-23 15:32:19 -0400179 if typeExt == "jar" {
180 // all top-level extra deps are assumed to be of type "jar" until we add syntax to specify other types
181 ret = append(ret, extraDeps[p.MkName()]...)
182 }
Dan Willemsen2902fa72017-04-27 21:16:35 -0700183 for _, d := range p.Dependencies {
Jeff Gaston8f084822018-03-29 14:58:50 -0400184 if d.Type != typeExt || !InList(d.Scope, scopes) {
Dan Willemsen2902fa72017-04-27 21:16:35 -0700185 continue
186 }
Alan Viverette75b95f82017-12-04 16:24:07 -0500187 name := rewriteNames.MavenToMk(d.GroupId, d.ArtifactId)
Dan Willemsen2902fa72017-04-27 21:16:35 -0700188 ret = append(ret, name)
189 ret = append(ret, extraDeps[name]...)
190 }
191 return ret
192}
193
Dan Willemsen15a8e792017-11-10 14:02:44 -0800194func (p Pom) SdkVersion() string {
195 return sdkVersion
196}
197
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500198func (p *Pom) FixDeps(modules map[string]*Pom) {
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700199 for _, d := range p.Dependencies {
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500200 if d.Type == "" {
201 if depPom, ok := modules[d.MkName()]; ok {
202 // We've seen the POM for this dependency, use its packaging
203 // as the dependency type rather than Maven spec default.
204 d.Type = depPom.Packaging
205 } else {
206 // Dependency type was not specified and we don't have the POM
207 // for this artifact, use the default from Maven spec.
208 d.Type = "jar"
209 }
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700210 }
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500211 if d.Scope == "" {
212 // Scope was not specified, use the default from Maven spec.
213 d.Scope = "compile"
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700214 }
215 }
216}
217
Dan Willemsen2902fa72017-04-27 21:16:35 -0700218var mkTemplate = template.Must(template.New("mk").Parse(`
219include $(CLEAR_VARS)
220LOCAL_MODULE := {{.MkName}}
221LOCAL_MODULE_CLASS := JAVA_LIBRARIES
222LOCAL_UNINSTALLABLE_MODULE := true
223LOCAL_SRC_FILES := {{.ArtifactFile}}
224LOCAL_BUILT_MODULE_STEM := javalib.jar
225LOCAL_MODULE_SUFFIX := .{{.Packaging}}
226LOCAL_USE_AAPT2 := true
Dan Willemsen15a8e792017-11-10 14:02:44 -0800227LOCAL_SDK_VERSION := {{.SdkVersion}}
Alan Viverette2b53a0c2018-03-28 10:32:10 -0400228LOCAL_STATIC_JAVA_LIBRARIES :={{range .MkJarDeps}} \
229 {{.}}{{end}}
230LOCAL_STATIC_ANDROID_LIBRARIES :={{range .MkAarDeps}} \
231 {{.}}{{end}}
Dan Willemsen2902fa72017-04-27 21:16:35 -0700232include $(BUILD_PREBUILT)
233`))
234
Alan Viverette1593d3d2017-12-11 17:14:26 -0500235var mkDepsTemplate = template.Must(template.New("mk").Parse(`
236include $(CLEAR_VARS)
237LOCAL_MODULE := {{.MkName}}-nodeps
238LOCAL_MODULE_CLASS := JAVA_LIBRARIES
239LOCAL_UNINSTALLABLE_MODULE := true
240LOCAL_SRC_FILES := {{.ArtifactFile}}
241LOCAL_BUILT_MODULE_STEM := javalib.jar
242LOCAL_MODULE_SUFFIX := .{{.Packaging}}
243LOCAL_USE_AAPT2 := true
244LOCAL_SDK_VERSION := {{.SdkVersion}}
245LOCAL_STATIC_ANDROID_LIBRARIES :={{range .MkAarDeps}} \
246 {{.}}{{end}}
247include $(BUILD_PREBUILT)
248include $(CLEAR_VARS)
249LOCAL_MODULE := {{.MkName}}
250LOCAL_SDK_VERSION := {{.SdkVersion}}{{if .IsAar}}
251LOCAL_MANIFEST_FILE := manifests/{{.MkName}}/AndroidManifest.xml{{end}}
252LOCAL_STATIC_JAVA_LIBRARIES :={{if .IsJar}} \
253 {{.MkName}}-nodeps{{end}}{{range .MkJarDeps}} \
254 {{.}}{{end}}
255LOCAL_STATIC_ANDROID_LIBRARIES :={{if .IsAar}} \
256 {{.MkName}}-nodeps{{end}}{{range .MkAarDeps}} \
257 {{.}}{{end}}
258LOCAL_JAR_EXCLUDE_FILES := none
259LOCAL_JAVA_LANGUAGE_VERSION := 1.7
260LOCAL_USE_AAPT2 := true
261include $(BUILD_STATIC_JAVA_LIBRARY)
262`))
263
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700264func parse(filename string) (*Pom, error) {
Dan Willemsen2902fa72017-04-27 21:16:35 -0700265 data, err := ioutil.ReadFile(filename)
266 if err != nil {
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700267 return nil, err
Dan Willemsen2902fa72017-04-27 21:16:35 -0700268 }
269
270 var pom Pom
271 err = xml.Unmarshal(data, &pom)
272 if err != nil {
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700273 return nil, err
Dan Willemsen2902fa72017-04-27 21:16:35 -0700274 }
275
Dan Willemsen47e44a42017-10-05 13:28:16 -0700276 if useVersion != "" && pom.Version != useVersion {
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700277 return nil, nil
Dan Willemsen47e44a42017-10-05 13:28:16 -0700278 }
279
Dan Willemsen2902fa72017-04-27 21:16:35 -0700280 if pom.Packaging == "" {
281 pom.Packaging = "jar"
282 }
283
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700284 pom.PomFile = filename
Dan Willemsen2902fa72017-04-27 21:16:35 -0700285 pom.ArtifactFile = strings.TrimSuffix(filename, ".pom") + "." + pom.Packaging
286
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700287 return &pom, nil
Dan Willemsen2902fa72017-04-27 21:16:35 -0700288}
289
Colin Cross9f5633d2018-04-19 16:52:21 -0700290func rerunForRegen(filename string) error {
291 buf, err := ioutil.ReadFile(filename)
292 if err != nil {
293 return err
294 }
295
296 scanner := bufio.NewScanner(bytes.NewBuffer(buf))
297
298 // Skip the first line in the file
299 for i := 0; i < 2; i++ {
300 if !scanner.Scan() {
301 if scanner.Err() != nil {
302 return scanner.Err()
303 } else {
304 return fmt.Errorf("unexpected EOF")
305 }
306 }
307 }
308
309 // Extract the old args from the file
310 line := scanner.Text()
311 if strings.HasPrefix(line, "# pom2mk ") {
312 line = strings.TrimPrefix(line, "# pom2mk ")
313 } else {
314 return fmt.Errorf("unexpected second line: %q", line)
315 }
316 args := strings.Split(line, " ")
317 lastArg := args[len(args)-1]
318 args = args[:len(args)-1]
319
320 // Append all current command line args except -regen <file> to the ones from the file
321 for i := 1; i < len(os.Args); i++ {
322 if os.Args[i] == "-regen" {
323 i++
324 } else {
325 args = append(args, os.Args[i])
326 }
327 }
328 args = append(args, lastArg)
329
330 cmd := os.Args[0] + " " + strings.Join(args, " ")
331 // Re-exec pom2mk with the new arguments
332 output, err := exec.Command("/bin/sh", "-c", cmd).Output()
333 if exitErr, _ := err.(*exec.ExitError); exitErr != nil {
334 return fmt.Errorf("failed to run %s\n%s", cmd, string(exitErr.Stderr))
335 } else if err != nil {
336 return err
337 }
338
339 return ioutil.WriteFile(filename, output, 0666)
340}
341
Dan Willemsen2902fa72017-04-27 21:16:35 -0700342func main() {
343 flag.Usage = func() {
344 fmt.Fprintf(os.Stderr, `pom2mk, a tool to create Android.mk files from maven repos
345
346The tool will extract the necessary information from *.pom files to create an Android.mk whose
347aar libraries can be linked against when using AAPT2.
348
Colin Cross6b382bc2018-04-19 22:44:16 -0700349Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-deps <module>=<module>[,<module>]] [<dir>] [-regen <file>]
Dan Willemsen2902fa72017-04-27 21:16:35 -0700350
351 -rewrite <regex>=<replace>
Alan Viverette75b95f82017-12-04 16:24:07 -0500352 rewrite can be used to specify mappings between Maven projects and Make modules. The -rewrite
353 option can be specified multiple times. When determining the Make module for a given Maven
354 project, mappings are searched in the order they were specified. The first <regex> matching
355 either the Maven project's <groupId>:<artifactId> or <artifactId> will be used to generate
356 the Make module name using <replace>. If no matches are found, <artifactId> is used.
Colin Cross6b382bc2018-04-19 22:44:16 -0700357 -exclude <module>
358 Don't put the specified module in the makefile.
Dan Willemsen2902fa72017-04-27 21:16:35 -0700359 -extra-deps <module>=<module>[,<module>]
360 Some Android.mk modules have transitive dependencies that must be specified when they are
361 depended upon (like android-support-v7-mediarouter requires android-support-v7-appcompat).
362 This may be specified multiple times to declare these dependencies.
Dan Willemsen15a8e792017-11-10 14:02:44 -0800363 -sdk-version <version>
364 Sets LOCAL_SDK_VERSION := <version> for all modules.
Dan Willemsen47e44a42017-10-05 13:28:16 -0700365 -use-version <version>
366 If the maven directory contains multiple versions of artifacts and their pom files,
367 -use-version can be used to only write makefiles for a specific version of those artifacts.
Alan Viverette1593d3d2017-12-11 17:14:26 -0500368 -static-deps
369 Whether to statically include direct dependencies.
Dan Willemsen2902fa72017-04-27 21:16:35 -0700370 <dir>
371 The directory to search for *.pom files under.
Colin Cross9f5633d2018-04-19 16:52:21 -0700372 The makefile is written to stdout, to be put in the current directory (often as Android.mk)
373 -regen <file>
374 Read arguments from <file> and overwrite it.
Dan Willemsen2902fa72017-04-27 21:16:35 -0700375`, os.Args[0])
376 }
377
Colin Cross9f5633d2018-04-19 16:52:21 -0700378 var regen string
379
Colin Cross6b382bc2018-04-19 22:44:16 -0700380 flag.Var(&excludes, "exclude", "Exclude module")
Dan Willemsen2902fa72017-04-27 21:16:35 -0700381 flag.Var(&extraDeps, "extra-deps", "Extra dependencies needed when depending on a module")
382 flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names")
Dan Willemsen15a8e792017-11-10 14:02:44 -0800383 flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to LOCAL_SDK_VERSION")
Dan Willemsen47e44a42017-10-05 13:28:16 -0700384 flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
Alan Viverette1593d3d2017-12-11 17:14:26 -0500385 flag.BoolVar(&staticDeps, "static-deps", false, "Statically include direct dependencies")
Colin Cross9f5633d2018-04-19 16:52:21 -0700386 flag.StringVar(&regen, "regen", "", "Rewrite specified file")
Dan Willemsen2902fa72017-04-27 21:16:35 -0700387 flag.Parse()
388
Colin Cross9f5633d2018-04-19 16:52:21 -0700389 if regen != "" {
390 err := rerunForRegen(regen)
391 if err != nil {
392 fmt.Fprintln(os.Stderr, err)
393 os.Exit(1)
394 }
395 os.Exit(0)
396 }
397
398 if flag.NArg() == 0 {
399 fmt.Fprintln(os.Stderr, "Directory argument is required")
400 os.Exit(1)
401 } else if flag.NArg() > 1 {
402 fmt.Fprintln(os.Stderr, "Multiple directories provided:", strings.Join(flag.Args(), " "))
Dan Willemsen2902fa72017-04-27 21:16:35 -0700403 os.Exit(1)
404 }
405
406 dir := flag.Arg(0)
407 absDir, err := filepath.Abs(dir)
408 if err != nil {
Colin Crossf46e37f2018-03-21 16:25:58 -0700409 fmt.Fprintln(os.Stderr, "Failed to get absolute directory:", err)
Dan Willemsen2902fa72017-04-27 21:16:35 -0700410 os.Exit(1)
411 }
412
413 var filenames []string
414 err = filepath.Walk(absDir, func(path string, info os.FileInfo, err error) error {
415 if err != nil {
416 return err
417 }
418
419 name := info.Name()
420 if info.IsDir() {
421 if strings.HasPrefix(name, ".") {
422 return filepath.SkipDir
423 }
424 return nil
425 }
426
427 if strings.HasPrefix(name, ".") {
428 return nil
429 }
430
431 if strings.HasSuffix(name, ".pom") {
432 path, err = filepath.Rel(absDir, path)
433 if err != nil {
434 return err
435 }
436 filenames = append(filenames, filepath.Join(dir, path))
437 }
438 return nil
439 })
440 if err != nil {
441 fmt.Fprintln(os.Stderr, "Error walking files:", err)
442 os.Exit(1)
443 }
444
445 if len(filenames) == 0 {
446 fmt.Fprintln(os.Stderr, "Error: no *.pom files found under", dir)
447 os.Exit(1)
448 }
449
450 sort.Strings(filenames)
451
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700452 poms := []*Pom{}
453 modules := make(map[string]*Pom)
Jeff Gastonaf2191e2018-03-29 14:59:01 -0400454 duplicate := false
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700455 for _, filename := range filenames {
456 pom, err := parse(filename)
457 if err != nil {
458 fmt.Fprintln(os.Stderr, "Error converting", filename, err)
459 os.Exit(1)
460 }
461
462 if pom != nil {
Alan Viverette75b95f82017-12-04 16:24:07 -0500463 key := pom.MkName()
Colin Cross6b382bc2018-04-19 22:44:16 -0700464 if excludes[key] {
465 continue
466 }
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700467
Alan Viverette75b95f82017-12-04 16:24:07 -0500468 if old, ok := modules[key]; ok {
469 fmt.Fprintln(os.Stderr, "Module", key, "defined twice:", old.PomFile, pom.PomFile)
Jeff Gastonaf2191e2018-03-29 14:59:01 -0400470 duplicate = true
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700471 }
472
Colin Cross6b382bc2018-04-19 22:44:16 -0700473 poms = append(poms, pom)
Alan Viverette75b95f82017-12-04 16:24:07 -0500474 modules[key] = pom
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700475 }
476 }
Jeff Gastonaf2191e2018-03-29 14:59:01 -0400477 if duplicate {
478 os.Exit(1)
479 }
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700480
481 for _, pom := range poms {
Alan Viverette6bd35eb2018-02-13 13:25:24 -0500482 pom.FixDeps(modules)
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700483 }
484
Dan Willemsen2902fa72017-04-27 21:16:35 -0700485 fmt.Println("# Automatically generated with:")
Colin Cross0b9f31f2019-02-28 11:00:01 -0800486 fmt.Println("# pom2mk", strings.Join(proptools.ShellEscapeList(os.Args[1:]), " "))
Dan Willemsen2902fa72017-04-27 21:16:35 -0700487 fmt.Println("LOCAL_PATH := $(call my-dir)")
488
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700489 for _, pom := range poms {
Alan Viverette1593d3d2017-12-11 17:14:26 -0500490 var err error
491 if staticDeps {
492 err = mkDepsTemplate.Execute(os.Stdout, pom)
493 } else {
494 err = mkTemplate.Execute(os.Stdout, pom)
495 }
Dan Willemsen2902fa72017-04-27 21:16:35 -0700496 if err != nil {
Dan Willemsen5f9d8a62017-10-05 14:01:31 -0700497 fmt.Fprintln(os.Stderr, "Error writing", pom.PomFile, pom.MkName(), err)
Dan Willemsen2902fa72017-04-27 21:16:35 -0700498 os.Exit(1)
499 }
500 }
501}