diff options
| author | 2020-01-13 10:25:16 +0000 | |
|---|---|---|
| committer | 2020-01-13 10:25:16 +0000 | |
| commit | 289bd28f17149a7de4dbb5d7c7914e71b3cf7873 (patch) | |
| tree | de340e52891855e0e1b79eedab68493751602dd1 /java/java.go | |
| parent | 72d009e1ecc3fea78211bf1753392d6dd7e1e081 (diff) | |
| parent | 38dfa0fa18aaa7c58cce10d37cc045c645786045 (diff) | |
Merge "Do not add jacocoagent to framework libraries in static coverage builds."
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/java/java.go b/java/java.go index bfdc7fcc0..a546cd524 100644 --- a/java/java.go +++ b/java/java.go @@ -652,7 +652,14 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { } } - if j.shouldInstrumentStatic(ctx) { + // Framework libraries need special handling in static coverage builds: they should not have + // static dependency on jacoco, otherwise there would be multiple conflicting definitions of + // the same jacoco classes coming from different bootclasspath jars. + if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { + if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { + j.properties.Instrument = true + } + } else if j.shouldInstrumentStatic(ctx) { ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent") } } @@ -1455,12 +1462,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.headerJarFile = j.implementationJarFile } - if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { - if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { - j.properties.Instrument = true - } - } - if j.shouldInstrument(ctx) { outputFile = j.instrument(ctx, flags, outputFile, jarName) } |