首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

maven惯用配置的变量

2013-03-01 
maven常用配置的变量maven的变量maven定义了很多变量属性,参考这里 http://docs.codehaus.org/display/MAV

maven常用配置的变量
maven的变量

maven定义了很多变量属性,参考这里
http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide

1)内置属性

${basedir} represents the directory containing pom.xml${version} equivalent to ${project.version} or ${pom.version}


2)Pom/Project properties
所有pom中的元素都可以用 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 } refers to the name of the project.${project.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


3)本地用户设定
所有用的的 settings.xml 中的设定都可以通过 settings. 前缀进行引用
${settings.localRepository } refers to the path of the user's local repository.${maven.repo.local } also works for backward compatibility with maven1 ??


4)环境变量
系统的环境变量通过 env. 前缀引用
${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>


5)java系统属性
所有JVM中定义的java系统属性.

6)用户在pom中定义的自定义属性
<project>     ...     <properties>         <my.filter.value>hello</my.filter.value>     </properties>     ... </project>

则引用 ${my.filter.value } 就会得到值 hello

7)上级工程的变量
上级工程的pom中的变量用前缀 ${project.parent } 引用. 上级工程的版本也可以这样引用: ${parent.version }.maven的变量


8)引用属性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().


汇总变量列表:
*  project (from [1])
          o project.distributionManagementArtifactRepository
          o project.artifact
          o project.parent
          o project.file
          o project.artifacts
          o project.parentArtifact
          o project.pluginArtifacts
          o project.remoteArtifactRepositories
          o project.pluginArtifactRepositories
          o project.attachedArtifact
    * settings (from [2])
          o settings.offilne
          o settings.interactive
    * rootless (from [3])
          o localRepository
          o reactorProjects
    * java properties (from [4])
          o java.version
          o java.vendor
          o java.vendor.url
          o java.home
          o java.vm.specification.version
          o java.vm.specification.vendor
          o java.vm.specification.name
          o java.vm.version
          o java.vm.vendor
          o java.vm.name
          o java.specification.version
          o java.specification.vendor
          o java.specification.name
          o java.class.version
          o java.class.path
          o java.library.path
          o java.io.tmpdir
          o java.compiler
          o java.ext.dirs
          o os.name
          o os.arch
          o os.version
          o file.separator
          o path.separator
          o line.separator
          o user.name
          o user.home
          o user.dir

热点排行