如何在 Maven 中为 scm:checkin 目标使用 basedir 和 workingDirectory 参数?

How to use basedir and workingDirectory parameters for scm:checkin goal in Maven?

我是 Maven 的新手,我对 Maven SCM 插件的 basedirworkingDirectory 参数的用途和正确用法感到困惑。假设我有以下 file/folder 结构(在 Windows 中):

C:\fruits\
├───.git\
├───apples\
│   └───pom.xml
└───oranges\
    └───pom.xml

在执行 Maven 之前(通过从命令行调用 mvn.cmd),我将 shell 中的 当前目录 更改为“C:\fruits\apples ”。因此,在 Maven 的术语中,“C:\fruits\apples”成为 工作目录 ,其中包含用于 apples 项目的适当 pom.xml 文件。另一方面,在 Git 的术语中, 工作目录 是“C:\fruits”,因为这是检出整个 monorepo 分支的地方。

在构建过程中的某个时候,我使用 Maven SCM 插件推送一些修改。目前,在指定 scm:checkin 目标时,我提供 --define workingDirectory="C:\fruits",但我不确定这是否是正确的路径。此外,即使我目前根本没有定义 basedir 参数,该插件似乎也能正常工作,这令人惊讶,因为 documentationbasedir 列为唯一的 必需的 参数。不幸的是,文档没有解释 basedir 参数的用途(他们只是说它是“基本目录”,duh),也没有解释哪个“工作目录”(即是否在 Git 的意义或 Maven 的意义) workingDirectory 参数应该指向.

你能给我解释一下吗,我应该定义 SCM 插件的 basedirworkingDirectory 参数指向什么路径(当 Maven 正在处理我的 apples项目),为什么?

working directory SCM 插件的参数在 Git 的上下文中,即 .git 文件夹的位置

basedir 是 pom.xml 所在的目录。 Maven 有许多默认属性,其中之一是 basedir.

要了解有关其实现方式的更多信息,您还可以从 maven central 查看此插件的代码或查看您的本地 maven 存储库。