使用Maven创建最基本的Scala项目? [英] Creating the most basic Scala project with Maven?

查看:89
本文介绍了使用Maven创建最基本的Scala项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Maven 3创建一个新的Scala项目.据我了解,使用Maven创建新项目的方式是:

I use Maven 3 to create a new Scala project. As far as I understand, the way to create a new project with Maven is by:

mvn archetype:generate

也许我错过了一些东西,但是我什至找不到一个提供最简单的Scala项目的选项(例如,lein new app ...收到的Clojure项目).这里有帮助吗?

Maybe I'm missing out something, but I couldn't find even one option that offers the simplest Scala project (like the one received by lein new app ... for Clojure, for example). Any help here?

推荐答案

您应该可以使用mvn archetype:generate.您可以选择例如org.scala-tools.archetypes:scala-archetype-simple.您需要在mvn archetype:generate命令的输出中的原型名称旁边输入数字,因为数字会随时间变化.还有其他选项,例如本文中所述的eu.stratosphere:quickstart-scala >.

You should be able to use mvn archetype:generate. You can choose, e.g., org.scala-tools.archetypes:scala-archetype-simple. You need to put in the number number next to the archetype name in the output of your mvn archetype:generate command because the numbering can change over time. There are also other options like eu.stratosphere:quickstart-scala as documented in this article.

不过,它们可能有些过时了.我个人更喜欢手动编写pom.xml文件.作为参考,这是与Scala 2.11.6和Scalatest 2.2.5一起使用的最小pom文件:

They may be somewhat outdated, though. I personally prefer writing my pom.xml files manually. For reference, here is a minimal pom file for 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>

这篇关于使用Maven创建最基本的Scala项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