From bb3b8e46839b0853252bed74abc2223436db4d6d Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Sat, 12 Mar 2011 18:46:17 -0600 Subject: [PATCH] Update AspectJPlugin to configure EclipseProject and EclipseClasspath tasks --- .../main/groovy/aspectj/AspectJPlugin.groovy | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy b/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy index 1a445b8ba5..64e273a645 100644 --- a/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy +++ b/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy @@ -9,6 +9,10 @@ import org.gradle.api.tasks.SourceSet import org.gradle.api.DefaultTask import org.gradle.api.GradleException +import org.gradle.plugins.eclipse.EclipseClasspath +import org.gradle.plugins.eclipse.EclipseProject +import org.gradle.plugins.eclipse.model.ProjectDependency + /** * * @author Luke Taylor @@ -47,6 +51,25 @@ class AspectJPlugin implements Plugin { outputs.dir(sourceSet.classesDir) aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath) } + + project.tasks.withType(EclipseProject).all { + whenConfigured { p -> + p.natures.add(0, 'org.eclipse.ajdt.ui.ajnature') + p.buildCommands = [new org.gradle.plugins.eclipse.model.BuildCommand('org.eclipse.ajdt.core.ajbuilder',[:])] + } + } + + project.tasks.withType(EclipseClasspath).all { + whenConfigured { classpath -> + def entries = classpath.entries.findAll { it instanceof ProjectDependency}.findAll { entry -> + def projectPath = entry.path.replaceAll('/',':') + project.rootProject.findProject(projectPath).plugins.findPlugin(AspectJPlugin) + } + entries.each { entry-> + entry.entryAttributes.put('org.eclipse.ajdt.aspectpath','org.eclipse.ajdt.aspectpath') + } + } + } } }