summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/java/java.go b/java/java.go
index beee1a5b5..bf62578f8 100644
--- a/java/java.go
+++ b/java/java.go
@@ -117,6 +117,10 @@ type CompilerProperties struct {
// If set to true, include sources used to compile the module in to the final jar
Include_srcs *bool
+ // If not empty, classes are restricted to the specified packages and their sub-packages.
+ // This restriction is checked after applying jarjar rules and including static libs.
+ Permitted_packages []string
+
// List of modules to use as annotation processors
Plugins []string
@@ -320,6 +324,9 @@ type Module struct {
// expanded Jarjar_rules
expandJarjarRules android.Path
+ // list of additional targets for checkbuild
+ additionalCheckedModules android.Paths
+
hiddenAPI
dexpreopter
}
@@ -481,6 +488,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
{Mutator: "arch", Variation: ctx.Config().BuildOsCommonVariant},
}, pluginTag, j.properties.Plugins...)
+ android.ProtoDeps(ctx, &j.protoProperties)
if j.hasSrcExt(".proto") {
protoDeps(ctx, &j.protoProperties)
}
@@ -768,12 +776,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.classpath = append(deps.classpath, dep.Srcs()...)
deps.staticJars = append(deps.staticJars, dep.Srcs()...)
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...)
- case android.DefaultsDepTag, android.SourceDepTag:
- // Nothing to do
- case publicApiFileTag, systemApiFileTag, testApiFileTag:
- // Nothing to do
- default:
- ctx.ModuleErrorf("dependency on genrule %q may only be in srcs, libs, or static_libs", otherName)
}
default:
switch tag {
@@ -1201,6 +1203,19 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
return
}
}
+
+ // Check package restrictions if necessary.
+ if len(j.properties.Permitted_packages) > 0 {
+ // Check packages and copy to package-checked file.
+ pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp")
+ CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages)
+ j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile)
+
+ if ctx.Failed() {
+ return
+ }
+ }
+
j.implementationJarFile = outputFile
if j.headerJarFile == nil {
j.headerJarFile = j.implementationJarFile