Merge "Add jetifier support in Soong."
am: b69575b1f6
Change-Id: I9f7c95114c8aeece111de86790035b1d7165454f
This commit is contained in:
commit
2c44285377
12
java/aar.go
12
java/aar.go
|
@ -375,6 +375,9 @@ type AARImportProperties struct {
|
|||
|
||||
Static_libs []string
|
||||
Libs []string
|
||||
|
||||
// if set to true, run Jetifier against .aar file. Defaults to false.
|
||||
Jetifier_enabled *bool
|
||||
}
|
||||
|
||||
type AARImport struct {
|
||||
|
@ -456,7 +459,14 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
return
|
||||
}
|
||||
|
||||
aar := android.PathForModuleSrc(ctx, a.properties.Aars[0])
|
||||
aarName := ctx.ModuleName() + ".aar"
|
||||
var aar android.Path
|
||||
aar = android.PathForModuleSrc(ctx, a.properties.Aars[0])
|
||||
if Bool(a.properties.Jetifier_enabled) {
|
||||
inputFile := aar
|
||||
aar = android.PathForModuleOut(ctx, "jetifier", aarName)
|
||||
TransformJetifier(ctx, aar.(android.WritablePath), inputFile)
|
||||
}
|
||||
|
||||
extractedAARDir := android.PathForModuleOut(ctx, "aar")
|
||||
extractedResDir := extractedAARDir.Join(ctx, "res")
|
||||
|
|
|
@ -121,6 +121,13 @@ var (
|
|||
CommandDeps: []string{"${config.JavaCmd}", "${config.JarjarCmd}", "$rulesFile"},
|
||||
},
|
||||
"rulesFile")
|
||||
|
||||
jetifier = pctx.AndroidStaticRule("jetifier",
|
||||
blueprint.RuleParams{
|
||||
Command: "${config.JavaCmd} -jar ${config.JetifierJar} -l error -o $out -i $in",
|
||||
CommandDeps: []string{"${config.JavaCmd}", "${config.JetifierJar}"},
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -371,6 +378,16 @@ func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||
})
|
||||
}
|
||||
|
||||
func TransformJetifier(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
inputFile android.Path) {
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: jetifier,
|
||||
Description: "jetifier",
|
||||
Output: outputFile,
|
||||
Input: inputFile,
|
||||
})
|
||||
}
|
||||
|
||||
type classpath []android.Path
|
||||
|
||||
func (x *classpath) FormJavaClassPath(optName string) string {
|
||||
|
|
|
@ -123,6 +123,7 @@ func init() {
|
|||
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
||||
pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar")
|
||||
pctx.HostJavaToolVariable("DokkaJar", "dokka.jar")
|
||||
pctx.HostJavaToolVariable("JetifierJar", "jetifier.jar")
|
||||
|
||||
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
||||
|
||||
|
|
11
java/java.go
11
java/java.go
|
@ -1582,6 +1582,9 @@ type ImportProperties struct {
|
|||
|
||||
// List of directories to remove from the jar file(s)
|
||||
Exclude_dirs []string
|
||||
|
||||
// if set to true, run Jetifier against .jar file. Defaults to false.
|
||||
Jetifier_enabled *bool
|
||||
}
|
||||
|
||||
type Import struct {
|
||||
|
@ -1622,9 +1625,15 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
jars := ctx.ExpandSources(j.properties.Jars, nil)
|
||||
|
||||
outputFile := android.PathForModuleOut(ctx, "classes.jar")
|
||||
jarName := ctx.ModuleName() + ".jar"
|
||||
outputFile := android.PathForModuleOut(ctx, "combined", jarName)
|
||||
TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{},
|
||||
false, j.properties.Exclude_files, j.properties.Exclude_dirs)
|
||||
if Bool(j.properties.Jetifier_enabled) {
|
||||
inputFile := outputFile
|
||||
outputFile = android.PathForModuleOut(ctx, "jetifier", jarName)
|
||||
TransformJetifier(ctx, outputFile, inputFile)
|
||||
}
|
||||
j.combinedClasspathFile = outputFile
|
||||
|
||||
ctx.VisitDirectDeps(func(module android.Module) {
|
||||
|
|
Loading…
Reference in New Issue