为什么 sbt 不创建项目文件?

发布于 2024-11-16 07:29:46 字数 441 浏览 2 评论 0 原文

我尝试在我的 MacBook 上安装 SBT。当我运行它时,它不会询问我任何项目定义(例如标题),只是说“

[info] Set current project to default (in build file:/Users/qui/Documents/Programming/test2/)

然后它会转到 sbt 解释器”。

当我查看“test2”内部时,有一个项目和目标目录,但我没有看到可以使用的 src 目录

,显然我在安装中的某个地方出了问题,但我不确定在哪里。有什么想法吗?

更新

所以我刚刚在全新的 Fedora 安装上安装了 0.10。我遇到了完全相同的问题,相同的“信息”消息,它只创建了一个项目和目标目录,

我一定是在做一些愚蠢的事情,对吗?我做错了什么? :p

I have tried to install SBT on my macbook. When I run it, it doesn't ask me for any project definitions (e.g. title) and simply says

[info] Set current project to default (in build file:/Users/qui/Documents/Programming/test2/)

It then goes to what looks like the sbt interpreter.

When I look inside "test2", there is a project and target directory but I dont see a src directory to work with

Clearly I have gone wrong somewhere in my installation but I'm unsure where. Any ideas?

Update

So I just installed 0.10 on a fresh fedora install. And I am getting the exact same problem, same "info" message and it has only created a project and target directory

I must be doing something idiotic right? What am I doing wrong? :p

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

总以为 2024-11-23 07:29:46

我使用 SBT 0.13,所以...您的里程可能会有所不同。

sbt 的默认行为

你所经历的是 sbt 的默认行为。该工具期望项目文件已经就位,或者当没有项目文件时,它不会创建它们 - 默认值仅应用于当前目录,该目录实际上成为按名称调用的项目的项目目录然后 SBT 打开 sbt shell。

jacek:~/sandbox/stackoverflow/testaaa
$ tree
.

0 directories, 0 files

jacek:~/sandbox/stackoverflow/testaaa
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to testaaa (in build file:/Users/jacek/sandbox/stackoverflow/testaaa/)
[testaaa]>

引用 SBT 官方文档中的 Running

不带命令行参数运行 sbt 会以交互方式启动它
模式。交互模式有一个命令提示符(带有制表符完成和
历史!)。

示例

在您的情况下,当您在 /Users/qui/Documents/Programming/test2/ 中启动 sbt 时,它会默默地假定它是项目目录并应用默认设置。

以下 sbt 会话也位于 test2 目录中。我使用 help 显示设置键的帮助,然后使用该键显示其值。

jacek:~/sandbox/stackoverflow/test2
$ tree
.

0 directories, 0 files
jacek:~/sandbox/stackoverflow/test2
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> help name
Project name.
[test2]> name
[info] test2
[test2]> help organization
Organization/group ID.
[test2]> organization
[info] default
[test2]> help version
The version/revision of the current module.
[test2]> version
[info] 0.1-SNAPSHOT
[test2]> help scalaVersion
The version of Scala used for building.
[test2]> scalaVersion
[info] 2.10.2

(我更改了提示,以便项目的名称(即 sbt 启动的目录的名称)显示在 > 之前)。

您可以使用 set 命令更改键的值,该命令评估设置并将其应用到当前项目。

[test2]> help set
set [every] <setting-expression>

    Applies the given setting to the current project:
      1) Constructs the expression provided as an argument by compiling and loading it.
      2) Appends the new setting to the current project's settings.
      3) Re-evaluates the build's settings.

    This command does not rebuild the build definitions, plugins, or configurations.
    It does not automatically persist the setting(s) either.
    To persist the setting(s), run 'session save' or 'session save-all'.

    If 'every' is specified, the setting is evaluated in the current context
    and the resulting value is used in every scope.  This overrides the value
    bound to the key everywhere.

