I am trying to test a sbt-plugin (hereafter MyPlugin) with sbt-scripted, but it keeps on giving me a java.lang.RuntimeException (the plugin compiles properly) due to this error (see here for a complete gist):
[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 depends on sbteclipse (I need to execute the "eclipse" Command
programmatically), as stated in last row of MyPlugin/build.sbt
file:
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")
My AutoPlugin
subclass overrides both trigger
and requires
signatures as follows:
override def trigger = allRequirements
override def requires = EclipsePlugin
I setup a simple sbt scripted test, but it throws the java.lang.RuntimeException
described above. I cannot understand why.
This is the sbt scripted configuration:
test/build.sbt
version := "0.0.1"
scalaVersion in ThisBuild := "2.10.6"
name := "myPluginSimpleTest"
enablePlugins(MyPlugin)
test/project/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?
What am I missing?
Thank you!