1

I have a java module that depends on aspectj. When I use the module in a java project, I simply tell maven to use aspectj-maven-plugin (mojo) and compile the project with ajcCompiler. Steps are inhereted from Maven + AspectJ - all steps to configure it

Now I have a grails project and I need to use the module there. Therefore, as I understand it, I need to override the compiler to

ant.property(name:'build.compiler', value:'org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter')

in _Events.groovy:eventCompileStart closure. this does not work, so there is also another suggestion to add an iajc task on eventCompileEnd (http://permalink.gmane.org/gmane.comp.lang.groovy.grails.user/127215)

How do I exactly do that? I am not sure about the process! BTW, I have 'org.codehaus.mojo:aspectj-maven-plugin:1.4' defined as compile time dependency on buildConfig.groovy

[update]

I defined this in _Events.groovy

ant.taskdef( resource:"org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath)
ant.iajc(destDir: grails.compile.classpath, source: "1.7", target:"1.7", ) {
    classpathref(dir: classesDirPath)
}

This 'should' work, but ofcourse it does not! What am I missing?

Community
  • 1
  • 1
bdas
  • 63
  • 1
  • 6

1 Answers1

1

Two step solution:

Define the IAJC task:

ant.taskdef(name: 'iajc', classname: 'org.aspectj.tools.ant.taskdefs.AjcTask')

Execute the IAJC task to weave the compiled classes

String aspectjrtPath = "path to your aspectjrt.jar"
String classesDirPath = "path to the compiled classes you're weaving"
ant.iajc(classpath: aspectjrtPath, destdir: classesDirPath) {
  inpath() {
    pathelement(path: classesDirPath)
  }
  aspectpath() {
    pathelement(path: icnTraceLibrary)
  }
}

This solved my problem, the target is now weaved with my trace framework.

bdas
  • 63
  • 1
  • 6