目前我有一个主要项目的sbt multi项目。 其他项目只是聚合或scalaJS项目,所以我的项目定义有点像:
lazy val auth = project
lazy val utils = project
lazy val client = project
lazy val main = project
.dependsOn(utils).aggregate(utils)
.dependsOn(auth).aggregate(auth)
.aggregate(clients.map(projectToRef): _*)
然而,在发布时我得到了:
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)
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)
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)
[error] (client/*:publishConfiguration) Repository for publishing is not specified.
[error] (auth/*:publishConfiguration) Repository for publishing is not specified.
[error] (utils/*:publishConfiguration) Repository for publishing is not specified.
目前我的主要项目上传成功但是我得到退出代码1,这对我的CI服务器不利。
有没有办法为这些子项目禁用它?
编辑:我也使用sbt-native-packager进行发布,即:。
makeDeploymentSettings(Universal, packageBin in Universal, "tgz")
我使用的命令
sbt universal:publish
答案 0 :(得分:1)
您必须为所有模块提供publishTo
设置。
这可以通过使用包含publishTo
所有设置的公共对象来实现。然后可以将这些设置导入到所有模块中的build.sbt。
所以你可以有一个文件,比如Common.scala,看起来像这样:
object Common {
val settings: Seq[Setting[_]] = Seq(
scalaVersion := "Your Scala version",
publishTo <<= Some("your repo" at "http://yourserver.com")
)
val nonPublishSettings = settings ++ Seq(
publish := { }
)
}
现在像这样修改你的build.sbt:
Common.settings
lazy val auth = project
lazy val utils = project.settings(Common.nonPublishSettings) // This module will not be published. All others will be.
lazy val client = project
lazy val main = project
.dependsOn(utils).aggregate(utils)
.dependsOn(auth).aggregate(auth)
.aggregate(clients.map(projectToRef): _*)
因此,您的问题的解决方案是明确告诉sbt要发布哪些模块以及在哪里。
答案 1 :(得分:0)
这看起来像配置错误。主项目聚合所有其他项目,这意味着您在main
项目上执行的每个命令都将在aggregate
函数中列出的项目上执行。
我假设您使用
指定了存储库publishTo := Some("your repo" at "http://yourcompany.com")
仅在您的主项目上设置。因此,当您运行universal:publish
时,所有子项目也会发布。
Here is another Stackoverflow关于如何在单个项目上禁用发布的问题。