Skip to content

scoverage:integration-report fails if JARs are not present in local repository #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
norbjd opened this issue Feb 21, 2018 · 3 comments

Comments

@norbjd
Copy link

norbjd commented Feb 21, 2018

Hello,

(This looks like a duplicate of #51)

When running mvn scoverage:integration-report on a multi-module project with dependencies between modules, build fails if the modules JARs are not present in local repository (~/.m2/repository).

If I run mvn install before, it works.

I have reproduced the issue based on the scoverage-maven-samples repository (subproject aggregation), by just adding a dependency between module02 and module01 (see module02/pom.xml). The error I got when running mvn scoverage:integration-report is :

...
[INFO] ------------------------------------------------------------------------
[INFO] Building SCoverage Maven Samples : Aggregation : Module 2 1.3.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> scoverage-maven-plugin:1.3.0:integration-report (default-cli) > [scoverage]verify @ module02 >>>
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] SCoverage Maven Samples : Aggregation .............. SUCCESS [  0.552 s]
[INFO] SCoverage Maven Samples : Aggregation : Module 1 ... SUCCESS [  4.324 s]
[INFO] SCoverage Maven Samples : Aggregation : Module 2 ... FAILURE [  0.022 s]
[INFO] SCoverage Maven Samples : Aggregation : Module 3 ... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.263 s
[INFO] Finished at: 2018-02-21T12:25:35+01:00
[INFO] Final Memory: 19M/305M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project module02: Could not resolve dependencies for project org.scoverage.scoverage-maven-samples.aggregation:module02:jar:1.3.1-SNAPSHOT: Could not find artifact org.scoverage.scoverage-maven-samples.aggregation:module01:jar:1.3.1-SNAPSHOT

The issue comes from the verify phase on module02 run in forked scoverage lifecycle.

How can I avoid doing a mvn install before using coverage goals ? Is there any reason that integration-report goal uses JARs in local repository instead of classes/JARs generated in modules target/ directory ? Maybe I'm missing something.

@gslowikowski
Copy link
Member

Hi

In multi-module builds, in tasks after compile phase, Maven adds target/classes directory of the dependent artifact (Module 1 here) to the class path, when building modules depending on it (Module 2 here). If target/classes directory does not exist, that's not a problem. You can test it by calling mvn scoverage:report on clean project and checking that there are no target/classes directories.

In tasks after the package phase, Maven adds generated jars to the class paths of dependent modules. It expects these jars were build in package phase. In fact, scoverage builds jars with different names (scoverage- prefix) and Maven doesn't find them when preparing scoverage:integration-report goal execution. scoverage:integration-report will change it's classpath, because it needs the instrumented jars as dependencies, but it happens later, when the goal is already being executed.
Contrary to the target/classes directory case, when the dependent jar file does not exists, Maven fails the build.

The only workaround I know, without installing dependent modules in local repository is to call:

mvn package scoverage:integration-tests

You cannot run mvn package and then mvn scoverage:integration-report. Dependent jar files must be created in the same build if they need to be used as dependencies.

@norbjd
Copy link
Author

norbjd commented Feb 26, 2018

Thanks for your answer.

It worked doing

mvn package scoverage:integration-report

, but unit tests (Maven test phase) are executed twice (one time because of package phase, and one other in scoverage forked lifecycle because of scoverage:integration-report). Do you know a way to run unit tests only in scoverage lifecycle ?

@gslowikowski
Copy link
Member

Check my comment please.

@norbjd norbjd closed this as completed Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants