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') + } + } + } } }