소스 검색

Update AspectJPlugin to configure EclipseProject and EclipseClasspath tasks

Rob Winch 14 년 전
부모
커밋
bb3b8e4683
1개의 변경된 파일23개의 추가작업 그리고 0개의 파일을 삭제
  1. 23 0
      buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy

+ 23 - 0
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.DefaultTask
 import org.gradle.api.GradleException
 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
  * @author Luke Taylor
@@ -47,6 +51,25 @@ class AspectJPlugin implements Plugin<Project> {
             outputs.dir(sourceSet.classesDir)
             outputs.dir(sourceSet.classesDir)
             aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath)
             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')
+                }
+            }
+        }
     }
     }
 }
 }