[test2]> set scalaVersion := "2.10.3"
[info] Defining *:scalaVersion
[info] The new value will be used by *:allDependencies, *:dependencyUpdatesData and 11 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> scalaVersion
[info] 2.10.3

com/a/12781664/1305344">StackOverflow 上的另一个问题 @regis-jean-gilles 展示了如何使用 set 设置其他设置命令。

[test2]> set name := "My test2 sbt project"
[info] Defining *:name
[info] The new value will be used by *:description, *:normalizedName and 8 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> set version := "1.0"
[info] Defining *:version
[info] The new value will be used by *:isSnapshot, *:projectId and 5 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> set scalaVersion := "2.10.3"
[info] Defining *:scalaVersion
[info] The new value will be used by *:allDependencies, *:dependencyUpdatesData and 11 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> session save
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> exit

然后,build.sbt 文件将包含所有设置,就像一开始就在那里设置一样。

$ cat build.sbt
name := "My test2 sbt project"

version := "1.0"

scalaVersion := "2.10.3"

默认情况下,sbt 在 target 目录中创建各种文件。当您查看 target 目录时,会发现没有文件 - 只有一个空目录。这同样适用于也可能包含也可能不包含 target 目录的 project 。假定它们可用,如果不可用,则默认创建它们。

当您更改 sbt 交互式 shell 中的设置(使用 set)时,您可以使用 session save 保存会话。

[test2]> help session
session <command>

Manipulates session settings, which are temporary settings that do not persist past the current sbt execution (that is, the current session).
Valid commands are:

clear, clear-all

    Removes temporary settings added using 'set' and re-evaluates all settings.
    For 'clear', only the settings defined for the current project are cleared.
    For 'clear-all', all settings in all projects are cleared.

list, list-all

    Prints a numbered list of session settings defined.
    The numbers may be used to remove individual settings or ranges of settings using 'remove'.
    For 'list', only the settings for the current project are printed.
    For 'list-all', all settings in all projets are printed.

remove <range-spec>

    <range-spec> is a comma-separated list of individual numbers or ranges of numbers.
    For example, 'remove 1,3,5-7'.
    The temporary settings at the given indices for the current project are removed and all settings are re-evaluated.
    Use the 'list' command to see a numbered list of settings for the current project.

save, save-all

    Makes the session settings permanent by writing them to a '.sbt' configuration file.
    For 'save', only the current project's settings are saved (the settings for other projects are left alone).
    For 'save-all', the session settings are saved for all projects.
    The session settings defined for a project are appended to the first '.sbt' configuration file in that project.
    If no '.sbt' configuration file exists, the settings are written to 'build.sbt' in the project's base directory.
[test2]> session save
[info] Reapplying settings...
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)

完成此操作后,将保存带有您自己的设置的 build.sbt。这可能是进一步配置项目的良好起点。

jacek:~/sandbox/stackoverflow/test2
$ cat build.sbt
scalaVersion := "2.10.3"

Typesafe Activator

根据Typesafe Activator 主页

Typesafe Activator 是一个基于浏览器或命令行的工具,可帮助
开发人员开始使用 Typesafe 反应式平台。

在幕后,Activator 是一个构建在 sbt 之上的 UI,由 Josh Suereth 在截屏视频 sbt 简介0.13.2

看起来,这是 Activator 中提供的众多模板中唯一用于设置 sbt 项目的解决方案。

giter8 - sbt 项目(布局)模板

如果您需要一些帮助来布局目录结构并有一个现成的项目设置,您可能需要使用 giter8 这是一个用于应用 github 上定义的模板的命令行工具

比如说,您想使用 scalaz 依赖项。您可能需要使用 adinapoli/scalaz-revolver (请参阅可用模板列表)。

jacek:~/sandbox/stackoverflow
$ g8 adinapoli/scalaz-revolver

Simple scala project with sbt-revolver

organization [org.example]: pl.japila
name [Scala sbt-revolver project]:
scala_version [2.9.2]: 2.10.3
version [0.1-SNAPSHOT]:

