This question is actually quite old, but since I came across the same problem, I still want to share my solution.
The best solution I've found is this . In fact, there is no native AspectJ support in Gradle, and existing plugins (like the Gradle AspectJ plugin) do not work with Lombok. So the solution is to enable time-based compilation in your code manually. Ready to go gradle.build for Java 8 is
buildscript { repositories { jcenter() maven { url 'http://repo.spring.io/plugins-release' } } dependencies { } } apply plugin: 'idea' // if you use IntelliJ apply plugin: 'java' ext { aspectjVersion = '1.8.9' springVersion = '4.2.1.RELEASE' } repositories { jcenter() } configurations { ajc aspects compile { extendsFrom aspects } } dependencies { compile "org.aspectj:aspectjrt:$aspectjVersion" compile "org.aspectj:aspectjweaver:$aspectjVersion" ajc "org.aspectj:aspectjtools:$aspectjVersion" aspects "org.springframework:spring-aspects:$springVersion" } def aspectj = { destDir, aspectPath, inpath, classpath -> ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath) ant.iajc( maxmem: "1024m", fork: "true", Xlint: "ignore", destDir: destDir, aspectPath: aspectPath, inpath: inpath, classpath: classpath, source: project.sourceCompatibility, target: project.targetCompatibility ) } compileJava { doLast { aspectj project.sourceSets.main.output.classesDir.absolutePath, configurations.aspects.asPath, project.sourceSets.main.output.classesDir.absolutePath, project.sourceSets.main.runtimeClasspath.asPath } } compileTestJava { dependsOn jar doLast { aspectj project.sourceSets.test.output.classesDir.absolutePath, configurations.aspects.asPath + jar.archivePath, project.sourceSets.test.output.classesDir.absolutePath, project.sourceSets.test.runtimeClasspath.asPath } }
You can find an additional explanation in the article already mentioned above . The build.gradle given here is an updated version of the version given in the article to allow the use of Java 8 and AspectJ version 1.8.9, and in addition, all unnecessary things are deleted.
Fable source share