Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 3.2
-
Fix Version/s: 4.0
-
Component/s: None
-
Labels:None
-
Number of attachments :
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.
If you could provide a patch in unified diff format it would be faster to fix.