Building a fat jar using maven

后端 未结 6 1940
梦毁少年i
梦毁少年i 2020-11-21 23:51

I have a code base which I want to distribute as jar. It also have dependency on external jars, which I want to bundle in the final jar.

I heard that this can be do

6条回答
  •  囚心锁ツ
    2020-11-22 00:50

    You can use the onejar-maven-plugin for packaging. Basically, it assembles your project and its dependencies in as one jar, including not just your project jar file, but also all external dependencies as a "jar of jars", e.g.

    
        
            
                com.jolira
                onejar-maven-plugin
                    1.4.4
                    
                        
                            
                                one-jar
                            
                        
                    
            
        
    
    

    Note 1: Configuration options is available at the project home page.

    Note 2: For one reason or the other, the onejar-maven-plugin project is not published at Maven Central. However jolira.com tracks the original project and publishes it to with the groupId com.jolira.

提交回复
热议问题