Template applied in ./scala-sbt-revolver-project

jacek:~/sandbox/stackoverflow
$ cd scala-sbt-revolver-project/

jacek:~/sandbox/stackoverflow/scala-sbt-revolver-project
$ tree
.
├── README
├── build.sbt
├── project
│   ├── Build.scala
│   ├── build.properties
│   └── plugins.sbt
└── src
    └── main
        └── scala
            └── pl
                └── japila
                    └── ScalaSbtrevolverProject.scala

6 directories, 6 files

请参阅创建包含源代码的项目目录来查找出去更多。

np - 新的 sbt 项目生成变得简单(r)

正如下面 @0__ 的评论所指出的,还有另一个项目旨在简化 sbt 中新项目的创建方式 - np.这似乎正是您所需要的。

https://github.com/softprops/np#for-sbt-013 有一个完整的描述,说明了使用该实用程序进行设置和创建新的 sbt 项目所需的内容,可归结为:

  1. 注册 sbt 插件。将以下内容添加到 ~/.sbt/0.13/plugins/np.sbt

    addSbtPlugin("me.lessis" % "np" % "0.2.0")
    
  2. ~/.sbt/0.13/np.sbt中定义自定义全局覆盖。将以下内容添加到文件中。

    seq(npSettings:_*)
    
    ((Compile, NpKeys.np) 中的 NpKeys.defaults) ~= {
      _.copy(org =“me.lessis”,版本=“0.1.0-SNAPSHOT”)
    }
    
  3. 使用 np 插件的命令 - np。为 sbt 项目创建一个空目录并运行 sbt np。

    jacek:~/sandbox/stackoverflow
    $ mkdir np-sandbox/
    杰克:~/sandbox/stackoverflow
    $ cd np-sandbox/
    杰克:~/sandbox/stackoverflow/np-sandbox
    $ sbt NP
    [info] 从 /Users/jacek/.sbt/0.13/plugins 加载全局插件
    [info] 将当前项目设置为 np-sandbox (在构建文件中:/Users/jacek/sandbox/stackoverflow/np-sandbox/)
    [info] 生成的构建文件
    [info] 生成的源目录
    [成功] 总时间: 0 s, 完成 2013年12月7日 12:51:42 PM
    杰克:~/sandbox/stackoverflow/np-sandbox
    $ 树
    。
    ├── 构建.sbt
    ├── 来源
    │   ├── 主要
    │   │   ├── 资源
    │   │   └── 斯卡拉
    │   └── 测试
    │   ├── 资源
    │   └── 斯卡拉
    └── 目标
        └── 溪流
            └── 编译
                └── np
                    └── $全球
                        └── 出
    
    12个目录,2个文件
    杰克:~/sandbox/stackoverflow/np-sandbox
    $ cat build.sbt
    组织 := "me.lessis"
    
    名称 := "默认"
    
    版本 := "0.1.0-SNAPSHOT"
    

I work with SBT 0.13 so...your mileage may vary.

sbt's default behaviour

What you experience is the default behaviour of sbt. The tool expects that the project files are already in place or when there is no project files it doesn't bother to create them - the default values are just applied to the current directory that effectively becomes the project directory for a project called by the name of the directory it's in. SBT then opens sbt shell.

jacek:~/sandbox/stackoverflow/testaaa
$ tree
.

0 directories, 0 files

jacek:~/sandbox/stackoverflow/testaaa
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to testaaa (in build file:/Users/jacek/sandbox/stackoverflow/testaaa/)
[testaaa]>

Quoting Running from the official documentation of SBT.

Running sbt with no command line arguments starts it in interactive
mode. Interactive mode has a command prompt (with tab completion and
history!).

Example

In your case, when you started sbt in /Users/qui/Documents/Programming/test2/ it silently assumed it's the project directory and applied the default settings.

The following sbt session is in test2 directory, too. I use help to display the help of a setting key and then use the key to display its value.

