Hi,

Thanks for the note, sorry, its probably not very clear (late night sessions
and all that!).

Not sure if its a red hering or not but I have test classes that are
*affected* by the aspects. So, I have a call pointcut on some method (called
A.doSomething) and and before aspect. The test code calls the method
doSomething and so is affected by the aspect.

Running

maven aspectj

creates target/classes which contain the A class, ATest class and the
aspect. Reverse engineering the test class here shows it has the correctly
weaved (is that the right word) aspect code in it.

running 

maven test (which has a pregoal to run the aspectj compiler)

creates target/test-classes and target.test-reports

The test-classes folder here only contains the test class (ATest.class) and
reverse engineering it shows that the aspect was not weaved. So, runing the
test will fail becuase the test is testing that the aspect is being used.

Changing the default maven.test.dest to something like
${maven.build.dir}/classes seems to help but in my real project doesn't
solve it completly.

I have a test project that demonstrates this (if anyone is interested), all
the settings are pretty much default.

I'll keep playing and post my findings here.

Cheers,



Jeff Jensen wrote:
> 
> Are you saying that the test classes in test-classes need a pass by the
> AspectJ compiler, or the test classes do not see the AspectJ compiled
> classes in the classes dir?  (or something else entirely?)
> 
> The fact that the "production" classes compile to target/classes and the
> test classes compile to /target/test-classes seems correct to me (from
> what
> I understand from your emails).  When the tests run, the production code
> is
> also on the classpath, so works well (now there could be some bug in
> that...
> :-).
> 
> 
> -----Original Message-----
> From: diyfiesta [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 13, 2006 9:53 AM
> To: users@maven.apache.org
> Subject: Re: [M1] AspectJ with two source trees (main/src & main/test)
> 
> 
> So, looking into this more (and having created a simple example project to
> demonstrate it), it looks like the the aspectj plugin is compiling things
> correctly, its just that the tests are being run from the incorrect place.
> 
> So, for example, the output of the aspectj compilation goes into
> 
> target/classes/...
> 
> but the tests run from a folder called 
> 
> target/test-classes/... 
> 
> which has the compiled test code, but not the aspectj compiled code. So,
> if
> a test is affected by an aspect, it isn't in this folder.
> 
> 
> diyfiesta wrote:
>> 
>> Hi,
>> 
>> Thanks for the note, I tried this but still don't have any luck, for 
>> example, I'm using the convention main/src/java and main/src/test for 
>> my source trees, so adding an src/aspectj folder doesn't really fit 
>> in, if I add it to main/src/aspectj, I get the same problem (and just 
>> for completness, setting it to src/aspectj causes is the same!).
>> 
>> From the plugin's homepage, I didn't get the impression that setting 
>> the soruce directiory to src/aspectj was a requirement more of an 
>> example, and you should be able to set this to whatever your folder 
>> is. Is this not the case?
>> 
>> I think I'll have a go at creating a simple test project that 
>> demonstrates the problem, see if I can get some feedback.
>> 
>> Any other ideas?
>> 
>> Cheers
>> 
>> 
>> Alexandre Touret wrote:
>>> 
>>> Hello,
>>> There are 2 builds : the classes and test classes.
>>> If you specify the aspectsourcedirectory in src/java, aspectj doesn t 
>>> parse any file in src/test. Its the default behaviour I can suggest 
>>> you to put all the aspects file have in ${maven.src.dir}/aspectj (as 
>>> described in the plugin homepage). I suppose this directory is 
>>> accessible in both the build classpaths and test classpath.
>>> 
>>> Hope this helps.
>>> Alexandre
>>> 
>>> Toby Weston wrote:
>>>> Hi Folks,
>>>> [...]
>>>> I've got my source code under main/src and the unit tests under 
>>>> main/test, however I can't get aspectj compiling both. I added this 
>>>> to my project.xml hoping it would pick up both, but it doesn't seem 
>>>> to,,,
>>>>
>>>>        <aspectSourceDirectory>main/src/java</aspectSourceDirectory>
>>>>        <aspectSourceDirectory>main/test/java</aspectSourceDirectory>
>>>>
>>>> I'm kind of not confident I know the correct process, so may be 
>>>> doing something really silly. I was thinking that the pregoal for 
>>>> compile to run the aspectj compiler would apply my aspects to the 
>>>> code that they affect? After running this though, my unit tests 
>>>> confirm that the aspect isn't applied, and if I reverse engineer the 
>>>> test code, there is no aspect code in there (and there is if I do a 
>>>> normal eclipse aspectj compile).
>>>>
>>>> So, for some reason, its not applying my aspects to test code in the 
>>>> second source tree... :(
>>>>
>>>> Cheers,
>>>> Toby
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>> 
>>> 
>>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/-M1--AspectJ-with-two-source-trees-%28main-src---main-
> test%29-tf2556159s177.html#a7319470
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-M1--AspectJ-with-two-source-trees-%28main-src---main-test%29-tf2556159s177.html#a7333729
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to