本文整理汇总了Scala中sbt.Keys.version类的典型用法代码示例。如果您正苦于以下问题:Scala version类的具体用法?Scala version怎么用?Scala version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了version类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: PublishLocalSnapshot
//设置package包名称以及导入依赖的类
package x7c1.chaff.publish
import sbt.Def.{SettingsDefinition, taskKey}
import sbt.Keys.{publishLocal, version}
import sbt.{Compile, TaskKey}
object PublishLocalSnapshot {
def definition: SettingsDefinition = StateCommand.taskDefinition(
key = publishLocalSnapshot,
updates = Seq(
version := withSuffix(version.value, "-SNAPSHOT")
),
task = publishLocal in Compile
)
lazy val publishLocalSnapshot: TaskKey[Unit] = taskKey[Unit](
"Runs publishLocal on '-SNAPSHOT' version."
)
private def withSuffix(original: String, suffix: String) = {
if (original endsWith suffix) {
original
} else {
original + suffix
}
}
}
示例2: LatestVersion
//设置package包名称以及导入依赖的类
import sbt.Keys.version
import sbt._
import sbtrelease.ReleasePlugin.autoImport.ReleaseStep
import sbtrelease.ReleaseStateTransformations.reapply
object LatestVersion extends AutoPlugin {
object autoImport {
lazy val latestVersion: SettingKey[String] =
settingKey[String]("latest released version")
lazy val setLatestVersion: ReleaseStep = { st: State =>
val extracted = Project.extract(st)
val newVersion = extracted.get(version)
val latestVersionSbt = "latestVersion.sbt"
val content = Seq(s"""latestVersion in ThisBuild := "$newVersion"""")
IO.writeLines(file(latestVersionSbt), content)
val vcs = sbtrelease.Vcs.detect(file("."))
vcs.foreach(_.add(latestVersionSbt) !! st.log)
reapply(Seq(latestVersion in ThisBuild := newVersion), st)
}
}
}