jacek:~/sandbox/stackoverflow/test2
$ tree
.

0 directories, 0 files
jacek:~/sandbox/stackoverflow/test2
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> help name
Project name.
[test2]> name
[info] test2
[test2]> help organization
Organization/group ID.
[test2]> organization
[info] default
[test2]> help version
The version/revision of the current module.
[test2]> version
[info] 0.1-SNAPSHOT
[test2]> help scalaVersion
The version of Scala used for building.
[test2]> scalaVersion
[info] 2.10.2

(I've changed the prompt so the name of the project, i.e. the name of the directory sbt has been started in, is displayed before the >).

You can change the value of a key with the set command that Evaluates a Setting and applies it to the current project.

[test2]> help set
set [every] <setting-expression>

    Applies the given setting to the current project:
      1) Constructs the expression provided as an argument by compiling and loading it.
      2) Appends the new setting to the current project's settings.
      3) Re-evaluates the build's settings.

    This command does not rebuild the build definitions, plugins, or configurations.
    It does not automatically persist the setting(s) either.
    To persist the setting(s), run 'session save' or 'session save-all'.

    If 'every' is specified, the setting is evaluated in the current context
    and the resulting value is used in every scope.  This overrides the value
    bound to the key everywhere.

[test2]> set scalaVersion := "2.10.3"
[info] Defining *:scalaVersion
[info] The new value will be used by *:allDependencies, *:dependencyUpdatesData and 11 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> scalaVersion
[info] 2.10.3

In the other question on StackOverflow @regis-jean-gilles has showed how to set the other settings using the set command.

[test2]> set name := "My test2 sbt project"
[info] Defining *:name
[info] The new value will be used by *:description, *:normalizedName and 8 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> set version := "1.0"
[info] Defining *:version
[info] The new value will be used by *:isSnapshot, *:projectId and 5 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> set scalaVersion := "2.10.3"
[info] Defining *:scalaVersion
[info] The new value will be used by *:allDependencies, *:dependencyUpdatesData and 11 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> session save
[info] Reapplying settings...
[info] Set current project to My test2 sbt project (in build file:/Users/jacek/sandbox/stackoverflow/test2/)
[test2]> exit

The build.sbt file will then contain all the settings as if there'd been set there in the first place.

$ cat build.sbt
name := "My test2 sbt project"

version := "1.0"

scalaVersion := "2.10.3"

By default, sbt creates various files in target directory. When you look inside the target directory, there are no files - just an empty directory. The same applies to project that also may or may not hold target directory. They're assumed to be available and if there's not, they're created by default.

When you change a setting in sbt's interactive shell (with set), you can save the session with session save.

[test2]> help session
session <command>

Manipulates session settings, which are temporary settings that do not persist past the current sbt execution (that is, the current session).
Valid commands are:

clear, clear-all

    Removes temporary settings added using 'set' and re-evaluates all settings.
    For 'clear', only the settings defined for the current project are cleared.
    For 'clear-all', all settings in all projects are cleared.

list, list-all

    Prints a numbered list of session settings defined.
    The numbers may be used to remove individual settings or ranges of settings using 'remove'.
    For 'list', only the settings for the current project are printed.
    For 'list-all', all settings in all projets are printed.

remove <range-spec>

    <range-spec> is a comma-separated list of individual numbers or ranges of numbers.
    For example, 'remove 1,3,5-7'.
    The temporary settings at the given indices for the current project are removed and all settings are re-evaluated.
    Use the 'list' command to see a numbered list of settings for the current project.

save, save-all

    Makes the session settings permanent by writing them to a '.sbt' configuration file.
    For 'save', only the current project's settings are saved (the settings for other projects are left alone).
    For 'save-all', the session settings are saved for all projects.
    The session settings defined for a project are appended to the first '.sbt' configuration file in that project.
    If no '.sbt' configuration file exists, the settings are written to 'build.sbt' in the project's base directory.
