Search code examples
bashmavenmaven-2maven-3

Bash script pass arguments to maven


I have a bash script called runMain that is shown below:

#!/bin/bash

mvn exec:java -Dexec.mainClass=org.fjx.main.Main -f fjxRepo/pom.xml -Dexec.args="$@"

So I want to pass the arguments of the bash script to the maven exec. Even though this works when there is only one argument, it does not work for more than one argument e.g. 2 arguments.

Please help me fix this.


Solution

  • If you want to pass the whole argument string and none of the arguments have whitespace in them, you can use $* instead of $@.