Disable maven plugins when using a specific profile

后端 未结 3 1543
北海茫月
北海茫月 2020-12-08 02:17

I\'m looking to find a way of disabling a plugin execution if running with a particular profile.

This is the opposite of running a plugin if a profile is selected.

3条回答
  •  被撕碎了的回忆
    2020-12-08 02:48

    • Define your pom so that is has only the plugins you need in dev mode
    • Define a dev profile
    • Define a production profile which contains all plugins you want/need
    • Define the production profile as default

    example pom:

    
      
        production
    
        
          true
        
    
        
          
            
          
        
        
    
        
          dev
          
        
    
    

    To run in Dev Mode you can call the following:

    mvn -Pdev compile
    

    To run in Production Mode just use the normal steps:

    mvn compile
    

    In case you don't want/need to define anything special in your dev profile, you can omit its declaration and call your Dev Mode like this (! disables a profile):

    mvn -P!production compile
    

    Be aware: you may need to escape the exclamation mark since it is a special character in bash:

    mvn -P\!production compile
    

提交回复
热议问题