I tried looking for Jacoco offline instrumentation gradle script snippets but couldn\'t find one. Is it possible to do Jacoco offline instrumentation through gradle scripts
The answer https://stackoverflow.com/a/42238982/2689114 works for me(with some adapting to a newer gradle version).
If you have multi-module gradle project, then you should add some extra configuration to support cross-module code coverage.
For more details see Cross-module code coverage with Jacoco offline instrumentation in gradle mutlimodule project
Also, there is a working example: https://github.com/SurpSG/jacoco-offline-instrumentation