diff options
| author | 2018-10-17 15:10:48 -0700 | |
|---|---|---|
| committer | 2018-10-18 14:55:07 -0700 | |
| commit | 094054ab0761903626f27d32781dc64b67534219 (patch) | |
| tree | 769db374fff547c5a3738f1a58746888aea1115f /java/java.go | |
| parent | dc1e829b59fe97489180e38d8d8783468a3b9453 (diff) | |
Support main_class property in java_binary modules
Add a main_class property that will be used to generate a manifest
containing a Main-Class entry.
Test: m checkbuild
Change-Id: I0a59bb2b93cad915afd82fba708fa0f7eda2fe7a
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/java/java.go b/java/java.go index e5218bb76..c15a62b24 100644 --- a/java/java.go +++ b/java/java.go @@ -309,6 +309,9 @@ type Module struct { // list of extra progurad flag files extraProguardFlagFiles android.Paths + // manifest file to use instead of properties.Manifest + overrideManifest android.OptionalPath + // list of SDK lib names that this java moudule is exporting exportedSdkLibs []string @@ -1193,8 +1196,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path jars = append(jars, deps.staticJars...) jars = append(jars, deps.staticResourceJars...) - var manifest android.OptionalPath - if j.properties.Manifest != nil { + manifest := j.overrideManifest + if !manifest.Valid() && j.properties.Manifest != nil { manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest")) } @@ -1536,6 +1539,9 @@ func TestHostFactory() android.Module { type binaryProperties struct { // installable script to execute the resulting jar Wrapper *string + + // Name of the class containing main to be inserted into the manifest as Main-Class. + Main_class *string } type Binary struct { @@ -1556,6 +1562,15 @@ func (j *Binary) HostToolPath() android.OptionalPath { func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { if ctx.Arch().ArchType == android.Common { // Compile the jar + if j.binaryProperties.Main_class != nil { + if j.properties.Manifest != nil { + ctx.PropertyErrorf("main_class", "main_class cannot be used when manifest is set") + } + manifestFile := android.PathForModuleOut(ctx, "manifest.txt") + GenerateMainClassManifest(ctx, manifestFile, String(j.binaryProperties.Main_class)) + j.overrideManifest = android.OptionalPathForPath(manifestFile) + } + j.Library.GenerateAndroidBuildActions(ctx) } else { // Handle the binary wrapper |