Skip to content

Commit a3b6ca6

Browse files
committed
DATAJPA-826 - Added Jacoco to test executions explicitly.
To make sure the coverage data is collected for all test executions, we now explicitly add the Jacoco Java agent to the test executions. Added Jacoco plugin explicitly to make sure the agent can be resolved even if the build is not run in sonarcube profile.
1 parent 51ff07c commit a3b6ca6

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

pom.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,28 @@
276276

277277
<build>
278278
<plugins>
279+
280+
<!--
281+
Jacoco plugin redeclared to make sure it's downloaded and
282+
the agents can be explicitly added to the test executions.
283+
-->
284+
<plugin>
285+
<groupId>org.jacoco</groupId>
286+
<artifactId>jacoco-maven-plugin</artifactId>
287+
<version>${jacoco}</version>
288+
<configuration>
289+
<destFile>${jacoco.destfile}</destFile>
290+
</configuration>
291+
<executions>
292+
<execution>
293+
<id>jacoco-initialize</id>
294+
<goals>
295+
<goal>prepare-agent</goal>
296+
</goals>
297+
</execution>
298+
</executions>
299+
</plugin>
300+
279301
<plugin>
280302
<groupId>org.apache.maven.plugins</groupId>
281303
<artifactId>maven-surefire-plugin</artifactId>
@@ -337,7 +359,7 @@
337359
<exclude>**/OpenJpa*</exclude>
338360
<exclude>**/EclipseLink*</exclude>
339361
</excludes>
340-
<argLine>-javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring}/spring-instrument-${spring}.jar</argLine>
362+
<argLine>-javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring}/spring-instrument-${spring}.jar -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco}/org.jacoco.agent-${jacoco}-runtime.jar=destfile=${jacoco.destfile}</argLine>
341363
</configuration>
342364
</execution>
343365
<execution>
@@ -350,7 +372,7 @@
350372
<includes>
351373
<include>**/EclipseLink*Tests.java</include>
352374
</includes>
353-
<argLine>-javaagent:${settings.localRepository}/org/eclipse/persistence/org.eclipse.persistence.jpa/${eclipselink}/org.eclipse.persistence.jpa-${eclipselink}.jar -javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring}/spring-instrument-${spring}.jar</argLine>
375+
<argLine>-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco}/org.jacoco.agent-${jacoco}-runtime.jar=destfile=${jacoco.destfile} -javaagent:${settings.localRepository}/org/eclipse/persistence/org.eclipse.persistence.jpa/${eclipselink}/org.eclipse.persistence.jpa-${eclipselink}.jar -javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring}/spring-instrument-${spring}.jar</argLine>
354376
</configuration>
355377
</execution>
356378
<execution>
@@ -363,7 +385,7 @@
363385
<includes>
364386
<include>**/OpenJpa*Tests.java</include>
365387
</includes>
366-
<argLine>-javaagent:${settings.localRepository}/org/apache/openjpa/openjpa/${openjpa}/openjpa-${openjpa}.jar</argLine>
388+
<argLine>-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco}/org.jacoco.agent-${jacoco}-runtime.jar=destfile=${jacoco.destfile} -javaagent:${settings.localRepository}/org/apache/openjpa/openjpa/${openjpa}/openjpa-${openjpa}.jar</argLine>
367389
<classpathDependencyExcludes>
368390
<classpathDepencyExclude>org.hsqldb:hsqldb</classpathDepencyExclude>
369391
</classpathDependencyExcludes>

0 commit comments

Comments
 (0)