Reputation: 2524
I'm implementing a simple RMI server and client. I wanted to speed up the tedious task of adding server codebase each time (lots of terminal-bloating text), so I decided to use the maven exec plugin. Here's how a part of my pom.xml
looks now:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<argument>/media/files/EclipseWorkspace/JavaSE/rozprochy/lab2/RmiServer/target/classes</argument>
<argument>-Djava.rmi.server.codebase=file:/media/files/EclipseWorkspace/JavaSE/rozprochy/lab2/RmiServer/target/classes/</argument>
<argument>engine.ComputeEngine</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
Everything's fine when i run mvn exec:exec
in the console. The problem arises when I want to let the user specify the rmiregistry port for instance as an argument to the program. Basically, I'd like to add extra arguments from console, in addition to those specified in the POM file. All the solutions I've found overwrote the hardcoded args, when specifying new args from console, and this undesirable. Is it possible to do this somehow?
Upvotes: 4
Views: 1053
Reputation: 544
This is kind of a twisted workaround but I couldn't think of any other way to achieve what you want
Define a property in your pom with the default value for your additional parameter
<properties>
<extra.argument.from.console>extra.argument.from.console.default.value</extra.argument.from.console>
</properties>
In your execution add that property as an argument
<argument>${extra.argument.from.console}</argument>
When invoking maven give value to that property if you don't want to use the default value
mvn exec:exec -Dextra.argument.from.console=value.you.want
Upvotes: 3