matanox
matanox

Reputation: 13716

can you inject a compiler plugin from the sbt prompt?

In sbt, can you inject a compiler plugin from the sbt prompt, rather than from the build definition files?

Motivation:

being able to inject your own compiler plugin that you develop, into projects that are part of your test suite for it, without editing their build definitions. I find that automatically editing a build definition to wire in a plugin is rather non-deterministic...

Additional Motivation:

flexibly compile with and without a certain compiler plugin without editing files nor polluting a team git with a compiler plugin you only need to use at certain times. E.g. consider https://github.com/sksamuel/scalac-scapegoat-plugin.

If all else fails, can you do this with a globally installed sbt plugin that would introduce a new sbt command?

Upvotes: 0

Views: 37

Answers (1)

matanox
matanox

Reputation: 13716

Running the plugin from a local location can work like in the following example:

set scalacOptions in ThisBuild += "-Xplugin:/home/USERNAME/.ivy2/local/......./jars/plugin_2.11.jar"

However, this method won't fetch a plugin from a repository, only from a local path. Looking for a way to load the plugin globally and only activate it from the sbt prompt, naively adding the plugin as a managed dependency in the global plugins definition at ~/.sbt/0.13/plugins/plugins.sbt alone, does not activate the plugin when you thereafter compile a project.

Upvotes: 1

Related Questions