Created
March 30, 2020 09:46
-
-
Save gcdd1993/0c99e2cc9d335dad65c93ca5ac1465a3 to your computer and use it in GitHub Desktop.
AspectJ for Java in Gradle 6.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
aspectjVersion = '1.9.5' | |
springVersion = '5.1.11.RELEASE' | |
} | |
} | |
apply plugin: 'java' | |
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.classesDirs.asPath, | |
configurations.aspects.asPath, | |
project.sourceSets.main.output.classesDirs.asPath, | |
project.sourceSets.main.runtimeClasspath.asPath | |
} | |
} | |
compileTestJava { | |
dependsOn jar | |
doLast { | |
aspectj project.sourceSets.test.output.classesDirs.asPath, | |
configurations.aspects.asPath + jar.archiveFile, | |
project.sourceSets.test.output.classesDirs.asPath, | |
project.sourceSets.test.runtimeClasspath.asPath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment