checkstyle / eclipse-cs

The Eclipse Checkstyle plug-in integrates the Checkstyle Java code auditor into the Eclipse IDE. The plug-in provides real-time feedback to the user about violations of rules that check for coding style and possible error prone code constructs.
https://checkstyle.org/eclipse-cs
GNU Lesser General Public License v2.1
97 stars 56 forks source link

RFE: Remote Configuration allow jar to be added to classpath like maven plugin dependencies #274

Open space88man opened 3 years ago

space88man commented 3 years ago

See #272 for background.

RFE: alllow Remote Configuration to specify both config location and add JARs to the classpath of checkstyle (as maven does).

When both the configuration and SuppressionFilter XML are inside a JAR, Eclipse-CS can use a Remote Configuration and pass the configuration location to checkstyle as: jar:file:<location-to-jar>!/path-to-configuration-XML — at least this is how m2e-code-quality parsed the corresponding maven XML. However the SuppressionFilter XML cannot be located as the JAR is not on the classpath.

Wildfly is an example that puts both the configuration and SuppressionFilter XML inside a JAR.

For comparison: maven with plugin dependencies adds the JAR to the classpath; it specifies the configuration with a path like /wildfly-checkstyle/checkstyle.xml; the SupppressionFilter /wildfly-checkstyle/suppression.xml is found on the classpath.

Side note: there is a PR to maven checkstyle by @qxo to do the reverse and have maven support ${config_loc}; but this would require wildfly to change their JAR.

It would be good if Eclipse-CS could support the equivalent of this:

* configLocation is inside the JAR
* it references the SuppressionFilter as /wildfly-checkstyle/suppression.xml
  which is also inside the JAR
* Eclipse-CS  jar:file:wildfly-checkstyle-config-1.0.7.Final.jar!/wildfly-checkstyle/checkstyle.xml is the
  configLocation; subsequently /wildfly-checkstyle/suppression.xml can't be found (JAR not on classpath
  when checkstyle is invoked)

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${version.checkstyle.plugin}</version>
                    <configuration>
                        <configLocation>wildfly-checkstyle/checkstyle.xml</configLocation>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <sourceDirectories>
                            <directory>${project.build.sourceDirectory}</directory>
                        </sourceDirectories>
                        <resourceIncludes>**/*.properties,**/*.xml</resourceIncludes>
                        <includeTestResources>true</includeTestResources>
                        <includeResources>true</includeResources>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <failOnViolation>true</failOnViolation>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.wildfly.checkstyle</groupId>
                            <artifactId>wildfly-checkstyle-config</artifactId>
                            <version>${version.org.wildfly.checkstyle-config}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>check-style</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>checkstyle</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
romani commented 3 years ago

Fixing https://github.com/checkstyle/checkstyle/pull/8789 might make it more clear that path is classpath

rnveach commented 3 years ago

Fixing checkstyle/checkstyle#8789 might make it more clear that path is classpath

Fixing that issue will only allow user to force path to be identified as only classpath. From the prospect of this issue, it seems like a way is needed to add a custom user jar to eclipse-cs' classpath, which the referenced issue will not help with.

karypid commented 3 years ago

It seems that both this issue and the PR to maven checkstyle by @qxo are not getting fixed soon. In the meantime, is there a workaround that could be shared here? I reached this issue searching for a solution on how to share suppressions between maven and eclipse-cs so it would be nice if someone could recommend something (even if it is some sort of manual configuration of eclipse-cs after the maven project is imported).

As it stands, I can't rely on eclipse-cs because in our project the suppressions target all test classes so you can imagine that turning on checkstyle in eclipse creates a lot of noise regarding missing javadoc and such...

uldall commented 2 years ago

I have the exact same issue with not being able to share a suppressions.xml file between projects. Any update on this?