我有一个名为sonar的插件,它是作为AutoPlugin开发和发布的:
ArraySegment
然后我们有一个使用该插件的项目,其Memory<T>
如下所示:
object Sonar extends AutoPlugin {
object autoImport {
lazy val sonar = taskKey[Unit]("sonar")
}
import autoImport._
override def trigger = allRequirements
lazy val sonarTask = Def.task {
<snip task code here which runs sonarqube scanner>
}
}
然后像这样build.sbt:
plugins.sbt
当我尝试运行sbt插件时,它说该插件已启用:
resolvers ++= Seq(
"Nexus Snapshot repo" at "url here"
)
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
addSbtPlugin("packagename" % "sonar" % "1.0-SNAPSHOT")
那为什么启用了我的插件却无法运行name := "hashing-library"
organization := "org name here"
scalaVersion := "2.12.6"
autoScalaLibrary := false
crossPaths := false
resolvers += "Nexus Release repo" at "https://nexusurl/content/repositories/releases/"
resolvers += "nexus Snapshot repo" at "https://nexusurl/content/repositories/snapshots/"
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
// Publishing options:
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { x => false }
publishTo := {
val nexus = "nexus url here"
if (isSnapshot.value)
Some("sonatype-snapshots" at nexus + "content/repositories/snapshots")
else
Some("sonatype-releases" at nexus + "content/repositories/releases")
}
?当我这样做时,它说:
<snip output>
packagename.sonar.Sonar: enabled in hashingLibrary
(显然,组织名称和url已被删除,以保护我的客户的机密性,但希望这不会影响我的问题!)
答案 0 :(得分:0)
插件的缺失部分是sonar
任务 key 和sonarTask
任务实现之间的连接,即您需要说键设置为实现值的位置。通常,您可以通过覆盖插件中的项目设置来做到这一点:
override def projectSettings = Seq(
sonar := sonarTask.value
)