java - Maven多模块项目的构建顺序?

情况是,我有两个结构相同的Maven多模块项目:

Parent
    - Module 1
    - Module 2

当我构建项目 1 时,我看到先构建父级(顺序为 parent->module1->module2)。但是对于项目 2,最后构建父级(顺序为 module1->module2->parent)。为什么这两个项目有不同的构建顺序?另外,如何手动控制构建顺序?

更新 1:
两个父项目都是简单的POM项目,没有源代码,所以无法按照依赖图解释构建顺序。

更新 2:
除了 GAV 和子模块名称之外,父 POM 相同:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>parent-group-id</groupId>
    <artifactId>parent-artifact-id</artifactId>
    <version>parent-version</version>
    <packaging>pom</packaging>
    <name>parent-name</name>
    <modules>
        <module>module-1</module>
        <module>module-2</module>
    </modules>
</project>

最佳答案

构建顺序由 Maven react 器确定,这是一种通过对项目进行排序来自动确保多模块构建的正确构建顺序的机制。

见 the official documentation了解它的工作原理。

上面写着:

The following relationships are honoured when sorting projects:

  • a project dependency on another module in the build
  • a plugin declaration where the plugin is another modules in the build
  • a plugin dependency on another module in the build
  • a build extension declaration on another module in the build
  • the order declared in the element (if no other rule applies)

您无法手动控制构建顺序。如果您想更改顺序,您必须对您的项目做出影响 react 堆排序顺序的更改。

https://stackoverflow.com/questions/11131575/

相关文章:

ios - Xcode 8 无法存档 "Command/usr/bin/codesign faile

linux - 使用make构建后的.d文件是什么

java - 如何在命令行中编译多个java源文件

java - Maven 编译器插件总是将一组源检测为 "stale"

jenkins - 使用 H/1 * * * * 每分钟运行一次 Jenkins 作业

c++ - Visual Studio 2013 错误 MS8020 Build tools v14

.net - 复制本地如何工作? log4net.dll 没有被复制到 MyProject 输出目录

c# - 使用 CMake 生成 C# 项目

macos - xcode4:链接器错误:找不到选项的目录

ios - React-native:如何从 Windows 构建 ios