0

我正在尝试使用 sbt-scripted 测试一个 sbt-plugin (以下称为MyPlugin),但由于此错误,它一直给我一个 java.lang.RuntimeException (插件正确编译)(完整要点请参见此处):

[error] 
[error]   last tree to typer: ArrayValue
[error]               symbol: null
[error]    symbol definition: null
[error]        symbol owners: 
[error]       context owners: method $sbtdef -> object $ca19269de636e3032318 -> package <empty>
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Apply( // implicit def wrapRefArray(xs: Array[Object]): collection.mutable.WrappedArray in class LowPriorityImplicits
[error]   scala.this."Predef"."wrapRefArray" // implicit def wrapRefArray(xs: Array[Object]): collection.mutable.WrappedArray in class LowPriorityImplicits, tree.tpe=(xs: Array[Object])collection.mutable.WrappedArray
[error]   ArrayValue(
[error]     <tpt> // tree.tpe=sbt.AutoPlugin
[error]     List(
[error]       "it"."flatmap"."myplugin"."MyPlugin" // sym= <error> bad symbolic reference. A signature in MyPlugin.class refers to term plugin
[error] in value com.sbteclipse which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling MyPlugin.class.
[error]     )
[error]   )
[error] )
[error] 

MyPlugin 依赖于sbteclipse(我需要以编程方式执行“eclipse” Command),如MyPlugin/build.sbt文件最后一行所述:

sbtPlugin := true

version := "0.0.1"

name := "myplugin"

scalaVersion := "2.10.6"
organization := "it.flatmap"

isSnapshot := true

//Configuring scriptedplugin
ScriptedPlugin.scriptedSettings

scriptedLaunchOpts <++= version apply { version =>
  Seq("-Xmx1024M", "-Dplugin.version=" + version)
}
//end of scripted plugin config

libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % "3.0.0" % "test")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

我的AutoPlugin子类覆盖triggerrequires签名如下:

override def trigger = allRequirements

override def requires = EclipsePlugin

我设置了一个简单的 sbt 脚本测试,但它抛出了java.lang.RuntimeException上述内容。我不明白为什么。

这是 sbt 脚本配置:

测试/构建.sbt

version := "0.0.1"

scalaVersion in ThisBuild := "2.10.6"

name := "myPluginSimpleTest"

enablePlugins(MyPlugin)

测试/项目/plugins.sbt

{
  val pluginVersion = System.getProperty("plugin.version")
  if(pluginVersion == null)
    throw new RuntimeException("""|The system property 'plugin.version' is not defined.
                                 |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
  else addSbtPlugin("it.flatmap" % "myplugin" % pluginVersion)
}

//should I add the eclipse plugin also here? if so, why?

我错过了什么?

谢谢!

4

0 回答 0