为什么发布插件项目失败并出现 RuntimeException: Repository for publishing is not specified? [英] Why does publishing plugin project fail with RuntimeException: Repository for publishing is not specified?
问题描述
我正在尝试将 SBT 插件发布到存储库.我不确定这是否有任何相关性,但我们的插件加载了 sbt-twirl
插件 - 谷歌搜索,似乎publishConfiguration 可能会被覆盖:
I am trying to publish an SBT plugin to a repository. I'm not sure if this has any relevance, but our plugin loads the sbt-twirl
plugin - Googling around, it seems like publishConfiguration might be overriden:
new PublishConfiguration(None, "dotM2", arts, Seq(), level)
当我运行发布任务时,工件被部署到存储库,但随后 sbt 任务失败:
When I run the publish task, artifacts are deployed to the repo, but the sbt task then fails:
sbt (my-sbt-plugin)> publish
[info] Loading global plugins from ...
...
[info] Done packaging.
[info] published sbt-my-sbt-plugin to http://my.repo.com/.../sbt-my-sbt-plugin-0.1-SNAPSHOT.jar
java.lang.RuntimeException: Repository for publishing is not specified.
.... stack trace here ....
[error] (my-sbt-plugin/*:publishConfiguration) Repository for publishing is not specified.
导致错误的原因是什么,我该怎么做才能阻止发布失败?
What is causing the error, and what could I do to stop the publishing from failing?
** 更新 ** 这里是 inspect publish
** Update ** Here is inspect publish
sbt (my-sbt-plugin)> inspect publish
[info] Task: Unit
[info] Description:
[info] Publishes artifacts to a repository.
[info] Provided by:
[info] {file:/path/to/my-sbt-plugin/}my-sbt-plugin/*:publish
[info] Defined at:
[info] (sbt.Classpaths) Defaults.scala:988
[info] Dependencies:
[info] my-sbt-plugin/*:ivyModule
[info] my-sbt-plugin/*:publishConfiguration
[info] my-sbt-plugin/*:publish::streams
[info] Delegates:
[info] my-sbt-plugin/*:publish
[info] {.}/*:publish
[info] */*:publish
[info] Related:
[info] plugin/*:publish
这是我配置发布的方式(使用一些插件设置,不包括 libraryDependencies 和 1 或 2 个其他设置)
Here's how I've configured publishing (with some of the plugin settings, excluding libraryDependencies and 1 or 2 other settings)
lazy val plugin = project
.settings(publishSbtPlugin: _*)
.settings(
name := "my-sbt-plugin",
sbtPlugin := true,
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.2")
)
def publishSbtPlugin = Seq(
publishMavenStyle := true,
publishTo := {
val myrepo = "http://myrepo.tld/"
if (isSnapshot.value) Some("The Realm" at myrepo + "snapshots")
else Some("The Realm" at myrepo + "releases")
},
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
)
推荐答案
tl;dr 不要使用 lazy val plugin = project
来定义项目(对于未知的还有原因)
tl;dr Don't use lazy val plugin = project
to define a project (for unknown yet reasons)
经过几次评论后发现问题在于使用 lazy val plugin = project
定义的项目 plugin
的名称.这个名字似乎是不知何故保留的.将项目的名称更改为 plugin
以外的任何其他名称,然后重新开始.
After few comments it turned out that the issue was that the name of the project plugin
as defined using lazy val plugin = project
. It seems that the name is somehow reserved. Change the project's name to any other name than plugin
and start over.
这篇关于为什么发布插件项目失败并出现 RuntimeException: Repository for publishing is not specified?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!