Share test resources between maven projects

前端 未结 4 1689
太阳男子
太阳男子 2020-11-29 04:07

There is a clear solution for sharing the common test code between maven projects using test-jar goal of maven-jar-plugin plugin (see here).

<
4条回答
  •  北海茫月
    2020-11-29 04:22

    There is already a goal to build a test jar from maven.

    Assuming you need something a little more flexible, you can use the jar plugin to package your test resources and run that goal with the main package goal with something like this.

          
            org.apache.maven.plugins
            maven-jar-plugin
            
              
                package
                
                  jar
                
                
                  test-resources
                  
                    **/*.whatever-you-want
                  
                
              
            
          
    

    Whatever you want bundled would be added to the project-name-version-test-resources.jar when the jar goal is run.

    You could then include it in a project via the same dependency you use above.

提交回复
热议问题