Override -Djacoco.skip=false is not working.

823 views
Skip to first unread message

suresh...@gmail.com

unread,
Jun 29, 2020, 5:13:27 AM6/29/20
to JaCoCo and EclEmma Users
Hi All,

I have a requirement to Skip the Jacoco execution by default and have to execute the same on demand by overriding -Djacoco.skip=false in Jenkins build. 

I have  this in my base-pom. which is working fine by default. 

<plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.3</version>
                    <executions>
                        <execution>
                            <id>pre-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration combine.self="override">
<skip>true</skip>
                                <destFile>${project.build.directory}/jacoco.exec</destFile>
                                <propertyName>surefireArgLine</propertyName> 
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration combine.self="override">
<skip>true</skip>
                               <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
</configuration> 
                        </execution>
                    </executions>
                </plugin> 

overriding the same in mvn install  -Djacoco.skip=false , but getting this message.

[INFO] Skipping JaCoCo execution because property jacoco.skip is set.
[INFO] surefireArgLine set to empty

Evgeny Mandrikov

unread,
Jun 29, 2020, 5:23:25 AM6/29/20
to jac...@googlegroups.com
This has nothing to do with jacoco-maven-plugin - please refer to the documentation about Maven itself:
You can not use properties to override configuration explicitly specified in your pom.xml file,
i.e. everything here behaves as expected - "<skip>true</skip>" can not be overridden by "-Djacoco.skip=false" because this is how Maven works.

To achieve what you want, instead of 

<configuration>
  <skip>true</skip>
</configuration>

you can specify

<properties>
  <jacoco.skip>true</jacoco.skip>
</properties>


Regards,
Evgeny



--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e2906d07-4167-4e7c-b13c-bbdcbd0b5402o%40googlegroups.com.

suresh...@gmail.com

unread,
Jun 29, 2020, 6:23:05 AM6/29/20
to JaCoCo and EclEmma Users
Thank you Evgeny,

Removed that from configuration and added under properties, but still this is not overriding. 

<properties>
<jacoco.skip>true</jacoco.skip>
</properties>

and 

-Djacoco.skip=false to mvn install in jenkins. 

Getting [INFO] Skipping JaCoCo execution because property jacoco.skip is set.
[INFO] surefireArgLine set to empty.

Is there anything i missing, please help me with. I spend almost 2 days on this now. 
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.

Evgeny Mandrikov

unread,
Jun 29, 2020, 6:38:08 AM6/29/20
to jac...@googlegroups.com
Snippets of pom.xml are not complete minimal reproducible examples, so no idea what's wrong in your case - in the attachment you'll find complete minimal example that works just fine.

Regards,
Evgeny



To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/fc17ddd7-caea-49a8-acc2-e4e003df9391o%40googlegroups.com.
example.zip

suresh...@gmail.com

unread,
Jun 29, 2020, 8:04:12 AM6/29/20
to JaCoCo and EclEmma Users




<jacoco.skip>true</jacoco.skip>

This is what i have in my POM.
<plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.5</version>
                    <executions>
                        <execution>
                            <id>pre-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <destFile>${project.build.directory}/jacoco.exec</destFile>
                                <propertyName>surefireArgLine</propertyName> 
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration >
                               <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
</configuration> 
                        </execution>
                    </executions>
                </plugin>

Reply all
Reply to author
Forward
0 new messages