Add -jetifier to pom2mk and pom2bp
Test: use pom2mk -jetifier to replace some hand-modified makefiles Change-Id: I2a1988d0120fee1edf2d85c8b3294041840efe7c
This commit is contained in:
parent
7f276c6b77
commit
7fdab6eeec
2 changed files with 22 additions and 2 deletions
|
@ -126,6 +126,7 @@ var hostModuleNames = HostModuleNames{}
|
|||
|
||||
var sdkVersion string
|
||||
var useVersion string
|
||||
var jetifier bool
|
||||
|
||||
func InList(s string, list []string) bool {
|
||||
for _, l := range list {
|
||||
|
@ -257,6 +258,10 @@ func (p Pom) SdkVersion() string {
|
|||
return sdkVersion
|
||||
}
|
||||
|
||||
func (p Pom) Jetifier() bool {
|
||||
return jetifier
|
||||
}
|
||||
|
||||
func (p *Pom) FixDeps(modules map[string]*Pom) {
|
||||
for _, d := range p.Dependencies {
|
||||
if d.Type == "" {
|
||||
|
@ -331,6 +336,9 @@ var bpTemplate = template.Must(template.New("bp").Parse(`
|
|||
name: "{{.BpName}}-nodeps",
|
||||
{{.ImportProperty}}: ["{{.ArtifactFile}}"],
|
||||
sdk_version: "{{.SdkVersion}}",
|
||||
{{- if .Jetifier}}
|
||||
jetifier: true,
|
||||
{{- end}}
|
||||
{{- if .IsAar}}
|
||||
min_sdk_version: "{{.MinSdkVersion}}",
|
||||
static_libs: [
|
||||
|
@ -500,10 +508,12 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-static-libs
|
|||
are depended upon (like androidx.test.rules requires android.test.base).
|
||||
This may be specified multiple times to declare these dependencies.
|
||||
-sdk-version <version>
|
||||
Sets LOCAL_SDK_VERSION := <version> for all modules.
|
||||
Sets sdk_version: "<version>" for all modules.
|
||||
-use-version <version>
|
||||
If the maven directory contains multiple versions of artifacts and their pom files,
|
||||
-use-version can be used to only write Android.bp files for a specific version of those artifacts.
|
||||
-jetifier
|
||||
Sets jetifier: true for all modules.
|
||||
<dir>
|
||||
The directory to search for *.pom files under.
|
||||
The contents are written to stdout, to be put in the current directory (often as Android.bp)
|
||||
|
@ -521,8 +531,9 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-static-libs
|
|||
flag.Var(&extraLibs, "extra-libs", "Extra runtime dependencies needed when depending on a module")
|
||||
flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names")
|
||||
flag.Var(&hostModuleNames, "host", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is a host module")
|
||||
flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to LOCAL_SDK_VERSION")
|
||||
flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to sdk_version")
|
||||
flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
|
||||
flag.BoolVar(&jetifier, "jetifier", false, "Sets jetifier: true on all modules")
|
||||
flag.Bool("static-deps", false, "Ignored")
|
||||
flag.StringVar(®en, "regen", "", "Rewrite specified file")
|
||||
flag.Parse()
|
||||
|
|
|
@ -104,6 +104,7 @@ var excludes = make(Exclude)
|
|||
var sdkVersion string
|
||||
var useVersion string
|
||||
var staticDeps bool
|
||||
var jetifier bool
|
||||
|
||||
func InList(s string, list []string) bool {
|
||||
for _, l := range list {
|
||||
|
@ -195,6 +196,10 @@ func (p Pom) SdkVersion() string {
|
|||
return sdkVersion
|
||||
}
|
||||
|
||||
func (p Pom) Jetifier() bool {
|
||||
return jetifier
|
||||
}
|
||||
|
||||
func (p *Pom) FixDeps(modules map[string]*Pom) {
|
||||
for _, d := range p.Dependencies {
|
||||
if d.Type == "" {
|
||||
|
@ -229,6 +234,7 @@ LOCAL_STATIC_JAVA_LIBRARIES :={{range .MkJarDeps}} \
|
|||
{{.}}{{end}}
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES :={{range .MkAarDeps}} \
|
||||
{{.}}{{end}}
|
||||
LOCAL_JETIFIER_ENABLED := {{if .Jetifier}}true{{end}}
|
||||
include $(BUILD_PREBUILT)
|
||||
`))
|
||||
|
||||
|
@ -367,6 +373,8 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-deps <modul
|
|||
-use-version can be used to only write makefiles for a specific version of those artifacts.
|
||||
-static-deps
|
||||
Whether to statically include direct dependencies.
|
||||
-jetifier
|
||||
Enable jetifier in order to use androidx
|
||||
<dir>
|
||||
The directory to search for *.pom files under.
|
||||
The makefile is written to stdout, to be put in the current directory (often as Android.mk)
|
||||
|
@ -383,6 +391,7 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-deps <modul
|
|||
flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to LOCAL_SDK_VERSION")
|
||||
flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
|
||||
flag.BoolVar(&staticDeps, "static-deps", false, "Statically include direct dependencies")
|
||||
flag.BoolVar(&jetifier, "jetifier", false, "Enable jetifier in order to use androidx")
|
||||
flag.StringVar(®en, "regen", "", "Rewrite specified file")
|
||||
flag.Parse()
|
||||
|
||||
|
|
Loading…
Reference in a new issue