aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-07-18 17:00:45 +0900
committerJiyong Park <jiyong@google.com>2019-07-23 20:32:14 +0900
commitaa53324ac8308d974435cf2c8566835b87e3e05d (patch)
tree61c0c20ed58c5469c5d672671c775fdd06918d4f /java
parent1ecfa940d1fefdeab2df661778498b64bf81d8bb (diff)
downloadbuild_soong-aa53324ac8308d974435cf2c8566835b87e3e05d.tar.gz
build_soong-aa53324ac8308d974435cf2c8566835b87e3e05d.tar.bz2
build_soong-aa53324ac8308d974435cf2c8566835b87e3e05d.zip
Split Java libraries per apex
Just like native libs, a java library that is included in an APEX is mutated for the APEX. This allows us to infer the context (e.g. sdk_version, etc.) for building a java library in an APEX. Bug: 138182343 Test: apex_test added Change-Id: I9292ea097b98e74a8a794f164bd2bed3921d6337
Diffstat (limited to 'java')
-rw-r--r--java/androidmk.go15
-rw-r--r--java/hiddenapi_singleton.go8
-rw-r--r--java/java.go11
3 files changed, 33 insertions, 1 deletions
diff --git a/java/androidmk.go b/java/androidmk.go
index 90fdd0f7..ad0e171f 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -55,6 +55,11 @@ func (library *Library) AndroidMkHostDex(w io.Writer, name string, data android.
}
func (library *Library) AndroidMk() android.AndroidMkData {
+ if !library.IsForPlatform() {
+ return android.AndroidMkData{
+ Disabled: true,
+ }
+ }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(library.outputFile),
@@ -141,6 +146,11 @@ func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
}
func (prebuilt *Import) AndroidMk() android.AndroidMkData {
+ if !prebuilt.IsForPlatform() {
+ return android.AndroidMkData{
+ Disabled: true,
+ }
+ }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
@@ -157,6 +167,11 @@ func (prebuilt *Import) AndroidMk() android.AndroidMkData {
}
func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
+ if !prebuilt.IsForPlatform() {
+ return android.AndroidMkData{
+ Disabled: true,
+ }
+ }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index c83dda14..8379f539 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -152,6 +152,14 @@ func stubFlagsRule(ctx android.SingletonContext) {
// Collect dex jar paths for modules that had hiddenapi encode called on them.
if h, ok := module.(hiddenAPIIntf); ok {
if jar := h.bootDexJar(); jar != nil {
+ // For a java lib included in an APEX, only take the one built for
+ // the platform variant, and skip the variants for APEXes.
+ // Otherwise, the hiddenapi tool will complain about duplicated classes
+ if a, ok := module.(android.ApexModule); ok {
+ if android.InAnyApex(module.Name()) && !a.IsForPlatform() {
+ return
+ }
+ }
bootDexJars = append(bootDexJars, jar)
}
}
diff --git a/java/java.go b/java/java.go
index f3e10beb..ca6e232b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -267,6 +267,7 @@ func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
type Module struct {
android.ModuleBase
android.DefaultableModuleBase
+ android.ApexModuleBase
properties CompilerProperties
protoProperties android.ProtoProperties
@@ -1581,6 +1582,7 @@ func LibraryFactory() android.Module {
&module.Module.protoProperties)
InitJavaModule(module, android.HostAndDeviceSupported)
+ android.InitApexModule(module)
return module
}
@@ -1603,6 +1605,7 @@ func LibraryHostFactory() android.Module {
module.Module.properties.Installable = proptools.BoolPtr(true)
InitJavaModule(module, android.HostSupported)
+ android.InitApexModule(module)
return module
}
@@ -1858,6 +1861,7 @@ type ImportProperties struct {
type Import struct {
android.ModuleBase
android.DefaultableModuleBase
+ android.ApexModuleBase
prebuilt android.Prebuilt
properties ImportProperties
@@ -2014,6 +2018,7 @@ func ImportFactory() android.Module {
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.HostAndDeviceSupported)
+ android.InitApexModule(module)
return module
}
@@ -2029,6 +2034,7 @@ func ImportFactoryHost() android.Module {
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.HostSupported)
+ android.InitApexModule(module)
return module
}
@@ -2041,6 +2047,7 @@ type DexImportProperties struct {
type DexImport struct {
android.ModuleBase
android.DefaultableModuleBase
+ android.ApexModuleBase
prebuilt android.Prebuilt
properties DexImportProperties
@@ -2132,6 +2139,7 @@ func DexImportFactory() android.Module {
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.DeviceSupported)
+ android.InitApexModule(module)
return module
}
@@ -2141,6 +2149,7 @@ func DexImportFactory() android.Module {
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
+ android.ApexModuleBase
}
// java_defaults provides a set of properties that can be inherited by other java or android modules.
@@ -2199,7 +2208,7 @@ func DefaultsFactory(props ...interface{}) android.Module {
)
android.InitDefaultsModule(module)
-
+ android.InitApexModule(module)
return module
}