What is maven -D meaning?

Viewed 1715

I saw some maven commands which have -D inside. For example:

mvn clean install -Duser=john -Dpw=122345

I cannot find anything about it on the internet. Can someone show me some official documentation on what it means?

2 Answers

Command line tools usually have a --help option that you can use to find this info. Doing mvn --help yields this info about -D:

-D,--define <arg>                      Define a system property

-Dname=value is declaring variable with name "name" and value "value".

This variable can be used in pom.xml like this ${name}. Such expression will by replaced by "value".

Example

    <dependency>
        <groupId>com.acme</groupId>
        <artifactId>lolipop-factory</artifactId>
        <version>${name}</version>
    </dependency>

will in fact work as

    <dependency>
        <groupId>com.acme</groupId>
        <artifactId>lolipop-factory</artifactId>
        <version>value</version>
    </dependency>

if you run it as mvn -Dname=value compile

It could be accessed from maven plugins as well.

Related