我可以这样创建一个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
编辑1
我找到了另一种方法,即创建项目文件夹:
$ 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
。
sbt
命令行创建mvn原型项目吗? - tuxdna