summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2022-06-23 10:46:28 -0700
committer Bob Badour <bbadour@google.com> 2022-06-23 18:05:47 +0000
commit61fb62e5e3c6959c3d64bc9a22c79d2a345d7653 (patch)
treed357d81d526693cd10dcb2f0c3ff99b40ab3df41 /java
parent2ff57f9d00b4e34ba488e3216496a8429d7384a5 (diff)
Move embedded notice file path above aapt rule generation
The embedded notice file generation for apps was moved below the aapt rules, which meant the added asset path was ignored. Move the code to pick the notice file path selection back above the aapt rules, and leave the code to generate the notice file rule where it is. Bug: 236006463 Test: m NetworkStack ALWAYS_EMBED_NOTICES=true Change-Id: I1421fb0dbcdb759281259abfae7bddc9aecdaa56 Merged-in: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
Diffstat (limited to 'java')
-rwxr-xr-xjava/app.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/java/app.go b/java/app.go
index c5d88e978..8ff5d91c2 100755
--- a/java/app.go
+++ b/java/app.go
@@ -583,6 +583,16 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ var noticeAssetPath android.WritablePath
+ if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
+ // The rule to create the notice file can't be generated yet, as the final output path
+ // for the apk isn't known yet. Add the path where the notice file will be generated to the
+ // aapt rules now before calling aaptBuildActions, the rule to create the notice file will
+ // be generated later.
+ noticeAssetPath = android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
+ a.aapt.noticeFile = android.OptionalPathForPath(noticeAssetPath)
+ }
+
// Process all building blocks, from AAPT to certificates.
a.aaptBuildActions(ctx)
@@ -654,7 +664,8 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
}
- if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
+ if a.aapt.noticeFile.Valid() {
+ // Generating the notice file rule has to be here after a.outputFile is known.
noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
android.BuildNoticeHtmlOutputFromLicenseMetadata(
ctx, noticeFile, "", "",
@@ -663,13 +674,11 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
android.PathForModuleInstall(ctx).String() + "/",
a.outputFile.String(),
})
- noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Text("cp").
Input(noticeFile).
Output(noticeAssetPath)
builder.Build("notice_dir", "Building notice dir")
- a.aapt.noticeFile = android.OptionalPathForPath(noticeAssetPath)
}
for _, split := range a.aapt.splits {