Disable maven plugins when using a specific profile

后端 未结 3 1531
北海茫月
北海茫月 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:36

    There is a neat way to disable plugin execution when specific profile is active.

    Firstly you need to add an identifier to plugin execution like:

    
        
            
            
                nl.geodienstencentrum.maven
                sass-maven-plugin
                2.1
                
                    
                        styles-compilation 
                        generate-resources
                        
                            update-stylesheets
                        
                    
                
            
    

    Then you need to define a profile in which this plugin will NOT be executed:

    
        
            no-sass
            
                
                    
                        nl.geodienstencentrum.maven
                        sass-maven-plugin
                        2.1
                        
                            
                                styles-compilation 
                                none 
                            
                        
                    
                
            
        
    
    

    Now if you run standard maven build:

    mvn clean package
    

    the sass-maven-plugin will be executed, yet when running:

    mvn clean package -P no-sass
    

    the sass-maven-plugin will not be executed.

提交回复
热议问题