Packaging a jar into a dist dir with separated external resources and dependencies

后端 未结 2 1421
粉色の甜心
粉色の甜心 2020-12-25 14:43

Here\'s what I\'m trying to achieve - a dist directory (or a zip file) that looks like this:

dist/
|-- application-1.0.jar
|-- conf/
    |-- app         


        
2条回答
  •  温柔的废话
    2020-12-25 15:24

    You need to use two plugins to accomplish this: maven-jar-plugin and maven-assembly-plugin.

    Useful pom.xml samples:

    • how make JAR executable and set manifest classpath
    • how to exclude files from JAR file
    • assembly plugin usage

    (I would recommend you to separate the user-editable properties files to separate directory, but it is a matter of taste.)

    Sample assembly configuration, to get you started:

    
      dist
      
        zip
      
      true
      dist
      
        
          lib
          runtime
        
      
      
        
          src/conf
          conf
        
        
          src/run
          
          
            *.sh
          
        
      
      
        
          src/run/run.sh
          
          0755
        
      
    
    

提交回复
热议问题