How to stop Maven's verify phase rebuilding the artifact?

前端 未结 5 1886
太阳男子
太阳男子 2020-12-31 21:15

Imagine a Java project built using Maven for which I have:

  • some fast-running unit tests that:
    • developers should run before committing
    • my CI s
5条回答
  •  攒了一身酷
    2020-12-31 21:55

    You can define a Maven profile that will be used to execute only the integration tests. I do this a lot.

    Something like this:

    
        
            integration
            
                false
            
            
                
                    
                        maven-surefire-plugin2.17
                        
                            true
                        
                    
                    
                        maven-war-plugin2.4
                        
                            /tmp
                        
                    
                
            
        
    
    

    You would invoke this with:

    mvn verify -Pintegration
    

    Unfortunately the WAR plugin can't be skipped, but you can send its output to somewhere out of the way (I've used /tmp). If you really want to save milliseconds, you could also make it ignore the web resources (except web.xml, it won't work without that).

    You can also use the profile to skip any other plugins that you might be running, eg the assembly plugin, Cobertura, PMD, etc.

提交回复
热议问题