How do I get Maven 2 to build 2 separate WAR files

后端 未结 8 2057
有刺的猬
有刺的猬 2020-12-29 15:34

When doing a mvn install I want to end up with 2 WAR files in my target directory. One will contain the production web.xml and the

8条回答
  •  暖寄归人
    2020-12-29 16:31

    Sort-of-ugly hack (it breaks Maven's idea of declaring intentions instead of actions), but worked for me: I had to generate two wars which shared the same back-end code base, but varied on the MVC controller packages.

    After banging my head with several plugins, I thought "hey, I'd do it easily in ant", which lead me to use to generate the wars during the "package" phase (on which we arlready have all the files). Sort of like this:

    
      maven-antrun-plugin
        1.3
        
          
            package
            
              run
            
            
                
                
                            
                
                  
                    
                  
                
                
                  
                    
                  
                
                
            
          
        
      
    

    (to be fair, I did not delete the original file, but you should be able to do so.)

    In your case, you could package one war without the alternate web.xml, rename/move it over the original web.xml, then package the second war.

提交回复
热议问题