mavenmaven-jetty-pluginsystem-variable

maven jetty plugin how to pass system variable


How can I pass a system variable to my application using the jetty:run command?
Is it possible to pass it like:

mvn jetty:run -Dmy.variable=something

And use it in my code:

String myVariable = System.getProperty("my.variable");

Solution

  • mvn jetty:run -DcommandLineName=value
    
    <plugin>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>maven-jetty-plugin</artifactId>
       <version>6.1.10</version>
       <configuration>
            <systemProperties>
                <systemProperty>
                    <name>arg1</name>
                    <value>${commandLineName}</value>
                </systemProperty>
            </systemProperties>
        </configuration>
    </plugin>
    

    for more details see this