Support non-installable java libraries
Some java libraries will never be installed, support an
installable: false property and export it back to make as
LOCAL_UNINSTALLABLE_MODULE := true.
Test: m -j checkbuild, manually inspect out/soong/Android*.mk
Change-Id: I825ec897648c82fb7323da7df3539c9aaa6bcfce
diff --git a/java/androidmk.go b/java/androidmk.go
index 12643cf..c383a0e 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -29,6 +29,9 @@
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
+ if library.properties.Installable != nil && *library.properties.Installable == false {
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ }
},
},
}
@@ -41,6 +44,7 @@
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
},
},
}
diff --git a/java/java.go b/java/java.go
index a8093e7..7b213b2 100644
--- a/java/java.go
+++ b/java/java.go
@@ -96,6 +96,9 @@
// If not blank, set the java version passed to javac as -source and -target
Java_version *string
+
+ // If set to false, don't allow this module to be installed. Defaults to true.
+ Installable *bool
}
type CompilerDeviceProperties struct {
@@ -473,7 +476,10 @@
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.compile(ctx)
- j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
+ if j.properties.Installable == nil || *j.properties.Installable == true {
+ j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
+ ctx.ModuleName()+".jar", j.outputFile)
+ }
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -605,9 +611,6 @@
}
j.combinedClasspathFile = TransformClassesToJar(ctx, j.classJarSpecs, android.OptionalPath{}, nil)
-
- ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
- ctx.ModuleName()+".jar", j.combinedClasspathFile)
}
var _ Dependency = (*Import)(nil)