osundblad / intellij-annotations-instrumenter-maven-plugin

IntelliJ IDEA annotations instrumenter maven plugin
Other
38 stars 11 forks source link

Redundant instrumentation #33

Closed cschwier closed 5 years ago

cschwier commented 5 years ago

When building with maven and running the two commands in succession instrumentation will happen twice.

mvn test
mvn verify

For the first command the instrumentation goal is run after compilation. For the second command the instrumentation is run again although the compilation step was skipped with the message

Nothing to compile - all classes are up to date

This is not a semantic bug since a null check will either fail on the first or pass two times but is probably unintended since it just bloats the binary.

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00) notnull-instrumenter-maven-plugin 0.6.8 Java Oracle JDK 11.0.1 Windows 10

cschwier commented 5 years ago

I just realised this is a limitation of mavens lifecycle handling since it does not skip phases. The compilation step is skipped by javac not maven's compiler plugin. There's very little one can do about it. The correct way to realize above usecase is by passing skip flags for all plugins one does not want to have executed in the 2nd case (-Dse.eris.notnull.instrument=false for the instrumenter) or run mvn clean verify instead.

osundblad commented 5 years ago

I have actually been thinking about a way to detect of classes have been instrumented by us, but I haven't figured out a good way to do it...