Skip to content

Instantly share code, notes, and snippets.

@techforum-repo
Last active February 22, 2021 17:40
Show Gist options
  • Save techforum-repo/70a2756b0741aae6ac0b55787acedb89 to your computer and use it in GitHub Desktop.
Save techforum-repo/70a2756b0741aae6ac0b55787acedb89 to your computer and use it in GitHub Desktop.

Agent Configuration for remote JVM(Server)

VM Prarameter - -javaagent:/usr/local/tomcat/lib/jacocoagent.jar=port=6300,address=0.0.0.0,destfile=/tmp/jacoco-remote.exec,includes=com.sample.*,append=true,output=tcpserver

MVN Plugin Configuration

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.6</version>
  <executions>
  	<execution>
  		<id>dump</id>
  		<phase>post-integration-test</phase>
  		<goals>
  			<goal>dump</goal>
  		</goals>
  		<configuration>
  			<address>localhost</address>
  			<destFile>${project.build.directory}/jacoco.exec</destFile>
  			<port>6300</port>
  			<reset>false</reset>
  			<append>false</append>
  		</configuration>
  	</execution>
  	<execution>
  		<id>default-report</id>
  		<phase>verify</phase>
  		<goals>
  			<goal>report</goal>
  		</goals>
  	</execution>
  </executions>
</plugin>

Analyse the code and upload the report to Sonar

mvn clean verify sonar:sonar

Generate Report through jacoco CLI

Dump detail - java -jar jacococli.jar dump --address localhost --port 6300 --destfile jacoco.exec --reset

Generate Report - java -jar jacococli.jar report jacoco.exec --classfiles maven-sample-webapp/target/classes --sourcefiles maven-sample-webapp/src/main/resources --html cli_report --xml cli_report/jacoco.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment