You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bit ago, I was trying to use this plugin with Type Resolution, but ran into some issues getting the classpath specified correctly as required. For mostly other unrelated reasons, I decided to use detekt-cli via antrun plugin, but figured I'd put in this issue in case it helps others, or perhaps helps prioritize a built-in fix.
The problem
Enabling Type Resolution requires providing a classpath with all the JARs that should be considered by Detekt during code analysis. I took a look at #60, but the recommended solutions for providing the classpath there didn't scale; as far as I could tell, the recommendation was to manually stitch together paths to all the JARs you want considered in Detekt's check. For a project with any real number of dependencies, this isn't really workable.
Workaround
The best workaround I found was to use the maven-dependency-plugin to generate the classpath string, and put it into an output property, like so:
Once configured as such, the classpath can be specified in the detekt plugin as such:
<classPath>${generated.classpath}</classPath>
However, the main downside was that the maven-dependency-plugin needed to run before the detekt plugin. This was fine if I was running mvn verify, but broke usage of mvn detekt:check.
All of this said, the workaround I stitched together above, and the classpath support from the maven-antrun-plugin indicate that determining the classpath dynamically is possible. If there is enough need for it, it would be a really nice quality-of-life improvement for this plugin!
The text was updated successfully, but these errors were encountered:
Hi, thanks for the info and a second, in many ways nicer, workaround.
Just so I understand it correctly. If you activate Type Resolution, would you need all dependencies in the classpath? If so it could be done, otherwise you would have to specify manually.
A bit ago, I was trying to use this plugin with Type Resolution, but ran into some issues getting the classpath specified correctly as required. For mostly other unrelated reasons, I decided to use detekt-cli via antrun plugin, but figured I'd put in this issue in case it helps others, or perhaps helps prioritize a built-in fix.
The problem
Enabling Type Resolution requires providing a classpath with all the JARs that should be considered by Detekt during code analysis. I took a look at #60, but the recommended solutions for providing the classpath there didn't scale; as far as I could tell, the recommendation was to manually stitch together paths to all the JARs you want considered in Detekt's check. For a project with any real number of dependencies, this isn't really workable.
Workaround
The best workaround I found was to use the
maven-dependency-plugin
to generate the classpath string, and put it into an output property, like so:Once configured as such, the classpath can be specified in the detekt plugin as such:
However, the main downside was that the
maven-dependency-plugin
needed to run before the detekt plugin. This was fine if I was runningmvn verify
, but broke usage ofmvn detekt:check
.Having moved back to using detekt-cli, I am able to solve this problem via
maven-antrun-plugin
's classpath support.All of this said, the workaround I stitched together above, and the classpath support from the
maven-antrun-plugin
indicate that determining the classpath dynamically is possible. If there is enough need for it, it would be a really nice quality-of-life improvement for this plugin!The text was updated successfully, but these errors were encountered: