Azure-pipelines-tasks: Issue with code coverage and multi-module project.

Created on 5 Jul 2019  Â·  11Comments  Â·  Source: microsoft/azure-pipelines-tasks

@err108 commented on Oct 22, 2018, 4:52 PM UTC:

I can't seem to find any good documentation on or examples using the code coverage arguments. My project consists of a parent pom with multiple modules. Build is executed on the parent pom. I've supplied a list of paths in the codeCoverageClassFilesDirectories and codeCoverageSourceDirectories based on the tooltip help in the build configuration. However when the build runs, it fails with the following errors/warnings:

"An Ant BuildException has occured: Unable to read execution data file C:\agent_work\20\s\CCReport43F6D5EF\jacoco.exec"

"No code coverage found to publish. There might be a build failure resulting in no code coverage or there might be no tests."

It either isn't generating any code coverage reports, or can't aggregate the reports from the child modules. Tests are publishing fine and I can see the results aggregated for of all the tests run in the child modules.


Document Details

⚠ _Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking._

This issue was moved by davidstaheli from MicrosoftDocs/vsts-docs#2174.

Test bug

Most helpful comment

SOLVED

I don't know if the parent pom can be in a subdirectory but the key for me besides putting it in the root dir was to actually establish a parent/child relationship with the modules. As we had it, the modules were NOT declaring the root pom as parent which is perfectly legal and fine for maven. Unfortunately, it confuses the Azure DevOps maven task and won't correctly trigger the multi-module reporting without this relationship. After that, specifying the submodule class and src locations starting as moduleA/ and moduleB/ worked correctly.

All 11 comments

stale[bot] commented on Feb 28, 2019, 3:47 PM UTC:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@davidstaheli commented on Mar 10, 2019, 6:45 PM UTC:

Keep-alive

@davidstaheli commented on Jul 5, 2019, 6:57 PM UTC:

Thanks for reporting this. We're going to move this issue to this repo for better tracking and visibility:
https://github.com/Microsoft/azure-pipelines-tasks

/move to Microsoft/azure-pipelines-tasks

@err108, could you provide us with the build logs for this?

Sorry, been a while so unfortunately I don't have logs showing this error.

The good news is this is working for us now.

One of the issues we found was that codeCoverageClassFilesDirectories and codeCoverageSourceDirectories can't have spaces between the directories, ie dir1, dir2, dir3. I added the spaces back this morning to see if it generated the initial error above but it's a different error. It still can't resolve a list of directories with spaces, so might be nice if you guys could add a trim when you splice out each directory or a make a note in the tooltips. You can see below it tries to find the directory with the space.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project VstsReport: An Ant BuildException has occured: E:\AzDOAgent\_work\2\s\ apras-common-esec\target\test-classes does not exist.
[ERROR] around Ant part ...<report>... @ 8:11 in E:\AzDOAgent\_work\2\s\target\antrun\build-main.xml

After we hit the initial error above in Oct, we basically left code coverage turned off until we revisited it again in Feb 2019. I believe then we got the "...does not exist" error and we removed the spaces. So not sure if there were any release between Oct and Feb that might have inadvertently fixed the issue or if we made some other change to our project that did. Appreciate you looking into though!

I also have this issue ... we have a folder layout like this...

\main\pom.xml
\moduleA\pom.xml
\moduleB\pom.xml

where the \main\pom.xml is what is run and has no code itself to compile, just entries like...

../moduleA
../moduleB

The main pom does not reference joCoCo at all. I can see in the logs where joCoCo is running fine for the submodules and fails on generating the report with a similar error to above in the thread. I have tried simply putting the following, but it still fails:

codeCoverageClassFilesDirectories = target/classes,target/test-classes
codeCoverageSourcefileDirectories = src

I am doing this manually in the plugin for now and converting to yaml once I get it working. I am assuming the above are relative to each of the module pom directories. How do I get this working?

Paul, try explicitly listing each sub-module folder path.

codeCoverageClassFilesDirectories = moduleA/target/classes,moduleA/target/test-classes,moduleB/target/classes,moduleB/target/test-classes

codeCoverageSourcefileDirectories = moduleA/src/main,moduleA/src/test,moduleB/src/main,moduleB/src/test

That's how we have ours configured. Also, initially we had our parent pom just listing the sub-modules to build like you, and each sub-module had it's own parent (spring boot) defined. We ended up changing that so each sub-module defines the parent pom as it's parent and the parent pom defines spring boot as the parent. Not sure if that made a difference and if you can do that based on the sub module dependencies, but it was one change we made in between things not working in Oct and it all of a sudden working in Feb.

Our parent pom is also in our root folder, not in a sub folder. Not sure if the directories listed in the code coverage variables need to be relative to the parent pom location.

\pom.xml
\moduleA\pom.xml
\moduleB\pom.xml

Well ... still broken ... and here is what I have tried so far. I have tried both / and \ in the paths. since I was referencing a root\pom.xml, I also tried adding ../moduleA and ../moduleB in the paths. I also moved the root pom.xml OUT of the subdir and into the top dir per your thread above and fixing the module locations. Everything runs fine from maven ... it's this damn maven task specifying jacoco code coverage that fails. Every time I get ...

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project VstsReport: An Ant BuildException has occured: Unable to read execution data file D:\a\1\s\CCReport43F6D5EF\jacoco.exec
[ERROR] around Ant part ...... @ 8:11 in D:\a\1\s\target\antrun\build-main.xml: D:\a\1\s\CCReport43F6D5EF\jacoco.exec (The system cannot find the path specified)

What does it take to get MS FOLKS to chime in here?

SOLVED

I don't know if the parent pom can be in a subdirectory but the key for me besides putting it in the root dir was to actually establish a parent/child relationship with the modules. As we had it, the modules were NOT declaring the root pom as parent which is perfectly legal and fine for maven. Unfortunately, it confuses the Azure DevOps maven task and won't correctly trigger the multi-module reporting without this relationship. After that, specifying the submodule class and src locations starting as moduleA/ and moduleB/ worked correctly.

It is good that there i a solutionin case of the certain setup where each child has the parent project in it's pom.xml defined as paren pom too. But atually that is by intend to always the case, so how can i use it even if my child DOES have a parent pom from somewhere else ??

Do i then need to list all child comma separated for codeCoverageSourceDirectories and codeCoverageClassFilesDirectories?
Can you please give a working example?

DO i need absolute paths var in front?
codeCoverageClassFilesDirectories: ????????/target/classes
codeCoverageSourceDirectories: $(Build.SourcesDirectory)/child-app/src/main/java

Are there any updates to this? I've got a legacy app that has got a maven grandparent and about 35+ child projects. I really don't want to be specifying all of the codeCoverageClassFilesDirectories and codeCoverageSourcefileDirectories inside the maven task if possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaananth picture yaananth  Â·  3Comments

ThomasBarnekow picture ThomasBarnekow  Â·  3Comments

jabbera picture jabbera  Â·  3Comments

timfish picture timfish  Â·  3Comments

syltaxue picture syltaxue  Â·  3Comments