scala - sbt plugin - own configuration classpath incomplete -


i want create sbt plugin new kind of tests. keep things simple created small fuzz test plugin, analog 1 mentioned in sbt docs.

my plugin class looks this:

package sbtfuzz  import sbt._, keys._  object fuzzplugin extends sbt.autoplugin {   override def requires = plugins.jvmplugin   override def trigger = allrequirements    object autoimport {     lazy val fuzz = config("fuzz") extend(compile)   }   import autoimport._    lazy val basefuzzsettings: seq[def.setting[_]] = seq(     test := {       println("fuzz test")     }   )   override lazy val projectsettings = inconfig(fuzz)(basefuzzsettings) ++ inconfig(fuzz)(defaults.compilesettings) } 

the thing added in comaprison code in docs inconfig(fuzz)(defaults.compilesettings) tasks compile code.

if execute sbt fuzz:compile, sources in src/fuzz/scala compiled. if sources have dependencies actual project code ( tests have) compile failes, because classes not found. guess it's because fuzz:fullclasspath has 1 entry:

[info] * attributed(.../fuzz/target/scala-2.10/sbt-0.13/fuzz-classes) 

whereas test:fullclasspath has project classes dependencies in it:

[info] * attributed(.../fuzz/target/scala-2.10/sbt-0.13/test-classes) [info] * attributed(.../fuzz/target/scala-2.10/sbt-0.13/classes) [info] * attributed(~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.4.jar) [info] * attributed(~/.ivy2/cache/org.scala-sbt/sbt/jars/sbt-0.13.13.jar) ... 

this way test:compile able compile test classes , fuzz:compile not.

how can configure fuzz configuration way test configuration is, including project dependencies?

thanks!

edit: found (in opinion) rather dirty workaround:

lazy val basefuzzsettings: seq[def.setting[_]] = seq(   fullclasspath in fuzz ++= (dependencyclasspath in test).value,   dependencyclasspath in fuzz ++= (dependencyclasspath in test).value,   ... ) 

with can compile fuzz classes successfully. there more sane way this? thanks!

for test configs, use defaults.testsettings , defaults.testtasks. note order matters:

inconfig(fuzz)(defaults.testsettings ++ defaults.testtasks ++ basesettings) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -