在我的Play
项目中,我注意到build.properties
有sbt
版本的addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.12")
,build.properties
有sbt.version=0.13.15
。
( 1)为什么有两个企业?( 2)它们之间有什么区别?( 3)它们的版本应该不同吗?
发布于 2018-09-16 04:22:43
SBT本身和SBT插件是有区别的。Play框架是一个SBT插件。SBT版本是在project/build.properties
中指定的
sbt.version=0.13.15
而Play SBT插件版本是在project/plugins.sbt
中指定的
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.12")
Scala插件(PlayScala
)在build.sbt
中启用,如下所示:
lazy val root = (project in file(".")).enablePlugins(PlayScala)
SBT插件通过附加的有用任务、命令、设置和依赖项丰富了构建定义。下面是一些来自播放SBT插件的例子
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")
...
因此,例如,要更改播放运行的默认端口,我们可以在build.sbt
中定义
PlayKeys.playDefaultPort := 9009
注意,在升级SBT版本时,我们需要确保它与相应的Play SBT插件兼容。例如,要使用SBT 1,我们需要将Play sbt-plugin
更新为2.6.6
。
SBT插件最佳实践工件命名约定封装了以下命名方案:
sbt-$projectname
例如,sbt-scoverage
、sbt-buildinfo
、sbt-release
、sbt-assembly
,但是Play将其命名为sbt-plugin
,这可以说是令人困惑的。
https://stackoverflow.com/questions/52352081
复制相似问题