aboutsummaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go86
1 files changed, 27 insertions, 59 deletions
diff --git a/java/java.go b/java/java.go
index 7bf9fac1a..ad10cbd77 100644
--- a/java/java.go
+++ b/java/java.go
@@ -21,7 +21,6 @@ package java
import (
"fmt"
"path/filepath"
- "slices"
"sort"
"strings"
@@ -2338,9 +2337,6 @@ type ImportProperties struct {
// List of shared java libs that this module has dependencies to
Libs []string
- // List of static java libs that this module has dependencies to
- Static_libs []string
-
// List of files to remove from the jar file(s)
Exclude_files []string
@@ -2393,10 +2389,9 @@ type Import struct {
dexJarFileErr error
dexJarInstallFile android.Path
- combinedImplementationFile android.Path
- combinedHeaderFile android.Path
- classLoaderContexts dexpreopt.ClassLoaderContextMap
- exportAidlIncludeDirs android.Paths
+ combinedClasspathFile android.Path
+ classLoaderContexts dexpreopt.ClassLoaderContextMap
+ exportAidlIncludeDirs android.Paths
hideApexVariantFromMake bool
@@ -2480,7 +2475,6 @@ func (j *Import) setStrictUpdatabilityLinting(bool) {
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
- ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
if ctx.Device() && Bool(j.dexProperties.Compile_dex) {
sdkDeps(ctx, android.SdkContext(j), j.dexer)
@@ -2510,13 +2504,23 @@ func (j *Import) commonBuildActions(ctx android.ModuleContext) {
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.commonBuildActions(ctx)
+ jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
+
+ jarName := j.Stem() + ".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) {
+ inputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "jetifier", jarName)
+ TransformJetifier(ctx, outputFile, inputFile)
+ }
+ j.combinedClasspathFile = outputFile
j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
var flags javaBuilderFlags
j.collectTransitiveHeaderJars(ctx)
- var staticJars android.Paths
- var staticHeaderJars android.Paths
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
@@ -2526,8 +2530,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
flags.dexClasspath = append(flags.dexClasspath, dep.HeaderJars...)
case staticLibTag:
flags.classpath = append(flags.classpath, dep.HeaderJars...)
- staticJars = append(staticJars, dep.ImplementationAndResourcesJars...)
- staticHeaderJars = append(staticHeaderJars, dep.HeaderJars...)
case bootClasspathTag:
flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars...)
}
@@ -2541,46 +2543,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
addCLCFromDep(ctx, module, j.classLoaderContexts)
})
- jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
- jarName := j.Stem() + ".jar"
-
- // Always pass the input jars to TransformJarsToJar, even if there is only a single jar, we need the output
- // file of the module to be named jarName.
- outputFile := android.PathForModuleOut(ctx, "combined", jarName)
- implementationJars := append(slices.Clone(jars), staticJars...)
- TransformJarsToJar(ctx, outputFile, "combine prebuilt implementation jars", implementationJars, android.OptionalPath{},
- false, j.properties.Exclude_files, j.properties.Exclude_dirs)
-
- // If no dependencies have separate header jars then there is no need to create a separate
- // header jar for this module.
- reuseImplementationJarAsHeaderJar := slices.Equal(staticJars, staticHeaderJars)
-
- var headerOutputFile android.WritablePath
- if reuseImplementationJarAsHeaderJar {
- headerOutputFile = outputFile
- } else {
- headerJars := append(slices.Clone(jars), staticHeaderJars...)
- headerOutputFile = android.PathForModuleOut(ctx, "turbine-combined", jarName)
- TransformJarsToJar(ctx, headerOutputFile, "combine prebuilt header jars", headerJars, android.OptionalPath{},
- false, j.properties.Exclude_files, j.properties.Exclude_dirs)
- }
-
- if Bool(j.properties.Jetifier) {
- inputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "jetifier", jarName)
- TransformJetifier(ctx, outputFile, inputFile)
-
- if !reuseImplementationJarAsHeaderJar {
- headerInputFile := headerOutputFile
- headerOutputFile = android.PathForModuleOut(ctx, "jetifier-headers", jarName)
- TransformJetifier(ctx, headerOutputFile, headerInputFile)
- } else {
- headerOutputFile = outputFile
- }
- }
- j.combinedHeaderFile = headerOutputFile
- j.combinedImplementationFile = outputFile
-
j.maybeInstall(ctx, jarName, outputFile)
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
@@ -2664,11 +2626,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
- HeaderJars: android.PathsIfNonNil(j.combinedHeaderFile),
+ HeaderJars: android.PathsIfNonNil(j.combinedClasspathFile),
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
- ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedImplementationFile),
- ImplementationJars: android.PathsIfNonNil(j.combinedImplementationFile),
+ ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile),
+ ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile),
AidlIncludeDirs: j.exportAidlIncludeDirs,
StubsLinkType: j.stubsLinkType,
// TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
@@ -2696,7 +2658,7 @@ func (j *Import) maybeInstall(ctx android.ModuleContext, jarName string, outputF
func (j *Import) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "", ".jar":
- return android.Paths{j.combinedImplementationFile}, nil
+ return android.Paths{j.combinedClasspathFile}, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
@@ -2705,11 +2667,17 @@ func (j *Import) OutputFiles(tag string) (android.Paths, error) {
var _ android.OutputFileProducer = (*Import)(nil)
func (j *Import) HeaderJars() android.Paths {
- return android.PathsIfNonNil(j.combinedHeaderFile)
+ if j.combinedClasspathFile == nil {
+ return nil
+ }
+ return android.Paths{j.combinedClasspathFile}
}
func (j *Import) ImplementationAndResourcesJars() android.Paths {
- return android.PathsIfNonNil(j.combinedImplementationFile)
+ if j.combinedClasspathFile == nil {
+ return nil
+ }
+ return android.Paths{j.combinedClasspathFile}
}
func (j *Import) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {