在 Maven 中,目标目录是保存构建的所有输出的地方。许多其他构建系统(如 sbt、scala 构建工具)也遵循此约定。
出现的问题是“为什么要这样称呼目标目录?”。是因为这个目录是构建过程的“目标”还是什么?
在 Maven 中,目标目录是保存构建的所有输出的地方。许多其他构建系统(如 sbt、scala 构建工具)也遵循此约定。
出现的问题是“为什么要这样称呼目标目录?”。是因为这个目录是构建过程的“目标”还是什么?
我的猜测是目标目录中会发生很多不同的事情,而不仅仅是构建。例如,如果您执行 mvn jetty:run,它将使用 target 中的类和 maven 项目中的文件运行一个 jetty Web 服务器。
我认为 target 已经被用作计算机科学中各种创造性行为的目标文件夹已经有一段时间了。许多 linux 命令的文档都使用了该术语。由于大多数构建都是在复制文件或创建文件夹,因此它的命名法类似于这些命令是有道理的。
从 mv 信息页面:
The mv command is used to rename and move files and directories. Its general syntax is:
mv [options] argument(s)
The arguments are names of files and directories. If two file names are provided as arguments, mv renames the first as the second. If a list of arguments is provided and the final argument in the sequence is the name of an existing directory, mv moves all of the other items into that directory. If the final argument is not an existing directory and more than two arguments are provided, an error message is returned.
mv's syntax can also be expressed in a less general form as:
mv [options] source target
If the target file is located in the same directory as the source file, then the source file can only be renamed. If both are in different directories, then the source file is moved to the directory named in the target argument, in which it can keep its original name or be assigned a new name. If the target is a directory, then the source file or directory is moved into that directory and retains its original name.