Hi Elizabeth,

I had a quick look at the documentation and it says that there is a problem 
when using extra command line options: As these are not part of the effective 
POM they will break the cache key. Maybe they disable caching when additional 
goals are given for that reason. I would try the following:

1) Try adding another goal instead of JaCoCo, for example 
versions:display-dependency-updates. Does the cache work in this case?
2) Enable code coverage directly in your POM and see whether the cache works if 
you run the build without extra goals on the command line.

Regards,
-marc


> On 15. Dec 2023, at 15:59, Elizabeth Sirkova <e.sirk...@relay42.com> wrote:
> 
> Hi guys, 
> 
> (I am not sure this is the right place to ask, but at this moment it's a bit 
> unclear to me where our problem comes from, so I am hoping someone can point 
> me in the right direction / or if someone has experienced the same to share 
> their knowledge...)
> 
> We are looking into using the Maven build cache extension 
> <https://maven.apache.org/extensions/maven-build-cache-extension/getting-started.html>
>  for incremental builds in order to speed up our CI and local builds. In our 
> CI pipeline we have a step where we run tests and generate test coverage via 
> Jacoco (which is later used by Sonar). Unfortunately, we experience issues 
> with having the incremental builds/cache work when we generate code coverage 
> reports. 
> 
> For instance, whenever we run `mvn jacoco:prepare-agent test jacoco:report` 
> the remote/local cache is never used. However, if we remove the `jacoco` 
> parts from the command, then the cache is utilized.
> 
> We use:
> * Java   - 17.0.9 (OpenJDK)
> * Maven  - 3.9.6
> * Jacoco - 0.8.11
> 
> For running tests we use the `maven-surefire-plugin`, which is configured 
> like this:
> ```
> <properties>
>       <argLine></argLine>
>       <surefireArgLine></surefireArgLine>
>       ...
> </properties>
> ...
> <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-surefire-plugin</artifactId>
>       <version>${maven-surefire-plugin.version}</version>
>       <!-- 
> https://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation
>  -->
>       <configuration>
>               <argLine>@{argLine} ${surefireArgLine}</argLine>
>       </configuration>
> </plugin>
> <plugin>
>       <groupId>org.jacoco</groupId>
>       <artifactId>jacoco-maven-plugin</artifactId>
>       <version>${maven-jacoco-plugin.version}</version>
> </plugin>
> ```
> 
> Our `maven-build-cache-config.xml` for the incremental builds is the 
> following:
> 
> ```
> <?xml version="1.0" encoding="UTF-8" ?>
> <cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0";
>          xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 
> https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd";>
>       <configuration>
>               <enabled>true</enabled>
>               <hashAlgorithm>XX</hashAlgorithm>
>               <remote enabled="true" id="xxxx">
>                       <url>xxxx</url>
>               </remote>
>       </configuration>
>       <executionControl>
>               <runAlways>
>                       <executions>
>                               <execution groupId="me.qoomon" 
> artifactId="maven-git-versioning-extension">
>                                       <execIds>
>                                               <execId>git-versioning</execId>
>                                       </execIds>
>                               </execution>
>                       </executions>
>                       <goalsLists>
>                               <goalsList artifactId="maven-install-plugin">
>                                       <goals>
>                                               <goal>install</goal>
>                                       </goals>
>                               </goalsList>
>                       </goalsLists>
>               </runAlways>
>               <reconcile>
>                       <plugins>
>                               <plugin artifactId="maven-surefire-plugin" 
> goal="test">
>                                       <reconciles>
>                                               <reconcile propertyName="skip" 
> skipValue="true"/>
>                                               <reconcile 
> propertyName="skipExec" skipValue="true"/>
>                                               <reconcile 
> propertyName="skipTests" skipValue="true"/>
>                                               <reconcile 
> propertyName="testFailureIgnore" skipValue="true"/>
>                                       </reconciles>
>                               </plugin>
>                       </plugins>
>               </reconcile>
>       </executionControl>
> </cache>
> ```
> 
> Do you have any advise/suggestions how to make the Maven incremental builds + 
> Jacoco code coverage work together?
> 
> Kind regards,
> Elizabeth
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jacoco+unsubscr...@googlegroups.com 
> <mailto:jacoco+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/35d92af4-e0d4-4b06-aea5-5312807e65fen%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/35d92af4-e0d4-4b06-aea5-5312807e65fen%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jacoco+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/BF65853C-9B02-4148-8814-D863E0B7356A%40mountainminds.com.

Reply via email to