123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- apply plugin: 'java'
- configurations {
- ajtools
- aspectpath
- }
- dependencies {
- ajtools "org.aspectj:aspectjtools:$aspectjVersion"
- compile "org.aspectj:aspectjrt:$aspectjVersion"
- }
- task compileJava(overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) {
- dependsOn processResources
- sourceSet = sourceSets.main
- inputs.files(sourceSets.main.java.srcDirs)
- outputs.dir(sourceSet.classesDir)
- aspectPath = configurations.aspectpath
- }
- task compileTestJava(overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) {
- dependsOn processTestResources, compileJava, jar
- sourceSet = sourceSets.test
- inputs.files(sourceSets.test.java.srcDirs)
- outputs.dir(sourceSet.classesDir)
- aspectPath = files(configurations.aspectpath, jar.archivePath)
- }
- class Ajc extends DefaultTask {
- SourceSet sourceSet
- FileCollection aspectPath
- Ajc() {
- logging.captureStandardOutput(LogLevel.INFO)
- }
- @TaskAction
- def compile() {
- println "Running ajc ..."
- ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
- ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.classesDir.absolutePath,
- source: project.convention.plugins.java.sourceCompatibility,
- target: project.convention.plugins.java.targetCompatibility,
- aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
- sourceroots {
- sourceSet.java.srcDirs.each {
- pathelement(location: it.absolutePath)
- }
- }
- }
- }
- }
- if(hasProperty('eclipseProject')) {
- eclipseProject.whenConfigured { project ->
- project.natures.add(0, 'org.eclipse.ajdt.ui.ajnature')
- project.buildCommands = [new org.gradle.plugins.eclipse.model.BuildCommand('org.eclipse.ajdt.core.ajbuilder',[:])]
- }
- }
- if(hasProperty('eclipseClasspath')) {
- eclipseClasspath.withXml { xml ->
- def ssa = xml.asNode().'classpathentry'.find { it.@path == '/spring-security-aspects' }
- ssa?.appendNode('attributes')?.appendNode('attribute',[name:'org.eclipse.ajdt.aspectpath',value:'org.eclipse.ajdt.aspectpath'])
- }
- }
|