I have created IAJC task and replacing compileJava with it. My code is –
IAJCPlugin.groovy (custom plug-in)
class IAJCPlugin implements Plugin<Project> {
void apply(Project project) {
project.getPlugins().apply(JavaPlugin.class)
task compileJava(type: IAJC)
}
}
IAJC.groovy
class IAJC extends DefaultTask {
IAJC () {
project.configurations { iajcconf }
project.dependencies {
iajcconf 'org.aspectj:aspectjtools:1.6.2' }
doFirst {
ant.taskdef(resource: 'org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties', classpath: project.configurations.iajcconf.asPath)
project.sourceSets.main.java.srcDirs.each{ dir ->
if(dir.exists()) {
ant.iajc( destdir: project.sourceSets.main.output.classesDir,
source: "1.6",
srcdir : dir,
classpath: project.configurations.compile.asPath)
}
}
}
}
}
build.gradle
apply plugin: 'iajc' //custom plugin IAJCPlugin
This does not work and I am getting the following error –
Caused by: groovy.lang.MissingMethodException: No signature of method: com.pg.gradle.plugins.IAJCPlugin.compileJava() is applicable for argument types: (java.util.LinkedHashMap) values: [[type:class com.pg.gradle.tasks.IAJC]]
at com.pg.gradle.plugins.IAJCPlugin.apply(IAJCPlugin.groovy:17)