Results 1 to 6 of 6

Thread: Compiling aspectJ 5 annotated aspects with Ant

  1. #1
    Join Date
    Aug 2006
    Posts
    236

    Default Compiling aspectJ 5 annotated aspects with Ant

    Hi

    I have some aspects (plain java classes with the annotation @Aspect). I know how to do load time weaving, however is there a specific task definition that i need for the annotated aspects in the build file. I know there is iajc but i don't have .aj extensions. Not sure if i still use this or theres a nother process.


    Thanks

  2. #2
    Join Date
    Aug 2006
    Posts
    236

    Default

    Got it sorted.

  3. #3
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    56

    Default

    Quote Originally Posted by amin View Post
    Got it sorted.
    Hi Amin,
    It would be useful to post how you got it sorted for the benefit of other readers.....

    Thanks
    /Tom

  4. #4
    Join Date
    Aug 2006
    Posts
    236

    Default

    Hi

    I use the following:

    Code:
    	<target name="compile-withaspects" depends="clean,init">
    		 <iajc sourceroots="${project.src}" 
    	    	destDir="${project.classes}"
    	    	fork="true"
    	    	debug="on"
    	    	verbose="true"
    		    target="${java.target}"
    	    	source="${java.source}"
    			classpathref="javac.compiler.classpath">
    	    </iajc>
    		<copy todir="${project.classes}">
    	    	<fileset dir="${project.src}"
    	             includes="**/*.txt,**/*.xml,**/*.properties"/>
    		</copy> 
    	</target>
    The only problem I have is that I have a enforcement aspect that tracks the usage of System.out.println and printStackTrace(). When I try to compile I get an exception via Ant. I had a look around to exclude this aspect from the build process but no luck. The src dir contains all the aspects. I am using cruise control so when I compile via eclipse i can exclude from the build process. But CC takes the latest version and complains about the aspect.

    I'm still looking on the web. If anyone has any ideas then please let me know otherwise if I solve the problem I'll post it.

  5. #5
    Join Date
    Aug 2006
    Posts
    236

    Default

    Ok. Found something out about this. Reading the Eclipse AspectJ book I think Enforcement aspects should be placed in a different src folder. Commit this to version control but exclude when building. Is this a correct approach?

  6. #6
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Quote Originally Posted by amin View Post
    Reading the Eclipse AspectJ book I think Enforcement aspects should be placed in a different src folder. Commit this to version control but exclude when building. Is this a correct approach?
    Generally, this is the recommended approach for starter aspects. The idea is to start getting benefit of AspectJ without having to commitment upfront to always using those. In such situations, you need an easy to include/exclude aspects and using a separate source folder is one way.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •