Merge "Add jetifier support in Soong."
This commit is contained in:
12
java/aar.go
12
java/aar.go
@@ -375,6 +375,9 @@ type AARImportProperties struct {
|
|||||||
|
|
||||||
Static_libs []string
|
Static_libs []string
|
||||||
Libs []string
|
Libs []string
|
||||||
|
|
||||||
|
// if set to true, run Jetifier against .aar file. Defaults to false.
|
||||||
|
Jetifier_enabled *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type AARImport struct {
|
type AARImport struct {
|
||||||
@@ -456,7 +459,14 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
return
|
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")
|
extractedAARDir := android.PathForModuleOut(ctx, "aar")
|
||||||
extractedResDir := extractedAARDir.Join(ctx, "res")
|
extractedResDir := extractedAARDir.Join(ctx, "res")
|
||||||
|
@@ -121,6 +121,13 @@ var (
|
|||||||
CommandDeps: []string{"${config.JavaCmd}", "${config.JarjarCmd}", "$rulesFile"},
|
CommandDeps: []string{"${config.JavaCmd}", "${config.JarjarCmd}", "$rulesFile"},
|
||||||
},
|
},
|
||||||
"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() {
|
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
|
type classpath []android.Path
|
||||||
|
|
||||||
func (x *classpath) FormJavaClassPath(optName string) string {
|
func (x *classpath) FormJavaClassPath(optName string) string {
|
||||||
|
@@ -123,6 +123,7 @@ func init() {
|
|||||||
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
||||||
pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar")
|
pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar")
|
||||||
pctx.HostJavaToolVariable("DokkaJar", "dokka.jar")
|
pctx.HostJavaToolVariable("DokkaJar", "dokka.jar")
|
||||||
|
pctx.HostJavaToolVariable("JetifierJar", "jetifier.jar")
|
||||||
|
|
||||||
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
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)
|
// List of directories to remove from the jar file(s)
|
||||||
Exclude_dirs []string
|
Exclude_dirs []string
|
||||||
|
|
||||||
|
// if set to true, run Jetifier against .jar file. Defaults to false.
|
||||||
|
Jetifier_enabled *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Import struct {
|
type Import struct {
|
||||||
@@ -1622,9 +1625,15 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
jars := ctx.ExpandSources(j.properties.Jars, nil)
|
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{},
|
TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{},
|
||||||
false, j.properties.Exclude_files, j.properties.Exclude_dirs)
|
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
|
j.combinedClasspathFile = outputFile
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
|
Reference in New Issue
Block a user