Disable maven plugins when using a specific profile

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

    Building on Krzysiek's answer, you don't need to define explicit executions, just have a look at the output maven gives you and disable the default executions.

    For instance, given the following output from maven:

    [INFO] --- maven-resources-plugin:2.7:copy-resources (prepare-dockerfile) @ tilbud ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    ...
    [INFO]
    [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ tilbud ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    ....
    [INFO]
    [INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ tilbud ---
    ...
    [INFO]
    [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ tilbud ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    ...
    [INFO]
    [INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ tilbud ---
    ....
    

    The generated default execution names is listed in parenthesis after the plugin and goal. The following profile disables the plugins above:

    
        
            packageOnly
            
                
                    
                        
                            maven-compiler-plugin
                            
                                
                                    default-compile
                                    none
                                
                                
                                    default-testCompile
                                    none
                                
                            
                        
                        
                            maven-surefire-plugin
                            
                                
                                    default-test
                                    none
                                
                            
                        
                        
                            maven-resources-plugin
                            
                                
                                    default-resources
                                    none
                                
                                
                                    default-testResources
                                    none
                                
                                
                                    prepare-dockerfile
                                    none
                                
                            
                        
                    
                
            
        
    
    

提交回复
热议问题