Besides the maven solution, you can also consider https://www.eclemma.org/jacoco/trunk/doc/cli.html
Basically, you start your service on a remote machine with the javaagent option, for example (you can change the port number and omit include if you want to have coverage for all classes):
-javaagent: /tmp/jacocoagent.jar=port=36320,destfile=jacoco-it.exec,output=tcpserver,includes=abcd*"
Then connect to the remote computer by specifying the address of the remote host, or open the tunnel for the remote computer. The following example assumes that I have configured port forwarding between the local 36320 host and the 36320 remote host
java -jar jacococli.jar dump --port 36320 --destfile/tmp/jacoco-it.exec
If you have multiple .exec files, you need to merge them:
java -jar jacococli.jar merge/tmp/jacoco-it-1.exec/tmp/jacoco-it-2.exec --destfile/tmp/merge
Then generate the html report (path1 may be the path to the jar file or the class files folder)
java -jar jacococli.jar report/tmp/jacoco-it.exec --classfiles path1 --sourcefiles path2 --html/tmp/report
Kaituo li
source share