How to apply scala macro paradise plugin?

Hi,

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 {
    mavenCentral()
}

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 {
        mavenCentral()
    }
    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)

Thanks

Tom

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

Thanks for your quick answer

Hi René,

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

Thanks

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).

I found the following work around - tested and worked:

configurations {
scalaCompiler
}
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]  

-cl

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