How to suppress Java warnings for specific directories or files such as generated code

后端 未结 13 1592
太阳男子
太阳男子 2020-12-02 07:13

I\'m using a parser generator that creates somewhat ugly code. As a result my Eclipse project has several dozen warnings emanating from generated source files. I know I can

13条回答
  •  失恋的感觉
    2020-12-02 07:33

    I solved this by using the maven regexp replace plugin - it does not solve the cause, but heals the pain:

    
      com.google.code.maven-replacer-plugin
      maven-replacer-plugin
      1.3.2
      
    
      prepare-package
      
        replace
      
    
      
      
    
      target/generated-sources/antlr/**/*.java
    
    
    true
    
      MULTILINE
    
    
    
      
        ^public class
        @SuppressWarnings("all") public class
      
    
      
    
    

    Note that I did not manage to get the ** notation to work, so you might have to specify path exactly.

    See comment below for an improvement on how not to generate duplicate @SupressWarnings

提交回复
热议问题