Maven 1.x AspectJ Plugin

Unable to weave only sources defined in argument files. Error during compilation if argument file contains file from sourceDirectory.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 3.2
  • Fix Version/s: 4.0
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    4

Description

Some days ago I have started to use aspectj plugin for compilation
aspects. I use aspects only for tests. I have following structure in
project:
-src

aspectj - aspect sources

java - application sources

test - test sources

I have an "lst" file where defined what files should be compiled with
aspects e.g.:
com/toplinkmapping/UserRoleAspect.java
../java/com/toplinkmapping/UserRole.java

I want compile only files that defined in "lst" file and place classes
into test-classes folder. In project.properties I have defined
following properties:
maven.aspectj.source=1.4
maven.aspectj.argfiles=src/aspectj/aspects.lst

But when I have executed aspectj:compile I have error because this
task try to compile files from aspects.lst file and then from src/java
folder. And error occur because in aspects.lst defined files from java source
folder.

I have resolved this problem in my maven.xml by following way:
<postGoal name="test:compile">
<ant:path id="build.dest" location="${maven.build.dest}"/>
<maven:addPath id="maven.dependency.classpath" refid="build.dest"/>

<ant:path id="maven.compile.src.set"/>

<attainGoal name="aspectj:compile"/>

</postGoal>

So as you can see I have overwrite "maven.compile.src.set" path that
not so good.

I think it will be good if will be introduced new property
like "maven.aspectj.src.argfilesOnly" that if true then only sources that defined in argument files will be weaved. And following changes in plugin script are needed e.g.:
from
<ant:sourceroots>
<ant:path refid="${sourcePathRefid}"/>
<j:if test="${aspectSourcesPresent and weaveAspectSources}">
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
</j:if>
</ant:sourceroots>
to
<ant:sourceroots>
<j:if test="${context.getVariable('maven.aspectj.src.argfilesOnly') != 'true'}">
<ant:path refid="${sourcePathRefid}"/>
</j:if>
<j:if test="${aspectSourcesPresent and weaveAspectSources}">
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
</j:if>
</ant:sourceroots>

I have attached patch and test case for it. Please, take a look at them.

Activity

Hide
Carlos Sanchez added a comment -

If you could provide a patch in unified diff format it would be faster to fix.

Show
Carlos Sanchez added a comment - If you could provide a patch in unified diff format it would be faster to fix.
Hide
Alexey Dashkevich added a comment -

Required patch attached.

Show
Alexey Dashkevich added a comment - Required patch attached.
Hide
Carlos Sanchez added a comment -

Patch with fixed paths and missing modifications to plugin.jelly and plugin.properties

Show
Carlos Sanchez added a comment - Patch with fixed paths and missing modifications to plugin.jelly and plugin.properties
Hide
Carlos Sanchez added a comment -

After taking a close look to this I see no reason why you'd need to specify what sources to weave in maven. If you want your aspect to affect only one class you should change the pointcut.

I don't see too much point in adding this to the plugin.

Show
Carlos Sanchez added a comment - After taking a close look to this I see no reason why you'd need to specify what sources to weave in maven. If you want your aspect to affect only one class you should change the pointcut. I don't see too much point in adding this to the plugin.
Hide
Alexey Dashkevich added a comment -

What about performance. I have about 1300 classes in project and time for compile aspects with sources take about 4 minutes. If I add this property it take about 25 seconds. Furthermore in samples of AspectJ distributive shows possiblility to weave aspects and source that defined only in lst file.

It can save time during development because for example I execute tests every 30 minutes.

Show
Alexey Dashkevich added a comment - What about performance. I have about 1300 classes in project and time for compile aspects with sources take about 4 minutes. If I add this property it take about 25 seconds. Furthermore in samples of AspectJ distributive shows possiblility to weave aspects and source that defined only in lst file. It can save time during development because for example I execute tests every 30 minutes.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: