Skip a submodule during a Maven build

后端 未结 5 1761
暖寄归人
暖寄归人 2020-11-30 17:42

We have a need to be able to skip a submodule in certain environments.

The module in question contains integration tests and takes half an hour to run. So we want t

5条回答
  •  余生分开走
    2020-11-30 18:32

    The notion of multi-module projects is there to service the needs of codependent segments of a project. Such a client depends on the services which in turn depends on say EJBs or data-access routines. You could group your continuous integration (CI) tests in this manner. I would rationalize that by saying that the CI tests need to be in lock-step with application logic changes.

    Suppose your project is structured as:

    project-root
      |
      + --- ci
      |
      + --- client
      |
      + --- server
    

    The project-root/pom.xml defines modules

    
      ci
      client
      server
    
    

    The ci/pom.xml defines profiles such as:

    ... 
    
      
        default
        
          true
        
        
           maven-surefire-plugin
           
             true
           
         
      
      
        CI
        
           maven-surefire-plugin
           
             false
           
         
      
    
    

    This will result in Maven skipping tests in this module except when the profile named CI is active. Your CI server must be instructed to execute mvn clean package -P CI. The Maven web site has an in-depth explanation of the profiling mechanism.

提交回复
热议问题