Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.2
-
Component/s: None
-
Labels:None
-
Number of attachments :6
Description
We need the ability to weave in optional aspects.
Attachments
-
$i18n.getText("admin.common.words.hide")
- aspectj.zip
- 03/Oct/04 11:50 AM
- 38 kB
- Mark Proctor
-
- aspectj/.cvsignore 0.0 kB
- aspectj/CVS/Entries 0.3 kB
- aspectj/CVS/Repository 0.0 kB
- aspectj/CVS/Root 0.0 kB
- aspectj/plugin.jelly 9 kB
- aspectj/plugin.properties 2 kB
- aspectj/project.properties 0.9 kB
- aspectj/project.xml 4 kB
- aspectj/src/CVS/Entries 0.0 kB
- aspectj/src/CVS/Repository 0.0 kB
- aspectj/src/CVS/Root 0.0 kB
- aspectj/src/plugin-test/.cvsignore 0.0 kB
- aspectj/src/plugin-test/argfile.lst 0.1 kB
- aspectj/src/plugin-test/CVS/Entries 0.2 kB
- aspectj/src/plugin-test/CVS/Repository 0.0 kB
- aspectj/src/plugin-test/CVS/Root 0.0 kB
- aspectj/src/plugin-test/maven.xml 1 kB
- aspectj/src/.../project.properties 0.7 kB
- aspectj/src/plugin-test/project.xml 2 kB
- aspectj/src/plugin-test/.../CVS/Entries 0.0 kB
- aspectj/src/plugin-test/.../CVS/Repository 0.0 kB
- aspectj/src/plugin-test/.../aspect/CVS/Root 0.0 kB
- aspectj/src/plugin-test/.../CVS/Entries 0.0 kB
- aspectj/src/plugin-test/.../CVS/Repository 0.1 kB
- aspectj/src/plugin-test/.../apache/CVS/Root 0.0 kB
- aspectj/src/plugin-test/.../CVS/Entries 0.0 kB
- aspectj/src/plugin-test/.../CVS/Repository 0.1 kB
- aspectj/src/plugin-test/.../aspectj/CVS/Root 0.0 kB
- aspectj/src/.../aspectj/Sample.aj 1 kB
- aspectj/src/plugin-test/.../aspectj/TestA.aj 1 kB
-
- optional-aspects.diff
- 03/Oct/04 11:48 AM
- 8 kB
- Mark Proctor
-
- optional-aspects.diff
- 21/Sep/04 5:28 PM
- 3 kB
- Mark Proctor
-
- optional-aspects.diff
- 02/Aug/04 4:25 PM
- 2 kB
- Mark Proctor
-
$i18n.getText("admin.common.words.hide")
- optional-aspects-test.zip
- 21/Sep/04 5:31 PM
- 3 kB
- Mark Proctor
-
- optional-aspects-test/goodbye.lst 0.0 kB
- optional-aspects-test/hello.lst 0.0 kB
- optional-aspects-test/maven.xml 0.6 kB
- optional-aspects-test/project.properties 0.1 kB
- optional-aspects-test/project.xml 0.5 kB
- optional-aspects-test/src/.../Goodbye.java 0.2 kB
- optional-aspects-test/src/.../Hello.java 0.3 kB
- optional-aspects-test/src/.../test/Test.java 0.2 kB
$i18n.getText("admin.common.words.show")- optional-aspects-test.zip
- 21/Sep/04 5:31 PM
- 3 kB
- Mark Proctor
-
- plugin.jelly
- 21/Sep/04 5:29 PM
- 9 kB
- Mark Proctor
Activity
I have further enhanced this in drools and include for reference purposes.
So that users can specify features they want compiled in at runtime I create a file in src/aspects/conf that specifes the aspects to weave for that feature. That way I can just do the following to specify the features I want:
drools.aspects = event-model, trace
The code to achieve this is:
<preGoal name="java:compile">
<j:set var="droolsAspects" value="${drools.aspects}"/>
<j:if test="${droolsAspects != null}">
<util:tokenize var="tokens" delim="," trim="true">${droolsAspects}</util:tokenize>
<j:forEach var="token" items="${tokens}">
<j:set var="mavenAspects" value="${mavenAspects},src/aspects/conf/${token.trim()}.conf"/>
</j:forEach>
<j:if test="${mavenAspects != ''}">
<j:set var="maven.aspectj.aspects" value="${mavenAspects}" />
<attainGoal name="aspectj:compile"/>
</j:if>
</j:if>
</preGoal>
Here's more info from the AJDT project http://tinyurl.com/4boct
I'm having trouble applying the patch, could you post it in unified diff format? (diff -u)
ok I'll get that diff -U to you asap. do you still want the example, if so I'll try and knock up and something this weekend.
That link doesn't work.
Mark
Ok, if you can make the example I'll thank you.
This link works for me
http://tinyurl.com/4boct
else
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/org.eclipse.ajdt/AJDT_30M9_src/org.eclipse.ajdt/doc/AJDTug/ajdt-newbuildconfigs.html
I think you'll find interesting the last section titled "Using .ajproperties files with Ant"
Sorry about slacking on this one. I held off while I was looking into .ajproperties as that seemed the better way of doing it, rather than with .lst - do you know the status of this, do the current release versions use this, or is it still a dev feature?
Mark
It seems that ajproperties is not support by iajc yet, nor is it supported by the ant task AjcTask.
The docs in ajdt claims that you can use includes/excluds on the AjcTask, this is only ajc, iajc only supports SourceRoots and SourceRootsList.
For this reason I believe it makes sense to continue with the .lst format, untill ajproperties are better supported.
Example application.
Change comments in project.properties file by uncommenting one of the maven.aspectj.aspects properties:
#maven.aspectj.aspects = hello.lst
maven.aspectj.aspects = goodbye.lst
Different message printed depending on which .lst file you specify
Documentation and automated tests (check src/plugin-test) are required to commit the changes.
If I have to do them myself the commit will be delayed.
maven.aspectj.aspects should be renamed to maven.aspectj.argfiles, to be more exact.
I'll update the property as you suggested and move the example I wrote to a unit test.
I'm not sure how to unit test this, as part of the standard Maven UnitTest framework; as each test would require a "maven clean" and a "maven jar" for re-compilation. Any ideas?
Mark
Just chatting on #maven on irc and think I can alter maven.xml to do this, although I think it might get a little messy:
<goal name="testPlugin" prereqs="clean,test-aspectj-compile">
</goal>
<goal name="test-aspectj-compile">
<attainGoal name="aspectj:test-compile"/>
<attainGoal name="test:test"/>
<attainGoal name="clean"/>
</goal>
You can add a new aspect to the test e.g. throwing an exception, a .lst to ignore that aspect and then you won't need to modify maven.xml
This is an updated diff which includes unit testing of optional aspects.
It runs the unit test twice. The first time for the standard aspectsSourceDirectory, the second time using the given .list file. A system property is provided so that the unit test knows which mode its in, and thus which tests to run.
Incase there are any problems with the diff I have included the entire aspectj folder as a zip file.
Good work, thanks. I have changed a small thing, adding maven.aspectj.weaveAspectSources because argfiles can be used for other things than choosing aspects.
You can download it from http://cvs.apache.org/repository/maven/plugins/
If you check everything is correct I'll release the 3.2 version
works great. Using the example goal above I can now specify my aspects to compile in project.properties as:
drools.aspects = event
#drools.aspects = profile
#drools.aspects = event, profile
This should make things a lot easier for everyone, 3.2 asap please ![]()
You can also use
maven whatever -Ddrools.aspects=event
maven whatever -Ddrools.aspects=profile
maven whatever -Ddrools.aspects=event,profile
This diff allows optional aspects files to be included by specifying a comma delimited list in maven.aspectj.aspects. It uses the iajc argfiles propertly.
if you use maven.aspectj.aspects only those files are weaved, other aspects in your aspect source directory will be ignored.
The files specifed in maven.aspectj.aspects are line delimeted files either specifying the aspects to weave, or other line delimited files to process. Aspects are relative to the config file that specifies them.