【发布时间】:2014-03-14 10:02:20
【问题描述】:
我可以像这样创建一个 sbt 项目:
$ mkdir project1
$ cd project1
$ sbt
Loading /usr/share/sbt/bin/sbt-launch-lib.bash
> set name := "project1"
[info] Defining *:name
...
> set scalaVersion :="2.10.2"
[info] Defining *:scalaVersion
...
> set version :="1.0"
[info] Defining *:version
...
> session save
[info] Reapplying settings...
> exit
这将为项目创建build.sbt 文件。
$ cat build.sbt
name := "project1"
scalaVersion :="2.10.2"
version :="1.0"
现在有没有命令行可以做同样的事情?比如:
sbt new_project "name" version scala_version
EDIT1
我想出了另一种方法,即创建项目文件夹:
$ mkdir project1
$ cd project1/
更新项目详情:
$ sbt 'set name := "project1"' 'set scalaVersion :="2.10.2"' 'set version :="1.0"' 'session save'
Loading /usr/share/sbt/bin/sbt-launch-lib.bash
[info] Set current project to project1 (in build file:/tmp/scala/project1/)
[info] Defining *:name
[info] The new value will be used by *:description, *:normalizedName and 6 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to project1 (in build file:/tmp/scala/project1/)
[info] Defining *:scalaVersion
[info] The new value will be used by *:allDependencies, *:ivyScala and 10 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to project1 (in build file:/tmp/scala/project1/)
[info] Defining *:version
[info] The new value will be used by *:isSnapshot, *:projectId and 3 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to project1 (in build file:/tmp/scala/project1/)
[info] Reapplying settings...
[info] Set current project to project1 (in build file:/tmp/scala/project1/)
我们已生成项目并保存设置:
$ ls
build.sbt project
$ cat build.sbt
name := "project1"
scalaVersion :="2.10.2"
version :="1.0"
我希望 SBT 能够原生提供类似 Maven 中的功能:mvn archetype:generate。
【问题讨论】:
-
我也想知道为什么没人提到typesafe.com/activator
-
@JacekLaskowski 你提到的那个问题真的是一个奇怪的问题和很好的解释:-)
-
@tuxdna 你有没有设法为 sbt 创建一个 maven 类型原型?
-
@lazywiz 不确定你的意思。您想使用
sbtcli 创建 mvn 原型项目吗?