Minimize an Uber Jar correctly, Using Shade-Plugin

后端 未结 1 701
小鲜肉
小鲜肉 2020-12-09 08:29

I am using the Maven-Shade-Plugin to create a runnable Uber-jar. According to the last frame on this page, the size of the jar can be minimized by using:

<         


        
1条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 09:13

    This functionality has been added to version 1.6 of the maven-shade-plugin (just released). minimizeJar will now not remove classes that have been specifically included with filters. Note that including some of an artifact's classes in a filter will exclude non-specified classes for that artifact, so be sure to include all the classes that you need.

    Here's an example plugin config:

    
        org.apache.maven.plugins
        maven-shade-plugin
        1.6    
        
            
                package
                
                    shade
                                        
                
                    true    
                     
                        
                           log4j:log4j
                           
                               **
                           
                         
                        
                           commons-logging:commons-logging
                           
                               **
                           
                                              
                    
                
            
        
    
    

    To only include specific classes, add them as includes using path slashes in the class name in a filter (again, non-included classes will be automatically excluded).

    
      org.yourorg:your-artifact
      
        org/yourorg/yourartifact/api/*
        org/yourorg/yourartifact/util/*
      
    
    

    0 讨论(0)
提交回复
热议问题