Maven best practice for creating ad hoc zip artifact

后端 未结 3 1744
孤街浪徒
孤街浪徒 2020-12-02 14:22

Assume that I need to manage an artifact that consists of an aribtrary folder / file structure rolled up as a zip archive. It\'s not clear to me how to accomplish this in M

3条回答
  •  孤街浪徒
    2020-12-02 14:43

    Decide what classifier you will use for your zip file, for sake of argument let's say it would be sample.

    In your project create file assembly/sample.xml

    Fill in assembly/sample.xml with something like this:

    
    
      sample
      
        zip
      
      
        
          /
          some/directory/in/your/project
        
      
      
      
        
          lib
          
            *:pom
          
          true
          false
          runtime
        
      
    
    

    Add this to your pom's build section

      
        
          
            org.apache.maven.plugins
            maven-assembly-plugin
            
              
                create-distribution
                package
                
                  single
                
                
                  
                    assembly/sample.xml
                  
                
              
            
          
        
      
    

    As a result it should create and install you-project-name-VERSION-sample.zip.

    I suggest you read chapter on assemblies from Sonatype's maven book: https://books.sonatype.com/mvnref-book/reference/assemblies.html

    Also, read assembly format specification: http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

提交回复
热议问题