Is it possible to execute two different maven exec-maven-plugin in a single POM

后端 未结 6 2061
臣服心动
臣服心动 2021-01-30 09:59

I execute the following code using mvn exec:java com.mycompany.FooServer.

I would like to add another server which I can execute like mvn exec:java co

6条回答
  •  感动是毒
    2021-01-30 10:58

    For me including configuration in the execution block didn't work and maven complained about main class not being set. But inspired by Dario's answer I'd answer this question as follows:

    
        
            foo
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
                        1.3.2
                        
                            com.mycompany.FooServer
                        
                    
                
            
        
        
            bar
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
                        1.3.2
                        
                            com.mycompany.BarServer
                        
                    
                
            
        
    
    

    Which then allows you to run one or the other server using:

    mvn exec:java -Pfoo
    

    or

    mvn exec:java -Pbar
    

    Cheers,

提交回复
热议问题