[test2]> session save
[info] Reapplying settings...
[info] Set current project to test2 (in build file:/Users/jacek/sandbox/stackoverflow/test2/)

Once you do that, a build.sbt with your own setting(s) is saved. That might be a good starting point for further configuration of a project.

jacek:~/sandbox/stackoverflow/test2
$ cat build.sbt
scalaVersion := "2.10.3"

Typesafe Activator

According to the home page of Typesafe Activator:

Typesafe Activator is a browser-based or command-line tool that helps
developers get started with the Typesafe Reactive Platform.

Under the covers, Activator is a UI built atop of sbt as demo'ed by Josh Suereth in the screencast Introducing sbt 0.13.2.

It appears that that's the only blessed solution for setting up sbt projects out of the many templates available in Activator.

giter8 - sbt project (layout) templates

If you however need some help to lay out the directory structure and have a ready-to-use project setup, you may want to use giter8 that's a command line tool to apply templates defined on github

Say, you want to create a project with scalaz dependency. You may want to use adinapoli/scalaz-revolver (see the list of available templates).

jacek:~/sandbox/stackoverflow
$ g8 adinapoli/scalaz-revolver

Simple scala project with sbt-revolver

organization [org.example]: pl.japila
name [Scala sbt-revolver project]:
scala_version [2.9.2]: 2.10.3
version [0.1-SNAPSHOT]:

Template applied in ./scala-sbt-revolver-project

jacek:~/sandbox/stackoverflow
$ cd scala-sbt-revolver-project/

jacek:~/sandbox/stackoverflow/scala-sbt-revolver-project
$ tree
.
├── README
├── build.sbt
├── project
│   ├── Build.scala
│   ├── build.properties
│   └── plugins.sbt
└── src
    └── main
        └── scala
            └── pl
                └── japila
                    └── ScalaSbtrevolverProject.scala

6 directories, 6 files

See Create a project directory with source code to find out more.

np - new sbt project generation made simple(r)

As pointed out in the comments by @0__ below, there's another project that aims at simplifying how new projects in sbt are created - np. That seems exactly what you needed.

In https://github.com/softprops/np#for-sbt-013 there's a complete description of what's needed to set it up and create new sbt projects using the utility that boils down to:

  1. Registering the sbt plugin. Add the following to ~/.sbt/0.13/plugins/np.sbt.

    addSbtPlugin("me.lessis" % "np" % "0.2.0")
    
  2. Define a custom global overrides in ~/.sbt/0.13/np.sbt. Add the following to the file.

    seq(npSettings:_*)
    
    (NpKeys.defaults in (Compile, NpKeys.np)) ~= {
      _.copy(org="me.lessis", version="0.1.0-SNAPSHOT")
    }
    
  3. Use the np plugin's command - np. Create an empty directory for the sbt project and run sbt np.

    jacek:~/sandbox/stackoverflow
    $ mkdir np-sandbox/
    jacek:~/sandbox/stackoverflow
    $ cd np-sandbox/
    jacek:~/sandbox/stackoverflow/np-sandbox
    $ sbt np
    [info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
    [info] Set current project to np-sandbox (in build file:/Users/jacek/sandbox/stackoverflow/np-sandbox/)
    [info] Generated build file
    [info] Generated source directories
    [success] Total time: 0 s, completed Dec 7, 2013 12:51:42 PM
    jacek:~/sandbox/stackoverflow/np-sandbox
    $ tree
    .
    ├── build.sbt
    ├── src
    │   ├── main
    │   │   ├── resources
    │   │   └── scala
    │   └── test
    │       ├── resources
    │       └── scala
    └── target
        └── streams
            └── compile
                └── np
                    └── $global
                        └── out
    
    12 directories, 2 files
    jacek:~/sandbox/stackoverflow/np-sandbox
    $ cat build.sbt
    organization := "me.lessis"
    
    name := "default"
    
    version := "0.1.0-SNAPSHOT"
    
べ映画 2024-11-23 07:29:46

不,你没有做错什么,以前版本的 sbt (0.7.x) 确实询问你是否要创建项目。

sbt 版本 0.10.x 是完全重写的,并且行为方式不同(即要求您在启动时创建一个项目)。

旧项目位于 googlecode 上,但现已转移到 github,您可以在 https: //github.com/harrah/xsbt/wiki,特别是https://github.com/harrah/xsbt/wiki/Settings(如果您来自 0.7.x 背景)。

一开始你会觉得新的设置系统有点难以理解,但请相信我,你会喜欢它的:)

