Category Archives: aspectj

When Run Ant Script, AspectJ does not Import Aspect source folder out side java classes?

I create simple Ant Script to compile my AspectJ Project. Java file compile well under <Javac> tag witch out compile using aspectJ. But when compiling Aspectj (.aj) file, it gives error not import java class. (`iajc - tag pass import error'). My aspect.aj file import some .java classes in other modules.

This is my build.xml file

  <target name="init"  >
     <!-- Create the build directory structure used by compile -->
     <mkdir dir="${build}/classes"/>
  </target>


  <target name="resolve" depends="init" >
     <!-- Compile the java code from ${src} into ${build}/classes -->
     <javac  srcdir="${src}" destdir="${build}/classes"  includeantruntime="false"  />
  </target>

  <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
    <classpath>
      <pathelement location="${lib}/aspectjtools-1.8.6.jar"/>
    </classpath>
  </taskdef>


  <target name="compile.aspectj"  depends = "resolve"  > 
     <iajc destDir="${build}/classes"   >
        <sourceroots>
                 <pathelement location="${src}/bank_aspect" />              
        </sourceroots>

         <classpath>
                <pathelement location="${lib}/aspectjrt-1.8.6.jar"/>
        </classpath>
    </iajc>
  </target>

My folder structure show below image and all aspect file content under bank_aspect folder.

enter image description here

This is the error, coming when I run 'Ant' command in Command Promt.

enter image description here

Could you help me to avoid this error?