<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Jacoco in Maven Build</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build</link><description>&lt;p&gt;Hello,
I have been trying to get Jacoco to work with the maven build, because we used sonarqube to as part of our process and we need code coverage metrics. However, no matter what I do, Jacoco is always analyzing zero classes.&lt;/p&gt;
&lt;p&gt;Is there anything we can do for this?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/4312/jacoco-in-maven-build" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 13 Jan 2020 10:29:10 -0500</lastBuildDate><item><title>Comment by TareqK on TareqK's answer</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4319</link><description>&lt;p&gt;&lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel&lt;/a&gt;&lt;/a&gt; Thanks for the feedback, ill try it out as soon as i can!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">TareqK</dc:creator><pubDate>Mon, 13 Jan 2020 10:29:10 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4319</guid></item><item><title>Comment by Reguel Wermelinger on TareqK's answer</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4318</link><description>&lt;p&gt;Cool solution: thanks for sharing!&lt;/p&gt;
&lt;p&gt;One remark though: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you can make the resource copy process slightly simpler by teaching ivy projects where to put compile classes into (our default /classes is not the best for maven natured projects)&lt;/li&gt;
&lt;li&gt;use the package explorer &amp;gt; context menu &amp;gt; properties &amp;gt; java build path &amp;gt; source&lt;/li&gt;
&lt;li&gt;set the settings outlined in the screenshot: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://answers.axonivy.com/upfiles/mvnLike_compileDirs.png" width="640"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Mon, 13 Jan 2020 10:18:44 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4318</guid></item><item><title>Answer by TareqK</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build/4317</link><description>&lt;p&gt;Updates on this : &lt;/p&gt;
&lt;p&gt;Got it to work, turns out as &lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel&lt;/a&gt;&lt;/a&gt; said, the JDT compiler wont play with a javaagent. I got around this by using the offline mode of jacoco, and copying the generated classes from the classes directory in the correct target/classes and target/test-classes directories . This is what the pom section looks like : &lt;/p&gt;
&lt;p&gt;&lt;a href="https://gist.githubusercontent.com/TareqK/3fbbd05c9a61116083872f9497a4e7a8/raw/528696c54214b546f5fc2541a83dfdf7b45a8d94/Jacoco%2520With%2520Axon%2520Ivy"&gt;Gist Of pom.xml parts&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You also need to set the &amp;lt;testoutputdirectory&amp;gt; as well, otherwise it wont work&lt;/p&gt;
&lt;p&gt;The reports are generated in the target/site/jacoco folder, and the jacoco.exec file is in the target folder as well&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">TareqK</dc:creator><pubDate>Mon, 13 Jan 2020 10:07:53 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build/4317</guid></item><item><title>Comment by Reguel Wermelinger on TareqK's question</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4315</link><description>&lt;p&gt;you may have to set explicitly the test releated vars in pom.xml: e.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;build&amp;gt;
    &amp;lt;testSourceDirectory&amp;gt;src_test&amp;lt;/testSourceDirectory&amp;gt;
    &amp;lt;testOutputDirectory&amp;gt;target/test-classes&amp;lt;/testOutputDirectory&amp;gt;
&amp;lt;/build&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;if that doesn't help: the issue is very likely that jacoco works with a javaagent. Since we setup a custom JDT compiler run, this agent may can not be made known with a standard approach.&lt;/p&gt;
&lt;p&gt;However, we can provide detailed feedback if you share a simple project that shows the issue and file it as official support request.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Fri, 10 Jan 2020 05:22:07 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4315</guid></item><item><title>Comment by TareqK on TareqK's question</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4314</link><description>&lt;p&gt;I Did indeed do the maven setup, im using maven 4.12 with powermock and mockito, and all the test do run. I checked this configuration compared to the examples on baeldug and mkyong, but still no luck. Jacoco does see all the packages, its just ignoring every class in them.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">TareqK</dc:creator><pubDate>Thu, 09 Jan 2020 09:01:39 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4314</guid></item><item><title>Comment by Lukas Lieb on TareqK's question</title><link>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4313</link><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Seems to be an maven configuration problem to me...
How do you configure you're maven build? Do you use the jacoco-maven-plugin? Did the tests run? Which JUnit version?
Maybe this blog post can help you: &lt;a href="https://www.mkyong.com/maven/maven-jacoco-code-coverage-example/"&gt;https://www.mkyong.com/maven/maven-jacoco-code-coverage-example/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Lukas&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lukas Lieb</dc:creator><pubDate>Thu, 09 Jan 2020 08:39:31 -0500</pubDate><guid>https://answers.axonivy.com/questions/4312/jacoco-in-maven-build#4313</guid></item></channel></rss>