Java pom.xml 中 ${project.basedir} 的含义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35985090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 17:19:00  来源:igfitidea点击:

Meaning of ${project.basedir} in pom.xml

javamavenpom.xml

提问by TodayILearned

What is the meaning of

的意义是什么

<directory>${project.basedir}</directory>

and

${project.build.directory}

in pom.xml

在 pom.xml 中

回答by Tunaki

There are a set of available properties to all Maven projects.

所有 Maven 项目都有一组可用的属性。

From Introduction to the POM:

POM 简介

project.basedir: The directory that the current project resides in.

project.basedir: 当前项目所在的目录。

This means this points to where your Maven projects resides on your system. It corresponds to the location of the pom.xmlfile. If your POM is located inside /path/to/project/pom.xmlthen this property will evaluate to /path/to/project.

这意味着这指向您的 Maven 项目在您的系统上的位置。它对应于pom.xml文件的位置。如果您的 POM 位于内部,/path/to/project/pom.xml则此属性将评估为/path/to/project.

Some properties are also inherited from the Super POM, which is the case for project.build.directory. It is the value inside the <project><build><directory>element of the POM. You can get a description of all those values by looking at the Maven model. For project.build.directory, it is:

某些属性也继承自Super POM,对于project.build.directory. 它是<project><build><directory>POM 元素内的值。您可以通过查看Maven 模型来获得所有这些值的描述。对于project.build.directory,它是:

The directory where all files generated by the build are placed. The default value is target.

放置构建生成的所有文件的目录。默认值为target

This is the directory that will hold every generated file by the build.

这是将保存构建生成的每个文件的目录。

回答by Matthias

${project.basedir}is the root directory of your project.

${project.basedir}是你项目的根目录。

${project.build.directory}is equivalent to ${project.basedir}/target

${project.build.directory}相当于 ${project.basedir}/target

as it is defined here: https://github.com/apache/maven/blob/trunk/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml#L53

正如这里定义的那样:https: //github.com/apache/maven/blob/trunk/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml# L53