2

You can run JUnit tests with the Jacoco agent to produce wonderful coverage reports. (It produces an opaque *.exec file during the running of the unit tests).

Now surefire has a parameter to load exclusions from a file.

Maven can read a properties list. It might be able to read a variable into a list.

My question is: Can jacoco maven plugin read exclusions from a file?

Community
  • 1
  • 1
hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • Do you mean you want to put the list of files which you want to exclude in a separate file and then read that file? – UserASR Jan 18 '17 at 11:05
  • 1
    Curious to know why don't you exclude using ` **/*tmp.* ` – UserASR Jan 18 '17 at 11:06
  • 1
    Correct @AST - I have about 300 files I'd like to exclude and I don't want it bogging down my Pom.xml – hawkeye Jan 18 '17 at 11:44
  • Seems like it doesn't work, I tried reproducing it on my machine but it does not exclude. In log it showed : `surefireArgLine set to -javaagent:/home/ankit/.m2/repository/org/jacoco/org.jacoco.agent/0.7.5.201505241946/org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=/home/ankit/workspace/DTX/plugins/maven/dt-packaging/target/coverage-reports/jacoco.exec,excludes=./pom.txt` – UserASR Jan 18 '17 at 12:15
  • What are the reason to exclude 300 files? Do you want to exclude them from instrumentation or/and from report? Are they located in same package? @ASR wildcards (`*`) are working just fine – Godin Jan 18 '17 at 13:44
  • 1
    They're not in the one package. They're deprecated code - Jacoco results feed into a build breaker for coverage goals for the team. – hawkeye Jan 18 '17 at 20:55
  • I am seeking the same information, and I think hawkeye's use case is valid. The list may be long; the same list may be an input to more than one plugin; the list could be generated from other information such as a bug database. The older Ant build tool supports "excludesfile" (which does exactly what Hawkeye is asking) just about every place it supports "excludes". Gradle has a mechanism for this. It would be nice if Maven had a similar feature. – John Elion Jun 21 '18 at 19:57

1 Answers1

1

According to jacoco-maven-plugin documentation there is no way to specify exclusions via file.

Godin
  • 9,801
  • 2
  • 39
  • 76