首页 > 解决方案 > sbt,publishLocal 和 publish,未定义的解析器

问题描述

我想将我的工件推送到本地常春藤存储库和远程存储库,以便将它们用作其他项目中的依赖项。但他们都没有成功。

我的 SparkBuild.scala:

resolvers := Seq(
  // Google Mirror of Maven Central, placed first so that it's used instead of flaky Maven Central.
  // See https://storage-download.googleapis.com/maven-central/index.html for more info.
  "gcs-maven-central-mirror" at "https://maven-central.storage-download.googleapis.com/maven2/",
  DefaultMavenRepository,
  Resolver.mavenLocal,
  Resolver.file("ivyLocal", file(Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
),
externalResolvers := resolvers.value,
otherResolvers := SbtPomKeys.mvnLocalRepository(dotM2 => Seq(Resolver.file("dotM2", dotM2))).value,
publishLocalConfiguration in MavenCompile := PublishConfiguration()
    .withResolverName("dotM2")
    .withArtifacts(packagedArtifacts.value.toVector)
    .withLogging(ivyLoggingLevel.value),
publishLocalConfiguration in SbtCompile := PublishConfiguration()
    .withResolverName("ivyLocal")
    .withArtifacts(packagedArtifacts.value.toVector)
    .withLogging(ivyLoggingLevel.value),
publishMavenStyle in MavenCompile := true,
publishMavenStyle in SbtCompile := false,
publishLocal in MavenCompile := publishTask(publishLocalConfiguration in MavenCompile).value,
publishLocal in SbtCompile := publishTask(publishLocalConfiguration in SbtCompile).value,
publishLocal := Seq(publishLocal in MavenCompile, publishLocal in SbtCompile).dependOn.value,
publishTo := {
  val nexus = "http://maven.baidu-int.com/nexus/content/repositories/"
  if (isSnapshot.value)
    Some("snapshots" at nexus + "Baidu_Local_Snapshots")
  else
    Some("releases"  at nexus + "Baidu_Local")
},

运行 publishLocal 任务:

[error] (sql / publish) Undefined resolver 'snapshots'
[error] (tags / publish) Undefined resolver 'snapshots'
[error] (sql-kafka-0-10 / publish) Undefined resolver 'snapshots'
[error] java.lang.RuntimeException: Undefined resolver 'snapshots'
[error]     at scala.sys.package$.error(package.scala:30)
[error]     at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:136)
[error]     at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:133)

我可以成功运行编译、UT、打包,但无法发布。

它出什么问题了?

标签: scalasbt

解决方案


推荐阅读