I found what was wrong when I switched to aop.xml management: I didn't add
-xmlConfigured into "Project properties->AspectJ
Compiler->Other->Non-standard compiler options". After adding it, the
project is compiled correctly.

Then both of changes exclude my Junit test classes from weaving:

<aspect name="MyAspect" scope="!com.foo.bar.Test.*Test"/>

and

<weaver>
<exclude within="com.foo.bar.Test.*Test"/>
</weaver>

I also did a test. If I remove -xmlConfigured, the project cannot be
compiled correctly. src/test/java/com/foo/bar/Test/AjdtWeavingTest.java is
not compiled. The files under src/main/java are compiled, but not be weaved.

I attached my project here. Not sure if this is a bug.

Thanks a lot.

On Thu, May 20, 2010 at 11:45 AM, Andy Clement <[email protected]>wrote:

> > It seems that AJDT tries to weave all classes in a project by default.
> > I attached files in a test project.
>
> yes
>
> > When I use "call" for pointcuts of interface Addable in MyAspect, AJDT
> tries
> > to weave the interface calls of the mock object. Sometimes I don't want
> the
> > advices in my unit test code, for example, advices from the log aspect.
> > How can I prevent AJDT from weaving junit test case classes?
>
> You can set the within clauses for your aspect to exclude the
> testcode.  Or you can try out aop.xml management:
>
> > If I add aop.xml into project properties->AspectJ Builder->aop.xml
> > Management, some wired things happens:
> >
> > all aspectj advice markers are gone. You need to clean the project first,
> > otherwise you may see the markers are still there.
>
> When you switch to using aop.xml files to control the builder you are
> switching from the default mode of 'all aspects included' to an opt-in
> model where only those specified in your aop.xml file are included.
> It is a bug that there wasn't a clean when you made the switch (want
> to raise it?)
>
> This feature is intended to help users developing aop.xml files that
> they will later use for load-time weaving, hence the switch to opt-in.
>
> > if you clean the project "Project->clean...", only the files under
> > src/main/java are compiled, src/test/java are not compiled.
>
> Don't really understand that - the choice of aop.xml shouldn't affect
> what gets compiled... is there an entry in the error log saying why
> compilation failed?
>
> > remove aop.xml from aop.xml management, everything comes back.
>
> When you had switched to aop.xml management and defined an aop.xml
> file that mentioned the aspects you wanted woven, did it weave
> anything?
>
> aop.xml management is the feature you want, it allows you to set a
> scope for an aspect so that you could avoid weaving your tests with
> your aspects.
>
> <aspect name="MyAspect" scope="!com.foo.tests..*"/>
>
> aop.xml management is still under development right now.
>
> Andy
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>

Attachment: bar.tgz
Description: GNU Zip compressed data

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to