I have a Spring-Boot maven repository. I can't alter pom.xml to add jacoco-maven-plugin. But I need a test coverage report for this repository.
So my idea was to execute the following command:
mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report
But in the logs I see:
[INFO] --- jacoco-maven-plugin:0.8.6:prepare-agent (default-cli) @ backend ---
[INFO] argLine set to -javaagent:C:\\Users\\admin\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.6\\org.jacoco.agent-0.8.6-runtime.jar=destfile=C:\\projects\\my-project\\backend\\target\\jacoco.exec
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.6:report (default-cli) @ backend ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
and no report is generated.
What should I do to add "missing execution data file"? And is it even possible to generate Jacoco report without adding anything to the pom.xml?
I figured this thing out. Turns out I needed to change the goal's order a bit.
Instead of:
mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report
I need to do:
Clean
Prepare Jacoco Agent
Verify
Build report.
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report