我可以这样创建一个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的np插件可以满足您的需求。用法:
$ sbt
$ np name:my-new-project org:org.myproject version:0.1.0-SNAPSHOT
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句