我正在尝试使用akka-http
库的本地副本。我可以使用sbt publishLocal
在本地发布它,但我无法弄清楚如何更改版本号。 build.sbt
包含organization
字段,但没有简单的version
字段 - 这似乎是从其他地方生成的,我无法弄清楚在哪里。它目前位于10.0.5
但是在源代码中对该字符串进行处理并没有发现任何明显的字符串。
看起来像一个简单的问题,但版本定义在哪里?感谢。
(我问这是因为sbt
文档告诉我我应该将本地版本命名为0.1-SNAPSHOT
。我认为必须有一种更简单的方法来禁用自动生成逻辑并将其硬编码到build.sbt
)
答案 0 :(得分:0)
似乎Akka-HTTP在运行时生成了它的版本。
如果你看akka-http/akka-http-core/src/main/resources/reference.conf
:
Akka HTTP版本,根据Akka HTTP的运行时版本进行检查。 从生成的conf文件中加载。
然后查看akka-http/project/Version.scala
:
/**
* Generate version.conf and akka/Version.scala files based on the version setting.
*/
object Version {
def versionSettings: Seq[Setting[_]] = inConfig(Compile)(Seq(
resourceGenerators += generateVersion(resourceManaged, _ / "akka-http-version.conf",
"""|akka.http.version = "%s"
|""").taskValue,
sourceGenerators += generateVersion(sourceManaged, _ / "akka" / "http" / "Version.scala",
"""|package akka.http
|
|import com.typesafe.config.Config
|
|object Version {
| val current: String = "%s"
| def check(config: Config): Unit = {
| val configVersion = config.getString("akka.http.version")
| if (configVersion != current) {
| throw new akka.ConfigurationException(
| "Akka JAR version [" + current + "] does not match the provided " +
| "config version [" + configVersion + "]")
| }
| }
|}
|""").taskValue
))
def generateVersion(dir: SettingKey[File], locate: File => File, template: String) = Def.task[Seq[File]] {
val file = locate(dir.value)
val content = template.stripMargin.format(version.value)
if (!file.exists || IO.read(file) != content) IO.write(file, content)
Seq(file)
}
}
我假设在生成当前版本后,您应该在文件系统的某处看到akka-http-version.conf
文件。