Common test data for multiple independent maven projects

﹥>﹥吖頭↗ 提交于 2019-12-03 21:16:44

It is possible to share resources with Maven, for example with the help of the Assembly and Dependency plugins. Basically:

  1. Create a module with a packaging of type pom to hold the shared resources
  2. Use the assembly plugin to package the module as a zip
  3. Declare a dependency on this zip in "consumer" modules
  4. And use dependency:unpack-dependencies (plus some exclusion rules) to unpack the zip

This approach is detailed in How to share resources across projects in Maven. It requires a bit of setup (which is "provided") and is not too complicated.

Just place them in a tree in the src/main/resources directory of a separate module specially to share the test data. They will be added to the jar file and me nicely compressed and versioned in your nexus repository, file-share, ~/.m2/repository or whatever you use to store/distribute maven artifacts.

Then just add a dependency in the projects you need the data in the test scope and use resource loading to get them from the jars.

You do not need any special plugins or other infrastructure. This just works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!