依赖于另一个插件的Sbt插件在使用sbt-scripted测试时会抛出RuntimeException

时间:2016-11-10 19:21:57

标签: scala plugins sbt sbt-plugin

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

[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脚本配置:

测试/ build.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?

我错过了什么?

谢谢!

0 个答案:

没有答案