在Maven中为多项目强加构建顺序

Kar*_*och 14 maven-3 maven

我有一个像maven这样的多项目:

paren-project
  -> plugin-project
  -> testbed-project
Run Code Online (Sandbox Code Playgroud)

plugin项目生成一个JAR,手动将其复制到特定的子目录testbed(使用等嵌入式脚本).重点:我不希望插件JAR位于testbed的类路径中.

但我找不到强制插件项目在测试平台项目之前构建的解决方案.如果我将插件项目设置为testbed项目的依赖项,则会将其添加到类路径中.

任何解决方案,还是我必须切换到像,这样的构建系统?

Cha*_*suk 19

正如http://maven.apache.org/guides/mini/guide-multiple-modules.html中提到的那样

反应器排序

Because modules within a multi-module build can depend on each other, 
it is important that The reactor sorts all the projects in a way that 
guarantees any project is built before it is required.

The following relationships are honoured when sorting projects:
Run Code Online (Sandbox Code Playgroud)
  1. 项目依赖于构建中的另一个模块
  2. 插件声明插件是构建中的另一个模块
  3. 插件依赖于构建中的另一个模块
  4. 在构建中的另一个模块上构建扩展声明
  5. 模块元素中声明的顺序(如果没有其他规则适用)

请注意,仅使用"实例化"引用 - dependencyManagement和pluginManagement元素不会导致更改reactor排序顺序


Arp*_*pit 7

Maven是一个多功能系统.无需切换.

您可以像这样添加依赖项:

<dependency>
  <groupId>group</groupId> 
  <artifactId>artifact</artifactId> 
  <optional>true</optional> 
</dependency>
Run Code Online (Sandbox Code Playgroud)

这样,依赖项将不会包含在类路径中.

阅读有关可选依赖性的更多信息