首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Maven Predefined Properties

Maven Predefined Properties

作者头像
杨焱
发布于 2021-12-07 21:02:32
发布于 2021-12-07 21:02:32
8750
举报
文章被收录于专栏:杨焱的专栏杨焱的专栏

发表于2017-07-202019-01-01 作者 wind

List of predefined Maven properties

This list is based on a wiki page from Codehaus (http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide) which unfortunately has been gone with the shutdown of Codehaus

Note: In Maven 3.0, all pom.* properties are deprecated. Use project.* instead!

Built-in properties

{basedir} represents the directory containing pom.xml {version} equivalent to {project.version} (deprecated: {pom.version})

Pom/Project properties

All elements in the pom.xml, can be referenced with the project. prefix. This list is just an example of some commonly used elements. (deprecated: {pom.} prefix) {project.build.directory} results in the path to your “target” directory, this is the same as {pom.project.build.directory} {project.build.outputDirectory} results in the path to your “target/classes” directory {project.name} refers to the name of the project (deprecated: {pom.name} ). {project.version} refers to the version of the project (deprecated: {pom.version}).

Local user settings

Similarly, values in the user’s settings.xml can be referenced using property names with settings.prefix. ${settings.localRepository} refers to the path of the user’s local repository

Environment variables

Environment variables can be referenced using the env prefix {env.M2_HOME} returns the Maven2 installation path. {java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example: <jvm>

Java system properties

All Java System Properties defined by the JVM: {file.separator} {java.class.path} {java.home} {java.vendor} {java.vendor.url} {java.version} {line.separator} {os.arch} {os.name} {os.version} {path.separator} {user.dir} {user.home} {user.name} …

Custom properties in the POM

User defined properties in the pom.xml.<project> ... <properties> <my.filter.value>hello</my.filter.value> </properties> ... </project>

${my.filter.value} will result in hello if you inserted the above XML fragment in your pom.xml

Parent Project variables

How can parent project variables be accessed? You can use the prefix: {project.parent}. A good way to determine possible variables is to have a look directly at the API. I’m currently using Maven 2.2.1, and to access the Parent you can use {project.parent}. This will return an org.apache.maven.project.MavenProject instance. To access the parent version:

Reflection Properties

The pattern {someX.someY.someZ} can simply sometimes mean getSomeX().getSomeY().getSomeZ(). Thus, properties such as {project.build.directory} is translated to getProject().getBuild().getDirectory().

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-07-20,如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • List of predefined Maven properties
    • Built-in properties
    • Pom/Project properties
    • Local user settings
    • Environment variables
    • Java system properties
    • Custom properties in the POM
    • Parent Project variables
    • Reflection Properties
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档