Skip to content

How to apply a ruleset only on src/main/*.java files that do not match *Foo*.java? #5217

Answered by adangel
cinlloc asked this question in Q&A
Discussion options

You must be logged in to vote

But the (?!Foo) exclusion regex does not seems to work.

Yes, that seems to be the case. But it has something to do with regex, rather than PMD:
https://regex101.com/r/F4JBok/1

An easier way to achieve what you want: Just use exclusion without inclusion:

<exclude-pattern>.*Foo.java|.*/src/test/java/.*</exclude-pattern>

You could remove the "src/test/java"-part, if you set the maven-pmd-plugin parameter <includeTests>false</includeTests>.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@cinlloc
Comment options

Comment options

You must be logged in to vote
2 replies
@jsotuyod
Comment options

@cinlloc
Comment options

Answer selected by jsotuyod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants