pom2mk: Add a flag to specify a specific version of artifacts

For repositories that contain multiple versions of the same artifact,
we'd only like to create makefiles for one of the versions of the
artifact.

Bug: 64723465
Test: cd prebuilts/maven_repo/android; pom2mk -use-version 25.3.1 com/android/support
Change-Id: I5bdbba8d2143a47610d56d679381eb01b3cf176d
diff --git a/cmd/pom2mk/pom2mk.go b/cmd/pom2mk/pom2mk.go
index e6144a5..a2297f4 100644
--- a/cmd/pom2mk/pom2mk.go
+++ b/cmd/pom2mk/pom2mk.go
@@ -84,6 +84,8 @@
 
 var extraDeps = make(ExtraDeps)
 
+var useVersion string
+
 type Dependency struct {
 	XMLName xml.Name `xml:"dependency"`
 
@@ -152,6 +154,10 @@
 		return err
 	}
 
+	if useVersion != "" && pom.Version != useVersion {
+		return nil
+	}
+
 	if pom.Packaging == "" {
 		pom.Packaging = "jar"
 	}
@@ -178,6 +184,9 @@
      Some Android.mk modules have transitive dependencies that must be specified when they are
      depended upon (like android-support-v7-mediarouter requires android-support-v7-appcompat).
      This may be specified multiple times to declare these dependencies.
+  -use-version <version>
+     If the maven directory contains multiple versions of artifacts and their pom files,
+     -use-version can be used to only write makefiles for a specific version of those artifacts.
   <dir>
      The directory to search for *.pom files under.
 
@@ -187,6 +196,7 @@
 
 	flag.Var(&extraDeps, "extra-deps", "Extra dependencies needed when depending on a module")
 	flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names")
+	flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
 	flag.Parse()
 
 	if flag.NArg() != 1 {