Including dependencies in a jar with Maven

后端 未结 13 2144
盖世英雄少女心
盖世英雄少女心 2020-11-22 00:39

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file?

I have a project the builds into a single jar file. I want the classes fro

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 01:24

    Have a look at this answer:

    I am creating an installer that runs as a Java JAR file and it needs to unpack WAR and JAR files into appropriate places in the installation directory. The dependency plugin can be used in the package phase with the copy goal and it will download any file in the Maven repository (including WAR files) and write them where ever you need them. I changed the output directory to ${project.build.directory}/classes and then end result is that the normal JAR task includes my files just fine. I can then extract them and write them into the installation directory.

    
    org.apache.maven.plugins
    maven-dependency-plugin
    
        
            getWar
            package
            
                copy
            
            
                
                    
                        the.group.I.use
                        MyServerServer
                        ${env.JAVA_SERVER_REL_VER}
                        war
                        myWar.war
                    
                
                ${project.build.directory}/classes
            
        
    
    

提交回复
热议问题