How to get Maven to run war:exploded but not war:war

后端 未结 5 1664
长情又很酷
长情又很酷 2020-12-04 16:30

I have a Maven pom that uses war. But actually, I don\'t want build the war-file, I just want all the dependent jars collect

5条回答
  •  醉梦人生
    2020-12-04 16:52

    The only way I can think of to do what you want is to set use pom packaging (or create a custom packaging) and bind the required goals from the war packaging to the relevant phases of the lifecycle. If you go for pom packaging you can use define the war:war execution in a profile to allow you to package it, but you'll need to use the build-helper-maven-plugin attach-artifact goal to attach the war to the pom.

    Note with this approach if you want to use any other war-specific processing it may cause you problems.

    The lifecycle bindings for war packaging are listed in the Introduction to The Build Lifecycle (see the "Default Lifecycle Bindings - Packaging ejb / ejb3 / jar / par / rar / war" section).

    To bind the relevant plugin executions to the pom packaging you would do as follows:

    
      
        
          maven-resources-plugin
          
            
              process-resources
              process-resources
              
                resources
              
            
          
        
        
          maven-compile-plugin
          
            
              compile
              compile
              
                compile
              
            
          
        
        
          maven-resources-plugin
          
            
              process-test-resources
              process-test-resources
              
                testResources
              
            
          
        
        
          maven-surefire-plugin
          
            
              test
              test
              
                test
              
            
          
        
        
        
    

提交回复
热议问题