如何在命令行中覆盖 maven 属性? [英] How to override maven property in command line?
本文介绍了如何在命令行中覆盖 maven 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下由 Maven 3.0.4 运行的普通 pom.
I have the following plain pom running by Maven 3.0.4.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
我正在尝试像这样覆盖命令行中的默认设置:
I am trying to override default settings in command line like this:
mvn -Dproject.build.finalName=build clean package
但这被忽略了,我得到了 test-1.0.jar
.我尝试更改其他属性,例如 outputDirectory、目录、artifactId,但也失败了.
But this this is ignored, and I get test-1.0.jar
. I've tried to change another properties, like outputDirectory, directory, artifactId, but also failed.
做这件事的正确方法是什么?
What is the proper way to do this thing?
推荐答案
finalName 被创建为:
finalName is created as:
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
解决方案之一是添加自己的属性:
One of the solutions is to add own property:
<properties>
<finalName>${project.artifactId}-${project.version}</finalName>
</properties>
<build>
<finalName>${finalName}</finalName>
</build>
现在试试:
mvn -DfinalName=构建干净的包
这篇关于如何在命令行中覆盖 maven 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文