Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Exclude Some Files From Checking Operations

I am using checkstyle plugin to format my code and I need to exclude some java classes from checking operations. To do that, I wrote the code below:

<module name="BeforeExecutionExclusionFileFilter">
    <property name="fileNamePattern" value="src/main/java/package1/*.java"/>
</module>

<module name="BeforeExecutionExclusionFileFilter">
    <property name="fileNamePattern" value="src/main/java/package2/*.java"/>
</module>

I tried to exclude all classes in 2 different packages. But the code does not works unfortunately. I also tried as below:

<module name="BeforeExecutionExclusionFileFilter">
    <property name="fileNamePattern" value="src/main/java/package1/*.java"/>
    <property name="fileNamePattern" value="src/main/java/package2/*.java"/>
</module>

But this did not worked as well. The checkstyle plugin again checks all classes. How can I achieve this?

like image 646
JollyRoger Avatar asked Jan 26 '26 22:01

JollyRoger


1 Answers

I found the solution after long tries. My format for giving a path was wrong. Correct format should be like this one:

    <module name="BeforeExecutionExclusionFileFilter">
    <property name="fileNamePattern" value="[/\\]src[/\\]main[/\\]java[/\\]package1"/>
    </module>

    <module name="BeforeExecutionExclusionFileFilter">
        <property name="fileNamePattern" value="[/\\]src[/\\]main[/\\]java[/\\]package2"/>
    </module>

If we wanna give more than one package to ignore, this is the way we should do. Giving two property with same name does not work. Hope this helps to others.

like image 72
JollyRoger Avatar answered Jan 29 '26 10:01

JollyRoger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!