2012-01-21 20:27:14 +08:00
|
|
|
// redefine the compileJava and compileTestJava tasks in order to
|
|
|
|
// compile sources with ajc instead of javac
|
|
|
|
|
|
|
|
configurations {
|
2012-12-07 04:56:24 +08:00
|
|
|
ajc
|
|
|
|
aspects
|
|
|
|
ajInpath
|
2012-01-21 20:27:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
task compileJava(overwrite: true) {
|
2012-12-07 04:56:24 +08:00
|
|
|
dependsOn JavaPlugin.PROCESS_RESOURCES_TASK_NAME
|
|
|
|
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
def outputDir = project.sourceSets.main.output.classesDir
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
inputs.files(project.sourceSets.main.allSource + project.sourceSets.main.compileClasspath)
|
|
|
|
outputs.dir outputDir
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
doLast{
|
|
|
|
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
|
|
|
|
classpath: configurations.ajc.asPath)
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
ant.iajc(source: sourceCompatibility, target: targetCompatibility,
|
|
|
|
maxmem: "1024m", fork: "true", Xlint: "ignore",
|
|
|
|
destDir: outputDir.absolutePath,
|
|
|
|
aspectPath: configurations.aspects.asPath,
|
|
|
|
inpath: configurations.ajInpath.asPath,
|
|
|
|
sourceRootCopyFilter: "**/*.java",
|
2012-12-07 08:57:16 +08:00
|
|
|
classpath: sourceSets.main.runtimeClasspath.asPath) {
|
2012-12-07 04:56:24 +08:00
|
|
|
sourceroots {
|
|
|
|
sourceSets.main.java.srcDirs.each {
|
|
|
|
pathelement(location:it.absolutePath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 20:27:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
task compileTestJava(overwrite: true) {
|
2012-12-07 04:56:24 +08:00
|
|
|
dependsOn JavaPlugin.PROCESS_TEST_RESOURCES_TASK_NAME
|
|
|
|
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileTestJava")
|
|
|
|
dependsOn jar
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
def outputDir = project.sourceSets.test.output.classesDir
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
inputs.files(project.sourceSets.test.allSource + project.sourceSets.test.compileClasspath)
|
|
|
|
outputs.dir outputDir
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
doLast{
|
|
|
|
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
|
|
|
|
classpath: configurations.ajc.asPath)
|
2012-01-21 20:27:14 +08:00
|
|
|
|
2012-12-07 04:56:24 +08:00
|
|
|
ant.iajc(source: sourceCompatibility, target: targetCompatibility,
|
|
|
|
maxmem: "1024m", fork: "true", Xlint: "ignore",
|
|
|
|
destDir: outputDir.absolutePath,
|
|
|
|
aspectPath: jar.archivePath,
|
|
|
|
inpath: configurations.ajInpath.asPath,
|
2012-12-07 08:57:16 +08:00
|
|
|
classpath: sourceSets.test.runtimeClasspath.asPath + jar.archivePath) {
|
2012-12-07 04:56:24 +08:00
|
|
|
sourceroots {
|
|
|
|
sourceSets.test.java.srcDirs.each {
|
|
|
|
pathelement(location:it.absolutePath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 20:27:14 +08:00
|
|
|
}
|