How to merge exec files with maven?

7,983 views
Skip to first unread message

gaymailatga...@gmail.com

unread,
Dec 2, 2013, 7:09:11 AM12/2/13
to jac...@googlegroups.com
Hi,
I"m having a hard time merging .exec files with Maven. The furthest I was able to get was using the following execution setting

<execution>
<id>merge</id>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSet dir="${project.build.directory}/jacoco-execs">
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<destFile>${project.build.directory}/coverage-merged/jacoco.exec</destFile>
</configuration>
</execution>

However, when I run 'mvn -e jacoco:merge' from a command line, I get the following error message
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: org.jacoco:jacoco-maven-plugin. Reason: Invalid or missing parameters: [Mojo parameter [name: 'fileSets'; alias: 'null']] for mojo: org.jacoco:jacoco-maven-plugin:0.6.4-SNAPSHOT:merge

I suspect that my settings are wrong, but I was unable to find any examples whatsoever anywhere on the internet. So I'd like to ask, how do I merge the execution files? Right now, I'm trying to at least make the whole process work step by step from a command line before tying it more closely with my build process.

Thanks,
Jan

Henrik Horneber

unread,
Dec 2, 2013, 8:22:27 AM12/2/13
to jac...@googlegroups.com

Hi,

from the error message I'd guess it should be fileSets, not fileSet. Something like
<fileSets>
<fileSet dir="${project.build.directory}/jacoco-execs">
                        <includes>
                                <include>*.exec</include>
                        </includes>
                </fileSet>
</fileSets>

For maven 2 you'd also need implementation hints.

Hope that helps.

Henrik


--
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
"I find many of the machines of violence very attractive. Tanks, airplanes, warships, especially aircraft carriers."
- 14th Dalai Lama

gaymailatga...@gmail.com

unread,
Dec 2, 2013, 9:56:16 AM12/2/13
to jac...@googlegroups.com, gaymailatga...@gmail.com
Thank you Henrik. I was indeed using Maven 2 and I have no idea what implementation hints you're talking about. Could you elaborate?

Meanwhile, I tried maven 3. This fails with the message "Skipping JaCoCo merge execution due to missing execution data files". This is odd since I have two exec files in the target/jacoco-execs/ directory. By looking at JaCoCo's code, I suspect that the syntax is still wrong and the files don't reach their destination. Any ideas?

Thanks,
Jan

Henrik Horneber

unread,
Dec 2, 2013, 10:11:57 AM12/2/13
to jac...@googlegroups.com
Hi,

from https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin/src/org/jacoco/maven/MergeMojo.java
<fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">

:-)

Please note that I don't have first hand experience with the maven merge target yet; I'm just quoting the documentation here.



Thanks,
Jan

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Mirko Friedenhagen

unread,
Dec 2, 2013, 12:24:58 PM12/2/13
to jac...@googlegroups.com

Hello,

Henrik is right, for Maven 2 please use implementation hints (see the referred github source link, the online documentation is not up to date :-)).

When you want to specify configuration parameters in an execution element for one goal only and invoke it from the CLI instead of executing the goal during a phase of the build, please use the id default-GOALNAME, i.e. default-merge. Or use default-cli for configurations concerning all CLI invocations.

Regards Mirko
--
Sent from my mobile

gaymailatga...@gmail.com

unread,
Dec 2, 2013, 2:00:48 PM12/2/13
to jac...@googlegroups.com, gaymailatga...@gmail.com
Awesome, thanks! I finally made it work. The trick was to put the settings in the overall configuration of the plugin. I'm not yet sure how to tie it into the build process, but the following configuration works when running 'mvn jacoco:merge' from a command line:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4-SNAPSHOT</version>
<configuration>
<fileSets>
<!-- Implementation attribute not needed in Maven 3 -->
<fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
<directory>${project.build.directory}/jacoco-execs/</directory>


<includes>
<include>*.exec</include>
</includes>
</fileSet>

</fileSets>
<!-- File containing the merged data -->
<destFile>${project.build.directory}/jacoco-merged/merged.exec</destFile>
</configuration>
<executions>
<execution>
...
</execution>
...
</executions>
</plugin>

gaymailatga...@gmail.com

unread,
Dec 2, 2013, 2:04:51 PM12/2/13
to jac...@googlegroups.com
On Monday, December 2, 2013 6:24:58 PM UTC+1, Mirko Friedenhagen wrote:
> Hello,
>
> Henrik is right, for Maven 2 please use implementation hints (see the referred github source link, the online documentation is not up to date :-)).
>
> When you want to specify configuration parameters in an execution element for one goal only and invoke it from the CLI instead of executing the goal during a phase of the build, please use the id default-GOALNAME, i.e. default-merge. Or use default-cli for configurations concerning all CLI invocations.
>
>
> Regards Mirko

Thank you, I'm happy with what I've got right now, but could you tell me what should the 'execution' part of the POM look like? I'm quite new to Maven and perhaps other people who find this post would be more interested in doing this automatically.

Mirko Friedenhagen

unread,
Dec 2, 2013, 2:39:32 PM12/2/13
to jac...@googlegroups.com
Hello,

* Maven has the concept of lifecycles[0] (clean, default, site) each
of which is comprised of several phases (test, package, verify,
install, deploy, ...).
* To each phase depending on the type of your artifact (jar, war, ear)
maven plugins may bind specific goals (defined in classes typically
named *Mojo).
* Only some plugin goals are bound by default[0,1] (e.g.
maven-surefire-plugin:test to the phase test).
* Additional goals may be bound by specifying their execution (most
plugins have a default phase declaration).
* When you use build/pluginManagement, you tell Maven about the
configuration only (version, configuration and maybe executions).
* build/pluginManagement is mostly useful in parent poms.
* When you want these goals to be really executed you must tell Maven
to do so in the build/plugins section of a project. But you may define
executions in build/plugins as well[2], when you only need them to be
executed in one module.
* Executions with the id default-* have a special meaning[3] and are
picked up from the CLI as well.

Regards
Mirko

[0] http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
[1] https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob;f=maven-core/src/main/resources/META-INF/plexus/default-bindings.xml
[2] https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin.test/it/it-merge-passes/it-merge-passes-merge/pom.xml
[3] http://maven.apache.org/guides/mini/guide-default-execution-ids.html
Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/

er.yogesh...@gmail.com

unread,
Sep 16, 2015, 11:15:10 AM9/16/15
to JaCoCo and EclEmma Users, gaymailatga...@gmail.com
Hi Can you share the pom.xml of yours? we are facing the same issue.

cbraj...@gmail.com

unread,
Apr 8, 2016, 12:43:58 PM4/8/16
to JaCoCo and EclEmma Users, gaymailatga...@gmail.com


Hi ,

can you please send the POM file for merging the different .exec files.
I am facing a similar situation , i have 3 modules which generates 3 different .exec files , so i need to merge all the coverage reports and create a new aggregated file.
can you please post POM files , that you tried with.
where to keep the merge goal in, parent POM or any module ?

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages