diff options
| author | 2019-02-28 17:05:01 +0000 | |
|---|---|---|
| committer | 2019-02-28 17:05:01 +0000 | |
| commit | 6a48032fc9b10f97a68a60295c6816ecd3ad953f (patch) | |
| tree | 92fab22d3ac70262d9b3a9ccc87774b1f691006e /java/java.go | |
| parent | 724c5fd8138d46193adf6de74aba79a37627f897 (diff) | |
| parent | 7f004a765bcff342baf83954b694cb5f4c3f8a2d (diff) | |
Merge "Add java_* 'services:' field"
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index 350117467..ecc360896 100644 --- a/java/java.go +++ b/java/java.go @@ -168,6 +168,9 @@ type CompilerProperties struct { } Instrument bool `blueprint:"mutated"` + + // List of files to include in the META-INF/services folder of the resulting jar. + Services []string `android:"arch_variant"` } type CompilerDeviceProperties struct { @@ -478,6 +481,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { android.ExtractSourcesDeps(ctx, j.properties.Java_resources) android.ExtractSourceDeps(ctx, j.properties.Manifest) android.ExtractSourceDeps(ctx, j.properties.Jarjar_rules) + android.ExtractSourcesDeps(ctx, j.properties.Services) if j.hasSrcExt(".proto") { protoDeps(ctx, &j.protoProperties) @@ -1136,6 +1140,25 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest")) } + services := ctx.ExpandSources(j.properties.Services, nil) + if len(services) > 0 { + servicesJar := android.PathForModuleOut(ctx, "services", jarName) + var zipargs []string + for _, file := range services { + serviceFile := file.String() + zipargs = append(zipargs, "-C", filepath.Dir(serviceFile), "-f", serviceFile) + } + ctx.Build(pctx, android.BuildParams{ + Rule: zip, + Output: servicesJar, + Implicits: services, + Args: map[string]string{ + "jarArgs": "-P META-INF/services/ " + strings.Join(proptools.NinjaAndShellEscape(zipargs), " "), + }, + }) + jars = append(jars, servicesJar) + } + // Combine the classes built from sources, any manifests, and any static libraries into // classes.jar. If there is only one input jar this step will be skipped. var outputFile android.ModuleOutPath |