Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the fastest way to compile Scala files using maven?

Tags:

maven

scala

ideally using the FSC compiler

Question becomes what command or pom file set up should I use?

I'm currently using the scala maven plugin but it doesn't seem to actually use fsc

thanks

like image 734
James Avatar asked May 25 '11 20:05

James


People also ask

Can I use Maven for Scala?

The default maven plugin does not support Scala out of the box, so you need to install the m2eclipse-scala connector. This connector understands the Scala maven plugin and links the compile phase to the Eclipse Scala Builder. You can install both plugins by pointing Eclipse to the m2eclipse-scala update site.

What is the difference between SBT and Maven?

Once you familiarize yourself with how one Maven project builds you automatically know how all Maven projects build saving you immense amounts of time when trying to navigate many projects. On the other hand, SBT is detailed as "An open-source build tool for Scala and Java projects".

What is Maven Scala plugin?

The scala-maven-plugin is used for compiling/testing/running/documenting scala code in maven.


1 Answers

You can run the fsc as part of the compile phase of maven by adding the following to the plugins section of your pom.xml

<plugin>
 <groupId>org.scala-tools</groupId>
 <artifactId>maven-scala-plugin</artifactId>
 <version>2.9.1</version>
 <executions>
  <execution>
   <id>cc</id>
   <goals>
     <goal>cc</goal>
   </goals>
   <phase>compile</phase>
   <configuration>
    <useFsc>true</useFsc>
    <once>true</once>
   </configuration>
  </execution>
 </executions>
</plugin>

Of course you have to remove the standard scala compile execution from your POM if necessary.

like image 172
n_l Avatar answered Oct 06 '22 00:10

n_l