No you're not doing something wrong, previous versions of sbt (0.7.x) did ask you if you wanted to create your project.

sbt version 0.10.x is a complete rewrite and does not act the same way (i.e. ask you to create a project on startup).

The old project was on googlecode but has since moved to github, you can find the documentation for 0.10.x at https://github.com/harrah/xsbt/wiki, in particular https://github.com/harrah/xsbt/wiki/Settings if you come from a 0.7.x background.

It's a bit hard to wrap your head around the new settings system at first, but trust me when I say you'll love it :)

蓦然回首 2024-11-23 07:29:46

np 插件 自述文件中所述,所需的步骤是:

mkdir -p src/{main,test}/scala
touch build.sbt && vi build.sbt # fill in the basics (name, organization, version)
touch README.md && vi README.md
sbt

... 开始编码

As described in the np plugin readme, the required steps would be :

mkdir -p src/{main,test}/scala
touch build.sbt && vi build.sbt # fill in the basics (name, organization, version)
touch README.md && vi README.md
sbt

... start coding

风蛊 2024-11-23 07:29:46

一行创建目录结构和文件(全部为空):

mkdir -p ./src/{main,test}/{scala,java,resources}; mkdir project; touch build.sbt; touch project/build.properties

One-liner to create the directory-structure and files (all empty):

mkdir -p ./src/{main,test}/{scala,java,resources}; mkdir project; touch build.sbt; touch project/build.properties
濫情▎り 2024-11-23 07:29:46

我发现并更新了 Alvin Alexander(令人惊叹的书 Scala Cookbook 的作者)的 脚本,它的作用只是你想要什么。

我再次提供了一个 bash 脚本,因为创建目录和文件的任务很迂腐,但很简单。为此,为 SBT 制作一个成熟的插件是一种矫枉过正的行为。

This script creates an SBT project directory beneath the current directory.

Directory/Project Name (MyFirstProject): ProjectX
Create .gitignore File? (Y/n):
Create README.md File? (Y/n):

-----------------------------------------------
Directory/Project Name: ProjectX
Create .gitignore File?: y
Create README.md File?: y
-----------------------------------------------
Create Project? (Y/n):

Project created. See the following URL for build.sbt examples:
http://alvinalexander.com/scala/sbt-syntax-examples

$ cat build.sbt
name := "ProjectX"

version := "1.0"

scalaVersion := "2.11.7"

$

最后,我相信在没有任何参数的情况下启动的 SBT 应该像这个脚本一样完全

I found and updated a script by Alvin Alexander (author of the amazing book Scala Cookbook) that does just what you want.

Once again, I provide a bash script because the task of creating the directories and the files is pedantic, but simple. Making a full fledged plugin for SBT for this is an overkill.

This script creates an SBT project directory beneath the current directory.

Directory/Project Name (MyFirstProject): ProjectX
Create .gitignore File? (Y/n):
Create README.md File? (Y/n):

-----------------------------------------------
Directory/Project Name: ProjectX
Create .gitignore File?: y
Create README.md File?: y
-----------------------------------------------
Create Project? (Y/n):

Project created. See the following URL for build.sbt examples:
http://alvinalexander.com/scala/sbt-syntax-examples

$ cat build.sbt
name := "ProjectX"

version := "1.0"

scalaVersion := "2.11.7"

$

And finally, I believe SBT launched without any arguments should behave exactly like this script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文