|
@@ -9,6 +9,7 @@ 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.api.plugins.JavaPlugin
|
|
import org.gradle.plugins.ide.eclipse.GenerateEclipseProject
|
|
import org.gradle.plugins.ide.eclipse.GenerateEclipseProject
|
|
import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath
|
|
import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath
|
|
import org.gradle.plugins.ide.eclipse.EclipsePlugin
|
|
import org.gradle.plugins.ide.eclipse.EclipsePlugin
|
|
@@ -22,6 +23,8 @@ import org.gradle.plugins.ide.eclipse.model.ProjectDependency
|
|
class AspectJPlugin implements Plugin<Project> {
|
|
class AspectJPlugin implements Plugin<Project> {
|
|
|
|
|
|
void apply(Project project) {
|
|
void apply(Project project) {
|
|
|
|
+ project.plugins.apply(JavaPlugin)
|
|
|
|
+
|
|
if (!project.hasProperty('aspectjVersion')) {
|
|
if (!project.hasProperty('aspectjVersion')) {
|
|
throw new GradleException("You must set the property 'aspectjVersion' before applying the aspectj plugin")
|
|
throw new GradleException("You must set the property 'aspectjVersion' before applying the aspectj plugin")
|
|
}
|
|
}
|
|
@@ -38,18 +41,24 @@ class AspectJPlugin implements Plugin<Project> {
|
|
project.configurations.add('aspectpath')
|
|
project.configurations.add('aspectpath')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ project.tasks.compileJava.deleteAllActions()
|
|
|
|
+
|
|
project.tasks.add(name: 'compileJava', overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) {
|
|
project.tasks.add(name: 'compileJava', overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) {
|
|
|
|
+ dependsOn project.configurations*.getTaskDependencyFromProjectDependency(true, "compileJava")
|
|
|
|
+
|
|
dependsOn project.processResources
|
|
dependsOn project.processResources
|
|
sourceSet = project.sourceSets.main
|
|
sourceSet = project.sourceSets.main
|
|
- inputs.files(sourceSet.java.srcDirs)
|
|
|
|
|
|
+ inputs.files(sourceSet.allSource)
|
|
outputs.dir(sourceSet.output.classesDir)
|
|
outputs.dir(sourceSet.output.classesDir)
|
|
aspectPath = project.configurations.aspectpath
|
|
aspectPath = project.configurations.aspectpath
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ project.tasks.compileTestJava.deleteAllActions()
|
|
|
|
+
|
|
project.tasks.add(name: 'compileTestJava', overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) {
|
|
project.tasks.add(name: 'compileTestJava', overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) {
|
|
dependsOn project.processTestResources, project.compileJava, project.jar
|
|
dependsOn project.processTestResources, project.compileJava, project.jar
|
|
sourceSet = project.sourceSets.test
|
|
sourceSet = project.sourceSets.test
|
|
- inputs.files(sourceSet.java.srcDirs)
|
|
|
|
|
|
+ inputs.files(sourceSet.allSource)
|
|
outputs.dir(sourceSet.output.classesDir)
|
|
outputs.dir(sourceSet.output.classesDir)
|
|
aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath)
|
|
aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath)
|
|
}
|
|
}
|
|
@@ -90,7 +99,11 @@ class Ajc extends DefaultTask {
|
|
|
|
|
|
@TaskAction
|
|
@TaskAction
|
|
def compile() {
|
|
def compile() {
|
|
|
|
+ logger.info("="*30)
|
|
|
|
+ logger.info("="*30)
|
|
logger.info("Running ajc ...")
|
|
logger.info("Running ajc ...")
|
|
|
|
+ logger.info("classpath: ${sourceSet.compileClasspath.asPath}")
|
|
|
|
+ logger.info("srcDirs $sourceSet.java.srcDirs")
|
|
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
|
|
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.output.classesDir.absolutePath,
|
|
ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.output.classesDir.absolutePath,
|
|
source: project.convention.plugins.java.sourceCompatibility,
|
|
source: project.convention.plugins.java.sourceCompatibility,
|
|
@@ -98,6 +111,7 @@ class Ajc extends DefaultTask {
|
|
aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
|
|
aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
|
|
sourceroots {
|
|
sourceroots {
|
|
sourceSet.java.srcDirs.each {
|
|
sourceSet.java.srcDirs.each {
|
|
|
|
+ logger.info(" sourceRoot $it")
|
|
pathelement(location: it.absolutePath)
|
|
pathelement(location: it.absolutePath)
|
|
}
|
|
}
|
|
}
|
|
}
|