aboutsummaryrefslogtreecommitdiffstats
path: root/java/builder.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-09-12 22:50:46 -0700
committerColin Cross <ccross@android.com>2017-09-20 13:20:45 -0700
commit635acc9446c3a8c88b6599d30312c6399419f2b8 (patch)
treef46d048da7c2ac22272bcfb8f792a3db56997b80 /java/builder.go
parent6eebec7414cb5940725c91bc03261c7de838b9e0 (diff)
downloadbuild_soong-635acc9446c3a8c88b6599d30312c6399419f2b8.tar.gz
build_soong-635acc9446c3a8c88b6599d30312c6399419f2b8.tar.bz2
build_soong-635acc9446c3a8c88b6599d30312c6399419f2b8.zip
Rearrange manifest file handling in merge_zips and soong_zip
Jar always puts default MANIFEST.MF files in if none was specified. Copying that behavior in soong_zip causes problems with merge_zips, because it ends up taking the default manifest from the classes.jar instead of the user's manifest from res.jar. We don't want the user's manifest in the classes.jar, otherwise a change to the manifest will cause all the class files to rebuild. Instead, move the manifest insertion to the final merge_zips stage. Test: m -j checkbuild Change-Id: Id6376961dbaf743c2fb92843f9bdf2e44b963be0
Diffstat (limited to 'java/builder.go')
-rw-r--r--java/builder.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/java/builder.go b/java/builder.go
index d6f8c5bd..cf6ab6b5 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -78,10 +78,10 @@ var (
combineJar = pctx.AndroidStaticRule("combineJar",
blueprint.RuleParams{
- Command: `${config.MergeZipsCmd} -j $out $in`,
+ Command: `${config.MergeZipsCmd} -j $jarArgs $out $in`,
CommandDeps: []string{"${config.MergeZipsCmd}"},
},
- "outDir")
+ "jarArgs")
dx = pctx.AndroidStaticRule("dx",
blueprint.RuleParams{
@@ -126,7 +126,7 @@ func TransformJavaToClasses(ctx android.ModuleContext, srcFiles, srcFileLists an
classDir := android.PathForModuleOut(ctx, "classes")
annoDir := android.PathForModuleOut(ctx, "anno")
- classJar := android.PathForModuleOut(ctx, "classes.jar")
+ classJar := android.PathForModuleOut(ctx, "classes-compiled.jar")
javacFlags := flags.javacFlags + android.JoinWithPrefix(srcFileLists.Strings(), "@")
@@ -187,7 +187,7 @@ func RunErrorProne(ctx android.ModuleContext, srcFiles android.Paths, srcFileLis
}
func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
- manifest android.OptionalPath, deps android.Paths) android.Path {
+ deps android.Paths) android.Path {
outputFile := android.PathForModuleOut(ctx, "res.jar")
@@ -198,11 +198,6 @@ func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
jarArgs = append(jarArgs, j.soongJarArgs())
}
- if manifest.Valid() {
- deps = append(deps, manifest.Path())
- jarArgs = append(jarArgs, "-m "+manifest.String())
- }
-
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: jar,
Description: "jar",
@@ -216,19 +211,36 @@ func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
return outputFile
}
-func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Paths) android.Path {
+func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Paths,
+ manifest android.OptionalPath, stripDirs bool) android.Path {
outputFile := android.PathForModuleOut(ctx, stem)
- if len(jars) == 1 {
+ if len(jars) == 1 && !manifest.Valid() {
return jars[0]
}
+ var deps android.Paths
+
+ var jarArgs []string
+ if manifest.Valid() {
+ jarArgs = append(jarArgs, "-m "+manifest.String())
+ deps = append(deps, manifest.Path())
+ }
+
+ if stripDirs {
+ jarArgs = append(jarArgs, "-D")
+ }
+
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: combineJar,
Description: "combine jars",
Output: outputFile,
Inputs: jars,
+ Implicits: deps,
+ Args: map[string]string{
+ "jarArgs": strings.Join(jarArgs, " "),
+ },
})
return outputFile