2016-05-05 17 views
6

Tôi sử dụng Maven 3 để tạo một dự án Scala mới. Theo như tôi hiểu, cách để tạo ra một dự án mới với Maven là bởi:Tạo dự án Scala cơ bản nhất với Maven?

mvn archetype:generate 

Có lẽ tôi đang bỏ lỡ điều gì đó, nhưng tôi không thể tìm thấy ngay cả một lựa chọn mà cung cấp các dự án đơn giản nhất Scala (như ví dụ, một ví dụ được nhận bởi lein new app ... cho Clojure). Bất kỳ trợ giúp ở đây?

+0

Bạn đã thử các bước ở đây chưa? http://docs.scala-lang.org/tutorials/scala-with-maven.html –

+0

http://docs.scala-lang.org/tutorials/scala-with-maven.html#creating-your-first- dự án –

+0

Đã thử nó, 339 bây giờ là một số dự án Java khác: '339: remote -> com.yoctopuce.archetype: commandline (Ví dụ dòng lệnh đơn giản với thư viện Yoctoupce)' – shakedzy

Trả lời

10

Bạn sẽ có thể sử dụng mvn archetype:generate. Bạn có thể chọn, ví dụ: org.scala-tools.archetypes:scala-archetype-simple. Bạn cần phải đặt số thứ tự bên cạnh tên nguyên mẫu trong đầu ra của lệnh mvn archetype:generate của bạn vì việc đánh số có thể thay đổi theo thời gian. Ngoài ra còn có các tùy chọn khác như eu.stratosphere:quickstart-scala như được ghi trong this article.

Chúng có thể hơi lỗi thời. Cá nhân tôi thích viết các tệp pom.xml của tôi theo cách thủ công. Để tham khảo, đây là tệp pom tối thiểu để sử dụng với Scala 2.11.6 và 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> 
Các vấn đề liên quan