eclipse-cs icon indicating copy to clipboard operation
eclipse-cs copied to clipboard

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

Open space88man opened this issue 4 years ago • 4 comments

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>

space88man avatar Nov 11 '20 22:11 space88man

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

romani avatar Nov 12 '20 02:11 romani

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.

rnveach avatar Nov 12 '20 02:11 rnveach

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...

karypid avatar Jun 20 '21 19:06 karypid

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

uldall avatar Feb 11 '22 09:02 uldall