Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to prevent AJDT from weaving some class?

> 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


Back to the top