summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-09-27 17:42:05 -0700
committerColin Cross <ccross@android.com>2017-09-29 14:02:22 -0700
commit0f37af0c155b2f934e463da9c47af2afe5ee6cef (patch)
treec2f099634b03217aefe73b772a8456f003b3993d /java/java.go
parent8649b2653cdcb147c67a0c523967ca76689875bb (diff)
Add java file resources and flag to include sources
Add a properties to allow including files as resources, including support for filegroups. Also add a flag that causes module sources to be included in the final jar. Test: java_test.go TestResources Change-Id: Ida8ee59b28df9fe66952170f46470d3a09fd5d65
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index 06ba44db8..dbb755b9f 100644
--- a/java/java.go
+++ b/java/java.go
@@ -75,6 +75,12 @@ type CompilerProperties struct {
// list of directories that should be excluded from java_resource_dirs
Exclude_java_resource_dirs []string `android:"arch_variant"`
+ // list of files to use as Java resources
+ Java_resources []string `android:"arch_variant"`
+
+ // list of files that should be excluded from java_resources
+ Exclude_java_resources []string `android:"arch_variant"`
+
// don't build against the default libraries (legacy-test, core-junit,
// ext, and framework for device targets)
No_standard_libs *bool
@@ -100,6 +106,9 @@ type CompilerProperties struct {
// If set to false, don't allow this module to be installed. Defaults to true.
Installable *bool
+ // If set to true, include sources used to compile the module in to the final jar
+ Include_srcs *bool
+
// List of modules to use as annotation processors
Annotation_processors []string
@@ -275,6 +284,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...)
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
+ android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
}
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
@@ -426,7 +436,23 @@ func (j *Module) compile(ctx android.ModuleContext) {
jars = append(jars, classes)
}
- resArgs, resDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs)
+ dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs)
+ fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources)
+
+ var resArgs []string
+ var resDeps android.Paths
+
+ resArgs = append(resArgs, dirArgs...)
+ resDeps = append(resDeps, dirDeps...)
+
+ resArgs = append(resArgs, fileArgs...)
+ resDeps = append(resDeps, fileDeps...)
+
+ if proptools.Bool(j.properties.Include_srcs) {
+ srcArgs, srcDeps := ResourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
+ resArgs = append(resArgs, srcArgs...)
+ resDeps = append(resDeps, srcDeps...)
+ }
if len(resArgs) > 0 {
// Combine classes + resources into classes-full-debug.jar