为什么项目中有两个不同版本的sbt [英] Why two different versions of sbt in the project

查看:33
本文介绍了为什么项目中有两个不同版本的sbt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Play 项目中,我注意到 build.propertiessbt 版本 addSbtPlugin("com.typesafe.play" %"sbt-plugin" % "2.6.12")build.propertiessbt.version=0.13.15.

In my Play project I notice that build.properties has sbt version addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.12") and build.properties has sbt.version=0.13.15.

1) 为什么有两个实体?2)它们之间有什么区别3)他们的版本应该不同吗?

1) Why are there two enteries? 2) What is the difference between them 3) Should their versions be different?

推荐答案

SBT 专有和 SBT 插件之间存在差异.Play 框架是一个 SBT 插件.SBT 版本project/build.properties 中指定:

There is a difference between SBT proper and SBT plugin. Play Framework is an SBT plugin. The version of SBT is specified in project/build.properties:

sbt.version=0.13.15

虽然

whilst the version of Play SBT plugin is specified in project/plugins.sbt:

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.12")

Scala Play SBT 插件 (PlayScala) 在 build.sbt 中启用,如下所示:

Scala Play SBT plugin (PlayScala) is enabled in build.sbt like so:

lazy val root = (project in file(".")).enablePlugins(PlayScala)

SBT 插件通过其他有用的任务、命令、设置和依赖项丰富了构建定义.以下是来自 播放 SBT 插件:

SBT plugins enrich build definitions with additional useful tasks, commands, settings, and dependencies. Here are some examples from Play SBT plugin:

object PlayKeys {
  val playDefaultPort = SettingKey[Int]("playDefaultPort", "The default port that Play runs on")
  val playDefaultAddress = SettingKey[String]("playDefaultAddress", "The default address that Play runs on")
  val playRunHooks = TaskKey[Seq[PlayRunHook]]("playRunHooks", "Hooks to run additional behaviour before/after the run task")
  ...

例如,要更改运行 Play 的默认端口,我们可以在 build.sbt 中定义:

So for example to change the default port that Play runs on we can define in build.sbt:

PlayKeys.playDefaultPort := 9009

请注意,升级 SBT 版本时,我们需要确保它与相应的 Play SBT 插件兼容.例如,要在 SBT 1 中使用 Play,我们需要将 Play sbt-plugin 更新为 2.6.6.

Note when upgrading SBT version we need to make sure it is compatible with corresponding Play SBT plugin. For example, to use Play with SBT 1 we need to update Play sbt-plugin to 2.6.6.

SBT 插件最佳实践 artifact命名约定鼓励以下命名方案:

SBT plugin best practice artifact naming convention encurages the following naming scheme:

sbt-$projectname

例如,sbt-scoveragesbt-buildinfosbt-releasesbt-assembly、但是 Play 将其命名为 sbt-plugin,这可能会令人困惑.

For example, sbt-scoverage, sbt-buildinfo, sbt-release, sbt-assembly, however Play named it sbt-plugin, which arguably can be confusing.

这篇关于为什么项目中有两个不同版本的sbt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