Share test resources between maven projects

前端 未结 4 1697
太阳男子
太阳男子 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:28

    Using maven-dependency-plugin we can put the resource needed in the right directory, only modifying the pom on dependent project is needed:

    
       org.apache.maven.plugins
       maven-dependency-plugin
       
          
             generate-test-resources
             
                unpack
             
             
                
                   
                      dependeeGroupId
                      dependeeArtifactId
                      dependeeVersion
                      test-jar
                      ${project.build.directory}/test-classes
                      resourceNeeded.txt
                      true
                   
                
             
          
       
    
    

    type is used to get test resource
    outputDirectory is used to put the resource usable in tests

    Documentation here: https://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html

提交回复
热议问题