jshiell / checkstyle-idea

CheckStyle plug-in for IntelliJ IDEA
https://plugins.jetbrains.com/plugin/1065-checkstyle-idea
Other
884 stars 160 forks source link

Optionally configure Checkstyle according to Maven #107

Open rupert-madden-abbott opened 10 years ago

rupert-madden-abbott commented 10 years ago

In our organisation, we like to package our checkstyle configuration as Maven artifact.

This allows us to:

<plugin>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>${plugin.checkstyle.version}</version>
  <dependencies>
    <dependency>
      <groupId>our.organisation</groupId>
      <artifactId>checkstyle-configuration</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
  <configuration>
    <configLocation>conf/sys_dev_checks.xml</configLocation>
    <suppressionsLocation>conf/sys_dev_suppressions.xml</suppressionsLocation>
  </configuration>
</plugin>

The main advantage of this setup is that a developer just needs to upgrade there pom to use the new version of the checkstyle-configuration artifact, and Maven automatically finds the configuration on the classpath, pulled out of the included Jar.

It would be very useful if Checkstyle-IDEA support configuration based on Maven poms, or, failing that, could at least specify a configuration location that would be located based on the classpath of the IntelliJ module.

This behaviour does seem to be supported by some of the checkstyle plugins for Netbeans.

jshiell commented 10 years ago

Thanks for the suggestion. It's how I've got things set up at my current client as well, although we cheat and just point at the source of the module in Git to get around this. I can appreciate this would be a great improvement.

The classpath option is the more likely one, as the IDEA API has heard of documentation and will have nothing to do with it. However, we already play with our own class path to get exceptions on the classpath, so I don't think it'll be too hard to find it in the project.

The bad news is that I won't be able to look at this in the near future due to personal commitments over the next couple of months. But I do think it'd be a great addition and it'll be top of the suggested feature list next time I have a moment.

dbyron0 commented 8 years ago

Yet another +1 for me, though at the moment I'm using the plugin in gradle-based projects, so being able to use the same checkstyle config as gradle's checkstyle plugin would be ideal. If it helps, I'm happy to make a separate issue for it. Thanks for your help.

jshiell commented 8 years ago

A year on, I fear this is pretty unlikely to happen. My last client went tits up, and I ended up moving to a shop where we don't use CS ourselves, so I no longer use the plugin day to day. But more importantly, it's more complex that you'd think, as to do this you'd have to understand the entirely Maven (and/or Gradle) model - e.g. what if the rules file in question was included in a transitive dependency from a base POM? It's possible the IDEA SDK allows you to leverage their support to make this easier, but given the level of documentation there it's unlikely to be an easy find.

Never say never, but I can't offer much hope at present. Sorry.