Using the plugin (common)

Configuration

to use the plugin you need to add into your pom.xml (the first time you use the plugin, if you don't specify the version like in the following example, call maven with the "-U" option)

        
<project>
  ...
  <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.9.2</version>
        ... (see other usage or goals for details) ...
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>
            
      

Displaying scala help and version

mvn scala:help

Displaying the command line used

To display command used when process is spawned set the property displayCmd to true. (In the incremental mode no process is spawned, so example below overrides default of recompileMode to all).

        
$> mvn scala:compile -DdisplayCmd=true -DrecompileMode=all

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'scala'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building fooA
[INFO]    task-segment: [scala:compile]
[INFO] ----------------------------------------------------------------------------
[INFO] [scala:compile]
[INFO] cmd:  /home/dwayne/bin/soft-linux/jdk-1.5.0_07/jre/bin/java -classpath /home/dwayne/.m2/repository/scala/scala-compiler/2.6.0/scala-compiler-2.6.0.jar:/home/dwayne/.m2/repository/scala/scala-library/2.6.0/scala-library-2.6.0.jar scala.tools.nsc.Main -classpath /home/dwayne/work/oss/liftweb-archetypes/fooA/target/classes:/home/dwayne/.m2/repository/scala/scala-library/2.6.0/scala-library-2.6.0.jar -d /home/dwayne/work/oss/liftweb-archetypes/fooA/target/classes -sourcepath /home/dwayne/work/oss/liftweb-archetypes/fooA/src/main/scala /home/dwayne/work/oss/liftweb-archetypes/fooA/src/main/scala/bar/foog/App.scala
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Sat Nov 10 22:28:54 GMT+01:00 2007
[INFO] Final Memory: 7M/63M
[INFO] ------------------------------------------------------------------------
      
      

Changing the scala version

Since version 2.7 of the plugin, the scala version to use is detected from dependency to scala-library. So it suggested to not use scalaVersion configuration. But if you want to define explicitly the version of scala used to compile,... use 'scalaVersion', ex:

          
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.9.2</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
        </configuration>
      </plugin>