How to use Maven assembly plugin with multi module maven project

前端 未结 2 1035
南笙
南笙 2020-12-29 08:24

I am new to maven and spent ~3 days in generating the zip file with assembly plugin refering to http://www.petrikainulainen.net/programming/tips-and-tricks/creating-a-runnab

2条回答
  •  既然无缘
    2020-12-29 08:42

    The basic thing you should change is to create a separate module where you do the packaging which will look like this.

       +-- root (pom.xml)
            +--- mod-1 (pom.xml)
            +--- mod-2 (pom.xml)
            +--- mod-assembly (pom.xml)
    

    The pom in the mod-assembly will look like this:

    
      4.0.0
    
      
        org.test.parent
        root
        1.0.0-SNAPSHOT
      
    
      dist
      pom
    
      Packaging Test : Distribution
    
      
        
          ${project.groupId}
          module-one
          ${project.version}
        
        
          ${project.groupId}
          module-two
          ${project.version}
        
      
    
      
        
          
            maven-assembly-plugin
            
              
                make-bundles
                
                  single
                
                package
                
                  
                    proj1-assembly.xml
                  
                
              
            
          
        
      
    
    
    

    That will solve the problem with running maven-assembly-plugin in every child and the problem with the dummy descriptor. Here you can find a real example of such structure.

    Furthermore having the modules in one folder and the dependencies in an other folder you can use a assembly descriptor like this:

      bin
      
        zip
      
      false
      
        
              false
              true
              lib
              false
              
                ${project.groupId}:*:*
              
          
      
      
        
          true
          
            modules
            false
          
        
      
    

提交回复
热议问题