我也有其他项目取决于 A (及其测试):
A< ; - B< - B_t为了简化一些测试,我引入了一个帮助测试的新库基于 A :
A< - Atesthelper所以 A_t (和 B_t )将依赖于此测试助手,如下所示:
A< - A_t ^ | | v Atesthelper然而,当我创建Maven项目(pom.xml)时,事情是将该项目的项目和测试捆绑在同一个pom.xml中。而且我为 Atesthelper创建一个新的pom.xml
所以现在变成:
(A< - A_t) ^ | | v Atesthelper哪个是循环依赖。在pom.xml中有可能以某种方式指定 Atesthelper 只是测试构建目标的依赖关系,而不是 A 模块本身?
所以构建顺序应该是:A,Atesthelper,A_t。即A和A_t在同一个pom中指定,不应该同时生成。
提前感谢
解决方案您需要解决的问题是从 Atesthelper 到 A 的依赖关系,那么其他一切都可以正常工作: A 取决于Atesthelper , B 取决于Atesthelper 和 A 和 > B 将同时包含源和测试。在 A 和 B 中,Atesthelper 将包含在范围测试中。这是你的目标状态。
你如何到达那里?您需要将Atesthelper 的项目提取到单独的项目中。通常,这些是接口或其他常见功能,应该放在单独的项目中 - 我们称之为ACommon 。所以您的目标布局应该如下所示:
ACommon< - Atesthelper ^ ^ | / A(还有B)什么样的功能是Atesthelper 取决于 A ?你可以把它移动到一个单独的项目( ACommon )?
my set up is this. I have project A, and a test project depending on A:
A <- A_tI also have other projects depending on A (and their tests):
A <- B <- B_tTo simplify some of the testing I introduce a new library helping test stuff based on A:
A <- AtesthelperSo A_t (and B_t) will depend on this test helper, like this:
A <- A_t ^ | | v AtesthelperHowever when I create Maven projects (pom.xml) it seems the usual thing is to bundle both the project and the test of that project in the same pom.xml. And I create a new pom.xml for the Atesthelper
So now it becomes:
(A <- A_t) ^ | | v AtesthelperWhich is a circular dependency. Is it possible in the pom.xml to somehow specify that Atesthelper is only a dependency of the test build target, and not the A module in itself?
So the build order should be: A, Atesthelper, A_t. I.e. A and A_t which are specified in the same pom, should not be build at the same time.
Thanks in advance.
解决方案The problem that you need to solve is the dependency from Atesthelper to A, then everything else will work fine: A depends on Atesthelper, B depends on Atesthelper and both A and B will contain both sources and tests. Atesthelper will be included with scope test in both A and B. That's your target state.
How do you get there? You need to extract the items that Atesthelper is depending on into a separate projects. Typically, these are interfaces or other common functionality, which should be put into a separate project anyway - let's call it ACommon. So your target layout should look like this:
ACommon <- Atesthelper ^ ^ | / A (and also B)What kind of functionality is Atesthelper depending on in A? Can you move it to a separate project (ACommon)?
更多推荐
解决测试,测试和测试项目之间的Maven循环依赖关系
发布评论