Hiding manifest entries with maven

前端 未结 3 2292
执念已碎
执念已碎 2021-02-19 23:02

When building a jar file with maven, it will create a manifest file in META-INF/MANIFEST.MF. Its contents currently are:

Manifest-Version: 1.0                            


        
3条回答
  •  佛祖请我去吃肉
    2021-02-19 23:50

    The maven-achiver plugin documentation seems pretty clear that you cannot remove properties, only set them to blank as described in Alex Chernyshev's answer. In order to get more control over the MANIFEST.MF you should not use the maven-archiver plugin.

    One alternative would be to use the maven antrun plugin and the Ant Jar Task to build the Jar.

    In pom.xml:

    
      ...
      
        
          
            maven-antrun-plugin
            1.7
            
              
                package
                
                  
                    
                      
                      
                        
                      
                    
                  
                
                
                  run
                
              
            
          
        
      
      ...
    
    

    Another alternative is calling the Jar tool directly using the Maven exec plugin.

    I don't like recommending antrun, as I think it's a dirty hack, but it seems that maven-archiver does not meet your requirements. It might be worth raising a feature request for maven-archiver.

    EDIT: 2014-10-06 Raised Jira MSHARED-362

    EDIT: 2018-06-18: Updated link to Jira and to Maven Exec plugin

    EDIT: 2019-01-14: Fix targeted for maven-archiver-3.4.0

提交回复
热议问题