Skip to content

Instantly share code, notes, and snippets.

@edrabc
Last active December 17, 2015 18:09
Show Gist options
  • Save edrabc/5650911 to your computer and use it in GitHub Desktop.
Save edrabc/5650911 to your computer and use it in GitHub Desktop.
AspectJ support for Gradle 1.5+ (extracted from https://github.com/ultraq/gradle-support) Version from http://www.breskeby.com/2010/02/using-gradle-with-aspectj, does not work straight off, so just copying here version from https://raw.github.com/ultraq/gradle-support/master/aspectj.gradle, in order to adapt it to my needs and freeze the current…
configurations {
ajc
aspects
ajInpath
}
dependencies {
ajc 'org.aspectj:aspectjtools:1.7.2'
compile 'org.aspectj:aspectjrt:1.7.2'
}
task compileJava(dependsOn: JavaPlugin.PROCESS_RESOURCES_TASK_NAME, overwrite: true) {
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, 'compileJava')
inputs.dir sourceSets.main.java.srcDirs
outputs.dir sourceSets.main.output.classesDir
doLast {
ant.taskdef(
resource: 'org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties',
classpath: configurations.ajc.asPath)
ant.iajc(
source: sourceCompatibility,
target: targetCompatibility,
destDir: sourceSets.main.output.classesDir.absolutePath,
fork: 'true',
aspectPath: configurations.aspects.asPath,
inpath: configurations.ajInpath.asPath,
sourceRootCopyFilter: '**/*.java,**/*.aj',
classpath: configurations.compile.asPath) {
sourceroots {
sourceSets.main.java.srcDirs.each { dir ->
if (dir.exists()) {
pathelement(location: dir.absolutePath)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment