Maven variables

Maven中的内置变量

注:只是记录,方便查阅。

Build

  • ${version } 版本
  • ${basedir } 项目根目录(包含pom.xml文件的目录)

 

Project

  • ${project.build.directory } results in the path to your "target" dir, this is the same as ${pom.project.build.directory }
  • ${project.build. outputD irectory } results in the path to your "target/classes" dir
  • ${project.name } or ${pom.name } refers to the name of the project.
  • ${project.version } or ${pom.version } refers to the version of the project.
  • ${project.build.finalName } refers to the final name of the file created when the built project is packaged
  • ${project.packaging}package type, eg:jar, war

 

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.home}../bin/java.exe</jvm>

Java system properties

All Java System Properties defined by the JVM.

 

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: ${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() .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值