How to apply scala macro paradise plugin?

(Tom) #1


I’m trying to setup a minimalist test project for which I need to apply the scala macro paradise plugin.

I can’t find how to have a successful build.

My build.gradle is as:

apply plugin: 'scala'
apply plugin: 'eclipse'

sourceCompatibility = 1.7
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version

repositories {

dependencies {
    compile 'com.julianpeeters:avro-scala-macro-annotations_2.11:0.5' 
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'

test {
    systemProperties 'property': 'value'

buildscript {
    repositories {
    dependencies {
        classpath 'org.scalamacros:paradise_2.11.6:2.1.0-M5'

apply plugin: 'what to put here ??'

I get the following error message:
macro annotation could not be expanded (the most common reason for that is that you need to enable the macro paradise plugin; another possibility is that you try to use macro annotation in the same compilation run that defines it)



(René Groeschke) #2

scala macro paradise plugin is a scalac compiler plugin which is currently not supported by gradle. I will raise an issue for that.

(Tom) #3

Thanks for your quick answer

(Tom) #4

Hi René,

Is there any workaround for using this plugin in a project built with gradle ?


(kzarzycki) #5

Hi! I also hit this issue and can’t find a workaround for this. Anyone knows how to enable macroparadise scalac plugin in gradle??

It is necessary for people that want to use gradle for compilation of project in scala 2.10, and yes, a lot of projects still stick to 2.10, just to mention few: Apache Kafka, Apache Samza.

I find gradle such a better tool than sbt, it would really be great if it support Scala better (veery popular language lately).

(Chris L) #6

I found the following work around - tested and worked:

configurations {
configurations.scalaCompiler.transitive = false

dependencies {

scalaCompiler “org.scalamacros:paradise_2.11.7:2.1.0-M5”


def String scalaCompilerOptions="-Xplugin:$configurations.scalaCompiler.singleFile.path"  
compileScala.scalaCompileOptions.additionalParameters = [scalaCompilerOptions]  
compileTestScala.scalaCompileOptions.additionalParameters = [scalaCompilerOptions]  


(monnef) #7

Thank you, your work around is great :smile:.