Intro
Because I couldn't find a clear overview of which properties are availabe in maven2 I started this page. It is a collection of things found in the offcial maven documentation and postings to the maven user mailing list.
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.
outputD
irectory
}
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: or${pom.version
}). -
${project.build.finalName
} refers to the final name of the file created when the built project is packaged
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 inhello
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()
.
Comments
Here is my list. Some of these are not yet on the list and some of them are already are. And I must admit that I am still not yet acquainted with some of them.
I also placed here where I got these from just in case somebody wants to know how I came up with this list and where to get more info (code-reading-wise).
Not sure though if this is the complete list (excluding plugin expressions and user-defined properties).
* 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
摘自:http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide
相关推荐
Maven 有预定义的构建生命周期,包括 `compile`、`test`、`package`、`install` 和 `deploy` 等阶段,每个阶段都有多个阶段目标(phases),如 `clean`、`resources` 和 `site`。 5. **插件(Plugins)** Maven ...
- **内置仓库**:Nexus预定义了几种常用的仓库,包括Maven Central、Releases、Snapshots和3rd Party等,分别用于不同的目的,如缓存中央仓库中的发布版本构件、部署组织内部的发布版本构件等。 - **部署构件到...
- **安装**:需要先安装 JDK,然后解压缩 Maven,配置 MAVEN_HOME 和 PATH 环境变量。 - **配置 Maven**:包括全局配置文件(%MAVEN_HOME%/conf/settings.xml)和用户配置文件(~/.m2/settings.xml)。全局配置文件...
4. **设置环境变量**:配置`M2_HOME`环境变量指向Maven的安装目录,并将`%M2_HOME%\bin`添加到系统`PATH`变量中。 5. **验证安装**:在命令行输入`mvn -version`来验证Maven是否安装成功。 ##### Unix系统上的安装...
3. **环境变量配置**: 配置`M2_HOME`环境变量指向Maven的安装目录,并将`%M2_HOME%\bin`添加到`PATH`环境变量中。 ### Maven的配置 1. **修改配置文件**: 编辑`conf/settings.xml`,配置本地仓库路径、远程仓库...
同时,在`PATH`环境变量中添加`%Maven_HOME%\bin`。 4. 验证安装:打开命令行,输入`mvn -version`,如果显示出Maven的版本信息,则表示安装成功。 ### Maven的使用 1. 创建新项目:使用`mvn archetype:generate`...
- Maven Eclipse插件或IntelliJ IDEA插件,方便在IDE中使用Maven。 - HTTP服务器,如Apache或Jetty,用于内部开发。 安装Maven2只需解压安装包,并设置环境变量`M2_HOME`指向安装目录,同时确保`JAVA_HOME`已设置。...
3. **配置环境变量**:为了让系统能够识别并使用Maven,你需要设置`M2_HOME`环境变量指向Maven的安装路径,并将`Maven的bin目录`添加到`PATH`环境变量中。 4. **验证安装**:打开命令行窗口,输入`mvn -version`,...
3. **配置环境变量**: 设置系统环境变量`M2_HOME`为Maven的安装路径,同时将Maven的bin目录添加到`PATH`环境变量中。 4. **验证安装**: 在命令行输入`mvn -v`,如果正确配置,将会显示Maven的版本信息。 ** ...
Maven使用约定优于配置的原则,意味着默认的构建过程和目录结构是预定义的,这极大地简化了项目管理工作。 在开发过程中,`mvn install`命令会编译源代码,运行测试,并将结果部署到本地仓库,使得其他项目可以通过...
4. **设置Maven配置**:可能包含自定义`settings.xml`文件的路径,这可以用来配置Maven仓库的位置,代理设置,以及其他的项目特定配置。 5. **验证安装**:最后,脚本可能会运行`mvn -version`来确认Maven已经正确...
1. **项目对象模型(Project Object Model, POM)**:Maven通过POM来描述项目,它是Maven配置的基础,包含了项目的元数据、依赖、构建指令等信息。 2. **坐标(Coordinates)**:每个Maven项目都有唯一的标识,由...
1. **环境变量配置**:首先,需要将Maven的安装路径添加到系统的PATH环境变量中,这样可以在命令行中直接使用`mvn`命令。Maven的主目录通常包含`bin`目录,其中包含可执行的`mvn`脚本。 2. **本地仓库配置**:Maven...
3. **配置环境变量**: 配置系统环境变量,包括`MAVEN_HOME`指向Maven的安装目录,以及在`PATH`变量中添加`%MAVEN_HOME%\bin`,确保可以在命令行中直接运行`mvn`命令。 4. **验证安装**: 打开命令行,输入`mvn -v`,...
3. **配置环境变量**:设置"M2_HOME"环境变量指向Maven的安装目录,并将"Maven的bin"目录添加到PATH环境变量中,这样可以在命令行中直接运行Maven命令。 4. **验证安装**:打开命令行终端,输入`mvn -v`或`mvn --...
生命周期包括清理(clean)、编译(compile)、测试(test)、打包(package)、验证(verify)、集成测试(integration-test)、部署(deploy)等阶段,每个阶段都有预定义的目标,如`mvn clean`用于清理项目生成的...
3. **生命周期(Lifecycle)**: Maven有一套预定义的构建阶段,如编译、测试、打包、部署等。 4. **插件(Plugins)**: Maven通过插件执行具体的构建任务,如JAR打包、源码生成等。 **三、Maven的安装** 1. **下载*...
1. **安装 Maven**:首先,你需要下载Maven 3.6.3的zip文件,解压后将其添加到系统的PATH环境变量中,以便在任何地方使用mvn命令。 2. **配置Maven**:在用户目录下创建一个名为`.m2`的文件夹,然后在其中创建`...