Gradle Scala Plugin corollary to addCompilerPlugin in sbt

(Matt Zimmer) #1


Searching for ‘gradle add subcut scala compiler plugin’ returns nothing helpful.

What is gradle’s corollary to sbt’s addCompilerPlugin?

Thanks, Matt

(Peter Niederwieser) #2

It should be possible to accomplish this by passing the correct ‘scalac’ command line arguments. For example:

compileScala.scalaCompileOptions.additionalParameters = ["-Xplugin:path/to/plugin.jar"]

‘scalac -X’ shows the following compiler plugin related command line arguments:

              Load one or more plugins from files.
    Disable the given plugin(s).
                Print a synopsis of loaded plugins.
    Abort unless the given plugin(s) are available.
  -Xpluginsdir <path>
          Path to search compiler plugins.

(Matt Zimmer) #3

Thanks Peter. I placed the full path to subcut in that parameter and that worked.

I’ll have to set the rest of this aside for later research.

I didn’t see a straightforward way to grab the path of the subcut dependency in my build file to substitute in “-Xplugin:path/to/plugin.jar”.

That, coupled with the fact that it shows annoying error markers in the IDE, has led me to use the less convenient mechanism that doesn’t require the plug-in.

Cheers, Matt