How to work around the stricter Java 8 Javadoc when using Maven

后端 未结 5 2165
感动是毒
感动是毒 2020-12-02 05:44

You\'ll quickly realize that JDK8 is a lot more strict (by default) when it comes to Javadoc. (link - see last bullet point)

If you never generate any Javadoc then o

5条回答
  •  日久生厌
    2020-12-02 05:58

    I like @ThiagoPorciúncula's solution but it didn't quite go far enough for me.

    I typically already have javadoc plugin additionalparam set which were not being overridden by the profile. Because of this I had to:

    • Set a disableDoclint property to be empty by default.
    • If in java >= 8, set the disableDoclint property to be -Xdoclint:none
    • The use ${disableDoclint} in theadditionalparamsection of themaven-javadoc-plugin`.

    This seems to work well albeit verbose.

    
        
        
    
    
        
            disable-java8-doclint
            
                [1.8,)
            
            
                
                -Xdoclint:none
            
        
        ...
    
    

    Then down below I could use the optional ${disableDoclint} variable in the additionalparam section that I had already defined.

    
        org.apache.maven.plugins
        maven-javadoc-plugin
        
            
                
                    jar
                
                
                    false
                    -tag inheritDoc:X ${disableDoclint}
                
            
        
        
            false
            This documentation content is licensed...
            -tag inheritDoc:X ${disableDoclint}
        
    
    

    This works under java 8 but doesn't cause syntax errors under java 7. Woo hoo!

提交回复
热议问题