如何覆盖命令行中的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
b $ b
但是这被忽略,我得到 test-1.0.jar
。我尝试更改另一个属性,如outputDirectory,directory,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.
这是什么正确的方法?
推荐答案
请参阅 POM简介
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 = build clean package
这篇关于如何覆盖命令行中的maven属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文