gpt4 book ai didi

scala - "Repository for publishing is not specified"尽管发布成功

转载 作者:行者123 更新时间:2023-12-03 01:12:48 25 4
gpt4 key购买 nike

我的大型 SBT 项目中有一个单独的 Settings.scala 文件,其中包含以下内容:

lazy val commonSettings = Seq(
// ... lots of settings
publishTo :=
Some("Sonatype Nexus Repository Manager" at
"http://my.company.nexus/content/repositories/releases/"),
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
publishMavenStyle := true,
crossScalaVersions := Seq("2.10.6"),
// ... lots of other settings
)

现在我在 build.sbt 中的所有项目都定义如下:

lazy val aProject =
project.in(file("somewhere/aProject")).
settings(commonSettings).
settings(
// project specific settings
)

当我现在这样做时

sbt "+ publish"

我看到我的所有工件都已发布,当我查看 Nexus 时它们就在那里,而且我还可以将它们用作依赖项等,因此发布有效,但最终我得到以下结果:

java.lang.RuntimeException: Repository for publishing is not specified.
at scala.sys.package$.error(package.scala:27)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1470)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1470)
at scala.Option.getOrElse(Option.scala:120)
at sbt.Classpaths$.getPublishTo(Defaults.scala:1470)
at sbt.Classpaths$$anonfun$59.apply(Defaults.scala:1150)
at sbt.Classpaths$$anonfun$59.apply(Defaults.scala:1150)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我的 sbt 文件中缺少什么/做错了什么?

最佳答案

If a project is not defined for the root directory in the build, sbt creates a default one that aggregates all other projects in the build.

我怀疑您没有定义根项目,因此 SBT 定义了自己的项目,当然它没有获得通用设置。与+ publish SBT 尝试发布它,首先发布它聚合的所有项目(成功),然后无法发布聚合项目本身。

要解决此问题,可以:

  1. 只需定义根项目并显式给出所需的设置(它们不一定相同:实际上没有任何内容可以在那里发布,因此您可能需要 publishArtifact := false );

  2. 进行设置 global :

    publishTo in ThisBuild := ...

另请参阅What is the difference between ThisBuild and Global scopes?

关于scala - "Repository for publishing is not specified"尽管发布成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33998156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com