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()
.
分享到:
相关推荐
打开你的`bashrc`(Linux/Mac)或`system environment variables`(Windows),添加以下内容: - Linux/Mac: ```bash export MAVEN_HOME=/usr/local/apache-maven-3.8.2 export PATH=$PATH:$MAVEN_HOME/bin ``...
在Java开发领域,MavenRepository是一个至关重要的概念,它是一个存储和检索项目构建依赖的仓库。这个仓库系统是Apache Maven的核心组成部分,它管理着各种Java库、框架和项目的JAR文件,使得开发者能够轻松地引用并...
- **Eclipse环境变量配置**:打开Eclipse,依次点击`Window -> Preferences -> Java -> Build Path -> Classpath Variables`,进行以下操作: - 新建`MAVEN_HOME`环境变量,值为`D:\DEV\maven-1.0.2`。 - 新建`...
这可以通过`Window > Preferences > Java > Build Path > Classpath Variables`完成。创建名为`M2_REPO`的新变量,将其值设置为Maven的本地仓库路径,通常是`~/.m2/repository`。 7. **Maven配置文件**:Maven的...
在`Window -> Preferences -> Java -> Build Path -> Classpath Variables`中,需要确保`M2_REPO`变量指向正确的本地仓库路径,这样MyEclipse才能正确识别Maven的依赖。 5. **创建Maven项目** 创建一个新的Maven...
### Maven: The Complete Reference #### 1. Introducing Apache Maven **1.1 Maven - What is it?** Apache Maven is a software project management and comprehension tool that primarily targets Java ...
1. 打开Eclipse,进入`Window > Preferences > Java > Build Path > Classpath Variables`。 2. 查看或创建名为`M2_REPO`的类路径变量,其值应设置为`<USER_HOME>/.m2/repository`。 3. 在Maven项目中,确保`Build ...
用Go编写的Maven POM解析器,支持递归变量扩展/解释。 图书馆 pom.xml : ${p1}.${a.b}.z < p1>x${p.b} < p>x model , err := Unmarshal ([] byte ( data )) // supply additional variables model . ...
2. MAVEN_HOME should already set in system variables. 脚步: 1. Open cmd and run following commands: 2. cd projectPath 3. mvn clean 4. mvn test 报告: 使用的报告: 1. Extent Report 如何创建虚拟设备...
- 在Eclipse中,你需要在`window->preferences->java->Build Path->Classpath Variables`中添加`MAVEN_HOME`和`MAVEN_REPO`,以使Eclipse能够识别Maven。 2. **Eclipse项目工程配置**: - 创建新的Java项目时,...
window >> preferences >> Java >> Build Path >> Classpath Variables 新建一个 M2_REPO 的变量,变量值指向你系统的Maven2的数据仓库位置 或者直接安装eclipse的maven插件,然后设置你的M2_REPO。 管理平台还需要...
(3)配置环境变量:将maven中的bin的路径添加到system variables的PATH中 (4)测试maven是否安装成功 在命令行中输入mvn -version 如果如下下图所示结果,证明配置正确 3. 下载dl4j的examples,网址为: ...
Java编程语言中的面向对象程序设计和Java基础知识点 ...这份文件涵盖了Java编程语言中的面向对象程序设计、constructors、methods、variables等基础知识点,同时还涉及到Maven和Eclipse等开发工具的使用。
4. 查看变量值:在变量视图(Variables View)中实时查看变量状态。 五、Eclipse的构建工具与版本控制 1. 构建工具:Eclipse内置了Ant和Maven支持,可以自动化构建项目。 2. 版本控制:集成Git、SVN等,实现代码...
Variables page. Add a new one with a name of M2_REPO and Path of to your local Maven repository (/Users/${username}/.m2/repository on OS X and C:\Documents and Settings\${username}\.m2\repository on...
- **设置自定义代码模板快捷键**:在“File”菜单下的“Settings”中,找到“Editor” -> “Live Templates” -> “Context variables”,根据需求自定义模板和对应的快捷键。 - **设置文件、项目、全局的编码格式...
- 方法一:在Eclipse的`Window -> Preferences -> Java -> Build Path -> Classpath Variables`中新建名为M2_REPO的变量,路径指向Maven仓库的实际位置。 - 方法二:直接修改Eclipse的classpath,添加M2_REPO路径...