Creating a basic Scala project with Maven?

I am using Maven 3 to create a new Scala project. As I understand it, the way to create a new project with Maven is:

mvn archetype:generate 

Maybe I missed something, but could not find a single option offering the simplest Scala project (for example, the one that was obtained by lein new app ... for Clojure). Any help here?

+6
source share
1 answer

You can use mvn archetype:generate . You can choose, for example, org.scala-tools.archetypes:scala-archetype-simple . You need to specify the number number next to the archetype name in the output of your mvn archetype:generate command , since the numbering may change over time. There are also other options, such as eu.stratosphere:quickstart-scala , as described in this article .

However, they may be somewhat outdated. I personally prefer to write my pom.xml files manually. For reference, here is the minimum pom file to use with Scala 2.11.6 and Scalatest 2.2.5:
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-artifact</artifactId> <version>1.0-SNAPSHOT</version> <properties> <encoding>UTF-8</encoding> <scala.version>2.11.6</scala.version> </properties> <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.version}</version> </dependency> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_2.11</artifactId> <version>2.2.5</version> <scope>compile</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <version>2.15.2</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.scalatest</groupId> <artifactId>scalatest-maven-plugin</artifactId> <version>1.0</version> <configuration> </configuration> <executions> <execution> <id>test</id> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> 
+10
source

All Articles