diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/builder.go | 1 | ||||
-rw-r--r-- | java/dex.go | 2 | ||||
-rw-r--r-- | java/java.go | 36 |
3 files changed, 25 insertions, 14 deletions
diff --git a/java/builder.go b/java/builder.go index 55be3a6b..4bdea283 100644 --- a/java/builder.go +++ b/java/builder.go @@ -125,6 +125,7 @@ var ( ) func init() { + pctx.Import("android/soong/common") pctx.Import("android/soong/java/config") } diff --git a/java/dex.go b/java/dex.go index 8363a7db..d0ca06e4 100644 --- a/java/dex.go +++ b/java/dex.go @@ -140,7 +140,7 @@ func (j *Module) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8F } func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, - classesJar android.Path, jarName string) android.Path { + classesJar android.Path, jarName string) android.ModuleOutPath { useR8 := Bool(j.deviceProperties.Optimize.Enabled) diff --git a/java/java.go b/java/java.go index b183e2ba..43af2c6b 100644 --- a/java/java.go +++ b/java/java.go @@ -300,7 +300,7 @@ type Module struct { } func (j *Module) Srcs() android.Paths { - return android.Paths{j.implementationJarFile} + return android.Paths{j.outputFile} } var _ android.SourceFileProducer = (*Module)(nil) @@ -1152,14 +1152,24 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path // Combine the classes built from sources, any manifests, and any static libraries into // classes.jar. If there is only one input jar this step will be skipped. - var outputFile android.Path + var outputFile android.ModuleOutPath if len(jars) == 1 && !manifest.Valid() { - // Optimization: skip the combine step if there is nothing to do - // TODO(ccross): this leaves any module-info.class files, but those should only come from - // prebuilt dependencies until we support modules in the platform build, so there shouldn't be - // any if len(jars) == 1. - outputFile = jars[0] + if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok { + // Optimization: skip the combine step if there is nothing to do + // TODO(ccross): this leaves any module-info.class files, but those should only come from + // prebuilt dependencies until we support modules in the platform build, so there shouldn't be + // any if len(jars) == 1. + outputFile = moduleOutPath + } else { + combinedJar := android.PathForModuleOut(ctx, "combined", jarName) + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Input: jars[0], + Output: combinedJar, + }) + outputFile = combinedJar + } } else { combinedJar := android.PathForModuleOut(ctx, "combined", jarName) TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest, @@ -1204,17 +1214,17 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path } if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { - var dexOutputFile android.Path + var dexOutputFile android.ModuleOutPath dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName) if ctx.Failed() { return } - if Bool(j.properties.Installable) { - outputFile = dexOutputFile - } + outputFile = dexOutputFile } ctx.CheckbuildFile(outputFile) - j.outputFile = outputFile + + // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource + j.outputFile = outputFile.WithoutRel() } func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths, @@ -1258,7 +1268,7 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars } func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags, - classesJar android.Path, jarName string) android.Path { + classesJar android.Path, jarName string) android.ModuleOutPath { specs := j.jacocoModuleToZipCommand(ctx) |