Click here to lend your support to: scala-maven-plugin and make a donation at www.pledgie.com !

Running a "main(args: Array[String])"

You must have a well define project, and it must compile your code successfully before (see Compiling ).

Running

So you can now run your scala app by defining the "mainClass" property :

mvn scala:run -DmainClass=org.example.MyClass

Using Launcher

You need to use launchers if you :

  • need to specify args and/or jvmArgs that are different from the main configuration
  • run and run again the same "configuration"/command line
  • want to store, some configuration for later user, or for sharing with other
  <plugin>
    <groupId>maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <configuration>
      <launchers>
        <launcher>
          <id>foo</id>
          <mainClass>org.example.MyClass</mainClass>
          <!-- args are optional -->
          <args>
            <arg>arg1</arg>
          </args>
          <!-- jvmArgs are optional -->
          <jvmArgs>
            <jvmArg>-Xmx128m</jvmArg>
            <jvmArg>-Djava.library.path=...</jvmArg>
          </jvmArgs>
        </launcher>
        <!-- you could define other launcher -->
      </launchers>
    </configuration>
  </plugin>
      

Now you can run the following command to run your launcher (the classpath used is the test classpath).

mvn scala:run -Dlauncher=foo

If you don't specify launcher or mainClass then the first launcher is used, in your case, the example below is equivalent to the example above.

mvn scala:run

If you need/which to specify some additional arguments at call time use "-DaddArgs=arg1|arg2|arg3" ('|' is used as separator)

Set the property 'displayCmd' to true, to display the command line used