使用本地artifactory / maven代理设置sbt项目时,我看到以下消息:
为了指定在sbt项目中添加的所有解析器应该 被忽略,有利于存储库中配置的那些 配置,将以下配置选项添加到sbt 启动脚本:
-Dsbt.override.build.repos=true
将以下内容添加到build.sbt文件中:
resolvers += "Artifactory" at "http://url/artifactory/virtualRepository/"
但我想要实现的是类似于maven的行为,即不是手动覆盖SBT文件中的解析器,而是通过配置。 这也可能吗?如果有,怎么样? 期望的行为
目前,我只获得sbt插件的未解析依赖项:
::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalariform#sbt-scalariform;1.6.0: not found
[warn] :: org.scoverage#sbt-scoverage;1.5.0: not found
[warn] :: org.scalastyle#scalastyle-sbt-plugin;0.8.0: not found
[warn] :: net.virtual-void#sbt-dependency-graph;0.8.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
警告
[warn] module not found: org.scalariform#sbt-scalariform;1.6.0
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] d:\users\heilerg\.ivy2\local\org.scalariform\sbt-scalariform\scala_2.10\sbt_0.13\1.6.0\ivys\ivy.xml
[warn] ==== my-ivy-proxy-releases: tried
[warn] http://url/artifactory/virtualRepositoryScala/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== my-maven-proxy-releases: tried
[warn] http://url/artifactory/virtualRepositoryScala/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[warn] ==== Artima Maven Repository: tried
[warn] http://repo.artima.com/releases/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[info] Resolving org.scoverage#sbt-scoverage;1.5.0 ...
和SBT日志将显示
[ERROR] (o.a.r.RemoteRepoBase:766) - IO error while trying to download resource 'repo1:org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom': org.artifactory.api.repo.exception.maven.BadPomException: The target deployment path 'org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom' does not match the POM's expected path prefix 'org/scalariform/sbt-scalariform/1.6.0'. Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path.
有些人提到在Artifactory中使用以下选项来“抑制POM一致性检查”,但在当前版本的神器中我无法找到这样的选项。
答案 0 :(得分:0)
正如评论中所回答的,一个常见的解决方法是“禁止 POM 一致性检查” - Advanced Settings。
如果不希望这样,另一种方法可能是使用有效的 POM 重新发布插件。我写了 POM consistency for sbt plugins 来证明这是可以做到的。
// set some unique postfix
ThisBuild / version := "0.15.0-Pets1"
lazy val root = (project in file("."))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-assembly",
....
publishMavenStyle := true,
// add this
pomConsistency2021DraftSettings,
)
// Add the following
lazy val pomConsistency2021Draft = settingKey[Boolean]("experimental")
/**
* this is an unofficial experiment to re-publish plugins with better Maven compatibility
*/
def pomConsistency2021DraftSettings: Seq[Setting[_]] = Seq(
pomConsistency2021Draft := Set("true", "1")(sys.env.get("POM_CONSISTENCY").getOrElse("false")),
moduleName := {
if (pomConsistency2021Draft.value)
sbtPluginModuleName2021Draft(moduleName.value,
(pluginCrossBuild / sbtBinaryVersion).value)
else moduleName.value
},
projectID := {
if (pomConsistency2021Draft.value) sbtPluginExtra2021Draft(projectID.value)
else projectID.value
},
)
def sbtPluginModuleName2021Draft(n: String, sbtV: String): String =
s"""${n}_sbt${if (sbtV == "1.0") "1" else if (sbtV == "2.0") "2" else sbtV}"""
def sbtPluginExtra2021Draft(m: ModuleID): ModuleID =
m.withExtraAttributes(Map.empty)
.withCrossVersion(CrossVersion.binary)