-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added androidTest
coverage support
#16
base: main
Are you sure you want to change the base?
Conversation
gradle/libs.versions.toml
Outdated
@@ -1,6 +1,6 @@ | |||
[versions] | |||
kotlin = "1.8.21" | |||
agp = "8.0.0" | |||
agp = "8.2.0-alpha02" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with 8.0.1
producing empty results for library modules
import kotlin.reflect.jvm.isAccessible | ||
import kotlin.reflect.typeOf | ||
|
||
internal fun <FILE_TYPE : FileSystemLocation> Artifacts.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a blocker to me, I don't want to release code doing all this dark magic to access the artifacts
} | ||
} | ||
|
||
if (variant.unitTest != null && buildType.enableUnitTestCoverage) { | ||
aggregate(variant.unitTest!!.artifacts.get(UNIT_TEST_CODE_COVERAGE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This internal artifact points to the "build/jacoco/testXXXUnitTest.exec" files
files(this).asFileTree.forEach { file -> | ||
outgoing.artifact(file) { | ||
type = ArtifactTypeDefinition.BINARY_DATA_TYPE | ||
builtBy(this@file) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is not working well, as for AndroidTest
we know in advance the target output directory, but not all the .ec
files getting generated by each emulator.
into(provider { temporaryDir }) | ||
duplicatesStrategy = DuplicatesStrategy.INCLUDE // in case of duplicated classes | ||
include("**/*.class") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now required, as the PRE_JACOCO_TRANSFORMED_CLASSES
also includes R.jar
from its dependencies
aggregatedVariants.all task@{ | ||
from(artifacts | ||
.forScope(ScopedArtifacts.Scope.PROJECT) | ||
.get(PRE_JACOCO_TRANSFORMED_CLASSES)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been forced to change from ScopedArtifact.CLASSES
(public API) to InternalScopedArtifact .PRE_JACOCO_TRANSFORMED_CLASSES
because ScopedArtifact.CLASSES
gets replaced with JaCoCo instrumented classes when AndroidTest
coverage is enabled. JaCoCo report task won't accept instrumented classes
81fbcfe
to
f690d06
Compare
f690d06
to
6945d09
Compare
Draft WIP implementing #15: support for
AndrodiTest
variant.The aggregation functionally was extended to also allow including
AndroidTest
variants.The current implementation is hacky, accessing AGP's internal APIs by reflection. More details here .