Skip to content

Commit cb2fcd3

Browse files
committed
Enable Jacoco on at has-it-been-touched reporting
1 parent 1d004a3 commit cb2fcd3

1 file changed

Lines changed: 103 additions & 1 deletion

File tree

pom.xml

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<hamcrest.version>2.2</hamcrest.version>
3636
<okhttp3.version>3.12.3</okhttp3.version>
3737
<okio.version>2.4.1</okio.version>
38+
<jacoco.coverage.target>0.20</jacoco.coverage.target>
39+
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
40+
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
3841
</properties>
3942

4043
<build>
@@ -46,6 +49,16 @@
4649
</excludes>
4750
</testResource>
4851
</testResources>
52+
<pluginManagement>
53+
<plugins>
54+
<!-- adds jacoco coverage -->
55+
<plugin>
56+
<groupId>org.jacoco</groupId>
57+
<artifactId>jacoco-maven-plugin</artifactId>
58+
<version>0.8.5</version>
59+
</plugin>
60+
</plugins>
61+
</pluginManagement>
4962
<plugins>
5063
<plugin>
5164
<artifactId>maven-compiler-plugin</artifactId>
@@ -271,7 +284,96 @@
271284
<url>https://repo.jenkins-ci.org/public/</url>
272285
</pluginRepository>
273286
</pluginRepositories>
274-
287+
<profiles>
288+
<profile>
289+
<id>jacoco</id>
290+
<activation>
291+
<property>
292+
<name>!jacoco.disabled</name>
293+
</property>
294+
</activation>
295+
<build>
296+
<plugins>
297+
<plugin>
298+
<groupId>org.jacoco</groupId>
299+
<artifactId>jacoco-maven-plugin</artifactId>
300+
<version>0.8.5</version>
301+
<executions>
302+
<execution>
303+
<goals>
304+
<goal>prepare-agent</goal>
305+
</goals>
306+
</execution>
307+
<!-- attached to Maven test phase -->
308+
<execution>
309+
<id>report</id>
310+
<phase>test</phase>
311+
<goals>
312+
<goal>report</goal>
313+
</goals>
314+
</execution>
315+
<execution>
316+
<id>check</id>
317+
<phase>install</phase>
318+
<goals>
319+
<goal>check</goal>
320+
</goals>
321+
<configuration>
322+
<rules>
323+
<rule>
324+
<!--We end up with chatty logs, but it shows us which particular classes -->
325+
<!--are lacking in coverage. If this is too much, just remove the -->
326+
<!--<element>CLASS</element> tag below. -->
327+
<element>CLASS</element>
328+
<limits>
329+
<!-- These limits can be overridden, in the form of `0.50` for -->
330+
<!-- 50%, as necessary. Using a property just puts it in one spot. -->
331+
<limit>
332+
<counter>LINE</counter>
333+
<value>COVEREDRATIO</value>
334+
<minimum>${jacoco.coverage.target}</minimum>
335+
</limit>
336+
<limit>
337+
<counter>BRANCH</counter>
338+
<value>COVEREDRATIO</value>
339+
<minimum>${jacoco.coverage.target}</minimum>
340+
</limit>
341+
<limit>
342+
<counter>INSTRUCTION</counter>
343+
<value>COVEREDRATIO</value>
344+
<minimum>${jacoco.coverage.target}</minimum>
345+
</limit>
346+
<limit>
347+
<counter>COMPLEXITY</counter>
348+
<value>COVEREDRATIO</value>
349+
<minimum>${jacoco.coverage.target}</minimum>
350+
</limit>
351+
<limit>
352+
<counter>METHOD</counter>
353+
<value>COVEREDRATIO</value>
354+
<minimum>${jacoco.coverage.target}</minimum>
355+
</limit>
356+
<limit>
357+
<counter>CLASS</counter>
358+
<value>COVEREDRATIO</value>
359+
<minimum>${jacoco.coverage.target}</minimum>
360+
</limit>
361+
</limits>
362+
<excludes>
363+
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
364+
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
365+
<!--<exclude>io.jenkins.plugins.todeclarative.converter.api.*</exclude>-->
366+
</excludes>
367+
</rule>
368+
</rules>
369+
</configuration>
370+
</execution>
371+
</executions>
372+
</plugin>
373+
</plugins>
374+
</build>
375+
</profile>
376+
</profiles>
275377
<reporting>
276378
<plugins>
277379
<plugin>

0 commit comments

Comments
 (0)