Search code examples
javamavenparameters

How to pass parameters to maven?


I am trying to call a parameter via maven command. This is how the definition of it looks like:

/**
 *
 * @parameter default-value=false
 */
private boolean myBool;

What would be the right way to set it via maven command line?

<groupid>:<artifactid>:<version>:<goal> -myBool=true

does not work


Solution

  • You should be able to set it as a property (see Maven Command Line Options)

    mvn -DmyBool=true <groupid>:<artifactid>:<version>:<goal>
    

    As noted by Diego Victor De Jesus in the comments:

    if it is a boolean parameter that should be set to true, you can do:

    mvn -DmyBool <groupid>:<artifactid>:<version>:<goal>