Complete rewrite of the plugin. Now using AspectJ 1.1 and performing binary weaving on jar generated by the <code>jar:jar</code> goal. Also supports creation and weaving-in of reusable aspect libraries.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114067 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,132 +1,206 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:util="jelly:util">
|
||||
<!--
|
||||
=============================================================================
|
||||
AspectJ plugin for Maven. It offers 2 main features:
|
||||
- Ability to automatically weave aspects defined in
|
||||
${pom.build.aspectSourceDirectory}. This feature has no goal and is
|
||||
triggered automatically when the jar:jar goal is invoked if the
|
||||
${maven.aspectj.autoweave} property is set to true.
|
||||
- Generate a reusable aspect jar, by creating a jar of the aspects found
|
||||
in ${pom.build.aspectSourceDirectory}. This is invoked through the
|
||||
aspectj:jar goal.
|
||||
=============================================================================
|
||||
-->
|
||||
|
||||
<!--==================================================================-->
|
||||
<!-- Compile all source code, weaving the Aspects -->
|
||||
<!--==================================================================-->
|
||||
<goal name="aspectj"
|
||||
description="Compile code with AspectJ"
|
||||
prereqs="aspectj:compile"/>
|
||||
<project
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:util="jelly:util">
|
||||
|
||||
<goal name="aspectj:compile"
|
||||
description="Compile code with AspectJ">
|
||||
|
||||
<j:if test="${sourcesPresent == 'true'}">
|
||||
<!--
|
||||
========================================================================
|
||||
Default goal.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectj" prereqs="aspectj:weave"
|
||||
description="Weave aspects in project jar"/>
|
||||
|
||||
<ant:taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.Ajc"/>
|
||||
<!--
|
||||
========================================================================
|
||||
Automatic weaving on jar:jar if the ${maven.aspectj.autoweave}
|
||||
property is set to true.
|
||||
========================================================================
|
||||
-->
|
||||
<postGoal name="jar:jar">
|
||||
<attainGoal name="aspectj:init"/>
|
||||
<j:if test="${autoWeave == 'true'}">
|
||||
<attainGoal name="aspectj:weave-internal"/>
|
||||
</j:if>
|
||||
</postGoal>
|
||||
|
||||
<ant:available property="aspectSourcesPresent"
|
||||
<!--
|
||||
========================================================================
|
||||
Init AspectJ Ant task and global initializations.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectj:init">
|
||||
|
||||
<ant:taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
|
||||
<ant:classpath>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjtools')}"/>
|
||||
</ant:classpath>
|
||||
</ant:taskdef>
|
||||
|
||||
<ant:available property="aspectSourcesPresent"
|
||||
file="${pom.build.aspectSourceDirectory}"/>
|
||||
|
||||
<ant:uptodate property="aspectj.compile.notRequired"
|
||||
targetfile="${maven.build.dir}/${maven.final.name}.jar">
|
||||
<!-- Decide whether there is anything to weave -->
|
||||
<j:forEach var="artifact" items="${pom.artifacts}">
|
||||
<j:set var="dep" value="${artifact.dependency}"/>
|
||||
<j:if test="${dep.type == 'aspect'}">
|
||||
<j:set var="aspectLibrariesPresent" value="true"/>
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
<ant:condition property="shouldWeave">
|
||||
<ant:or>
|
||||
<ant:isset property="aspectSourcesPresent"/>
|
||||
<ant:isset property="aspectLibrariesPresent"/>
|
||||
</ant:or>
|
||||
</ant:condition>
|
||||
|
||||
<!-- Decide whether auto weave is on -->
|
||||
<ant:condition property="autoWeave">
|
||||
<ant:and>
|
||||
<ant:isset property="shouldWeave"/>
|
||||
<ant:istrue value="${maven.aspectj.autoweave}"/>
|
||||
</ant:and>
|
||||
</ant:condition>
|
||||
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
Weave aspects in project jar
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectj:weave"
|
||||
prereqs="aspectj:init,jar:jar,aspectj:weave-internal"
|
||||
description="Weave aspects in project jar"/>
|
||||
|
||||
<!-- Private goal used to that when the jar:jar postgoal is called we don't
|
||||
have to call aspectj:init and jar:jar twice -->
|
||||
<goal name="aspectj:weave-internal">
|
||||
|
||||
<j:if test="${shouldWeave == 'true'}">
|
||||
|
||||
<!-- Only weave if input jar has been modified. This is needed for
|
||||
the case when the user does a second run without changing
|
||||
sources -->
|
||||
<ant:uptodate property="weaveNotRequired"
|
||||
targetfile="${maven.aspectj.injar.nonweaved}">
|
||||
<ant:srcfiles dir="${pom.build.sourceDirectory}"/>
|
||||
<j:if test="${aspectSourcesPresent == 'true'}">
|
||||
<ant:srcfiles dir="${pom.build.aspectSourceDirectory}"/>
|
||||
</j:if>
|
||||
<ant:srcfiles dir="${pom.build.aspectSourceDirectory}"/>
|
||||
</ant:uptodate>
|
||||
|
||||
<j:set var="aspectjCompileNotRequired" value="${aspectj.compile.notRequired}"/>
|
||||
<j:if test="${aspectjCompileNotRequired == null}">
|
||||
|
||||
<j:set
|
||||
var="ajcEmacssymFlag"
|
||||
value="${maven.aspectj.ajc.option.emacssym}"/>
|
||||
|
||||
<ant:ajc
|
||||
destdir="${maven.build.dest}"
|
||||
excludes="**/package.html"
|
||||
debug="${maven.compile.debug}"
|
||||
deprecation="${maven.compile.deprecation}"
|
||||
optimize="${maven.compile.optimize}"
|
||||
emacssym="${ajcEmacssymFlag}">
|
||||
|
||||
<ant:src>
|
||||
<ant:path refid="maven.compile.src.set"/>
|
||||
<j:if test="${aspectSourcesPresent == 'true'}">
|
||||
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
|
||||
</j:if>
|
||||
</ant:src>
|
||||
|
||||
<j:forEach var="sm" items="${pom.build.sourceModifications}">
|
||||
<ant:available property="classPresent" classname="${sm.className}"/>
|
||||
<j:if test="${classPresent != 'true'}">
|
||||
<j:forEach var="exclude" items="${sm.excludes}">
|
||||
<ant:exclude name="${exclude}"/>
|
||||
</j:forEach>
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
|
||||
<ant:classpath>
|
||||
<ant:path refid="maven.dependency.classpath"/>
|
||||
<ant:pathelement path="${maven.build.dest}"/>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
||||
</ant:classpath>
|
||||
</ant:ajc>
|
||||
|
||||
</j:if>
|
||||
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
|
||||
<goal name="aspectj:ajdoc" description="Javadoc source using ajdoc">
|
||||
|
||||
<j:if test="${sourcesPresent == 'true'}">
|
||||
|
||||
<ant:taskdef name="ajdoc" classname="org.aspectj.tools.ant.taskdefs.Ajdoc" />
|
||||
|
||||
<ant:available property="aspectSourcesPresent"
|
||||
file="${pom.build.aspectSourceDirectory}"/>
|
||||
|
||||
<!-- retrieve various javadoc plugin vars -->
|
||||
<util:tokenize var="javadocVarList" delim=",">
|
||||
maven.javadoc.author,maven.javadoc.destdir,
|
||||
maven.javadoc.links,maven.javadoc.maxmemory,
|
||||
maven.javadoc.private,maven.javadoc.stylesheet,
|
||||
maven.javadoc.use,maven.javadoc.version
|
||||
</util:tokenize>
|
||||
<j:if test="${weaveNotRequired == null}">
|
||||
|
||||
<j:forEach var="javadocVar" items="${javadocVarList}">
|
||||
<j:set var="javadocVar" value="${javadocVar.trim()}" />
|
||||
<j:set var="${javadocVar}"
|
||||
value="${pom.getPluginContext('maven-javadoc-plugin').getVariable(javadocVar)}"/>
|
||||
</j:forEach>
|
||||
<!-- Rename input jar file to a temporary name so that we can use the
|
||||
same name for the outjar -->
|
||||
<move file="${maven.aspectj.outjar}"
|
||||
tofile="${maven.aspectj.injar.nonweaved}"/>
|
||||
|
||||
<ant:ajdoc packagenames="${pom.package}.*"
|
||||
destdir="${maven.javadoc.destdir}"
|
||||
author="${maven.javadoc.author}"
|
||||
private="${maven.javadoc.private}"
|
||||
version="${maven.javadoc.version}"
|
||||
use="${maven.javadoc.use}"
|
||||
windowtitle="${title}"
|
||||
doctitle="${title}"
|
||||
bottom="${copyright}"
|
||||
stylesheetfile="${maven.javadoc.stylesheet}">
|
||||
<!-- fork to avoid BCEL library version conflict with maven -->
|
||||
<ant:iajc fork="true" debug="${maven.aspectj.debug}"
|
||||
outjar="${maven.aspectj.outjar}"
|
||||
injars="${maven.aspectj.injar.nonweaved}"
|
||||
copyInjars="true"
|
||||
sourceRootCopyFilter="${maven.aspectj.sourceRootCopyFilters}"
|
||||
emacssym="${maven.aspectj.emacssym}">
|
||||
|
||||
<ant:forkclasspath>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjtools')}"/>
|
||||
</ant:forkclasspath>
|
||||
|
||||
<ant:sourceroots>
|
||||
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
|
||||
</ant:sourceroots>
|
||||
|
||||
<j:forEach var="link" items="${links}">
|
||||
<ant:link href="${link.trim()}"/>
|
||||
</j:forEach>
|
||||
<ant:classpath>
|
||||
<ant:path refid="maven.dependency.classpath"/>
|
||||
<ant:path location="${maven.build.dest}"/>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
||||
</ant:classpath>
|
||||
|
||||
<ant:sourcepath>
|
||||
<ant:path refid="maven.compile.src.set"/>
|
||||
<j:if test="${aspectSourcesPresent == 'true'}">
|
||||
<pathelement location="${pom.build.aspectSourceDirectory}"/>
|
||||
</j:if>
|
||||
</ant:sourcepath>
|
||||
|
||||
</ant:ajdoc>
|
||||
<!-- Look for aspect libraries to use for weaving -->
|
||||
<ant:aspectpath>
|
||||
<j:forEach var="artifact" items="${pom.artifacts}">
|
||||
<j:set var="dep" value="${artifact.dependency}"/>
|
||||
<j:if test="${dep.type == 'aspect'}">
|
||||
<ant:pathelement location="${artifact.path}"/>
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
</ant:aspectpath>
|
||||
|
||||
</ant:iajc>
|
||||
</j:if>
|
||||
</j:if>
|
||||
|
||||
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
Generate a jar of reusable aspects found in
|
||||
${pom.build.aspectSourceDirectory}. This jar can then be uploaded to
|
||||
the remote repository to serve as reusable aspects for other projects.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectj:jar" prereqs="aspectj:init"
|
||||
description="Generate reusable aspect jar">
|
||||
|
||||
<j:if test="${shouldWeave == 'true'}">
|
||||
|
||||
<!-- Only regenerate jar if aspect files have been modified. -->
|
||||
<ant:uptodate property="jarNotRequired"
|
||||
targetfile="${maven.aspectj.library}">
|
||||
<ant:srcfiles dir="${pom.build.aspectSourceDirectory}"/>
|
||||
</ant:uptodate>
|
||||
|
||||
<j:if test="${jarNotRequired == null}">
|
||||
<!-- fork to avoid BCEL library version conflict with maven -->
|
||||
<ant:iajc fork="true" debug="${maven.aspectj.debug}"
|
||||
outjar="${maven.aspectj.library}"
|
||||
sourceRootCopyFilter="${maven.aspectj.sourceRootCopyFilters}"
|
||||
emacssym="${maven.aspectj.emacssym}">
|
||||
<ant:forkclasspath>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjtools')}"/>
|
||||
</ant:forkclasspath>
|
||||
<ant:sourceroots>
|
||||
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
|
||||
</ant:sourceroots>
|
||||
<ant:classpath>
|
||||
<ant:path refid="maven.dependency.classpath"/>
|
||||
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
||||
</ant:classpath>
|
||||
</ant:iajc>
|
||||
</j:if>
|
||||
</j:if>
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
Install the reusable aspects in the local repository.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectj:jar-install" prereqs="aspectj:jar"
|
||||
description="Install reusable aspect jar in local repository">
|
||||
|
||||
<j:if test="${shouldWeave == 'true'}">
|
||||
<ant:property name="aspectdir__" value="${maven.repo.local}/${pom.artifactDirectory}/aspects"/>
|
||||
<ant:mkdir dir="${aspectdir__}"/>
|
||||
<ant:copy file="${maven.aspectj.library}" overwrite="true"
|
||||
todir="${aspectdir__}"/>
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1 +1,29 @@
|
||||
maven.aspectj.ajc.option.emacssym=no
|
||||
# -------------------------------------------------------------------
|
||||
# Default properties for the AspectJ Plugin
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
# If true, aspects located in ${pom.build.aspectSourceDirectory} will be
|
||||
# weaved into the project java sources automatically upon invocation of
|
||||
# the jar:jar goal.
|
||||
maven.aspectj.autoweave = false
|
||||
|
||||
# Name of the output jar containing the weaved aspects
|
||||
maven.aspectj.outjar = ${maven.build.dir}/${maven.final.name}.jar
|
||||
|
||||
# Name of non-weaved jar. The non-weaved jar (a.k.a input jar) will be
|
||||
# moved to this name so that the new weaved jar can reuse the same name
|
||||
maven.aspectj.injar.nonweaved = ${maven.build.dir}/${maven.final.name}-notweaved.jar
|
||||
|
||||
# List of resource files to exclude when copying resources from the input jar
|
||||
# to the weaved output jar
|
||||
maven.aspectj.sourceRootCopyFilters = **/CVS/*,**/*.java,**/*.aj
|
||||
|
||||
# If true, emit .ajesym symbol files for Emacs support
|
||||
maven.aspectj.emacssym = no
|
||||
|
||||
# If true, run in debug mode
|
||||
maven.aspectj.debug = false
|
||||
|
||||
# Name of the output jar of reusable aspects. Used only in the
|
||||
# aspectj:jar goal
|
||||
maven.aspectj.library = ${maven.build.dir}/${pom.artifactId}-aspects-${pom.currentVersion}.jar
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>maven-aspectj-plugin</id>
|
||||
<name>Maven AspectJ Plug-in</name>
|
||||
<currentVersion>1.1</currentVersion>
|
||||
<currentVersion>2.0-SNAPSHOT</currentVersion>
|
||||
<description/>
|
||||
<shortDescription>Eclipse Plugin for AspectJ</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/aspectj/</url>
|
||||
@@ -20,6 +20,11 @@
|
||||
<name>1.1</name>
|
||||
<tag>MAVEN_ASPECTJ_1_1</tag>
|
||||
</version>
|
||||
<version>
|
||||
<id>2.0</id>
|
||||
<name>2.0</name>
|
||||
<tag>HEAD</tag>
|
||||
</version>
|
||||
</versions>
|
||||
<developers>
|
||||
<developer>
|
||||
@@ -57,23 +62,15 @@
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.1.0</version>
|
||||
<properties>
|
||||
<classloader>root</classloader>
|
||||
</properties>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectj-ant</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<properties>
|
||||
<classloader>root</classloader>
|
||||
</properties>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectj-tools</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<artifactId>aspectjtools</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<properties>
|
||||
<classloader>root</classloader>
|
||||
</properties>
|
||||
|
||||
@@ -3,15 +3,22 @@
|
||||
<properties>
|
||||
<title>Changes</title>
|
||||
<author email="dion@multitask.com.au">dIon Gillard</author>
|
||||
<author email="vmassol@pivolis.com">Vincent Massol</author>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
<release version="2.0" date="in CVS">
|
||||
<action dev="vmassol" type="add">
|
||||
Complete rewrite of the plugin. Now using AspectJ 1.1 and performing
|
||||
binary weaving on jar generated by the <code>jar:jar</code> goal. Also
|
||||
supports creation and weaving-in of reusable aspect libraries.
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.1" date="2003-09-21">
|
||||
<action dev="dion" type="add">
|
||||
Added documentation for navigation, changes, properties and goals
|
||||
</action>
|
||||
</release>
|
||||
|
||||
<release version="1.0" date="2002-07-16">
|
||||
<action dev="jvanzyl" type="add">
|
||||
Original release for Maven 1.0-beta6
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
<body>
|
||||
<section name="Goals">
|
||||
<p>Todo. For the time being, please refer to the plugin.jelly file
|
||||
in the aspectj plugin directory.</p>
|
||||
<!--
|
||||
<table>
|
||||
<tr><th>Goal</th><th>Description</th></tr>
|
||||
<tr>
|
||||
@@ -37,6 +40,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
-->
|
||||
</section>
|
||||
</body>
|
||||
</document>
|
||||
|
||||
@@ -4,14 +4,25 @@
|
||||
<properties>
|
||||
<title>Maven AspectJ Plug-in</title>
|
||||
<author email="dion@multitask.com.au">dIon Gillard</author>
|
||||
<author email="vmassol@pivolis.com">Vincent Massol</author>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
<section name="Maven AspectJ Plug-in">
|
||||
<p>
|
||||
This plugin provides the basic facilities for compiling
|
||||
code using AspectJ.
|
||||
AspectJ plugin for Maven. It offers the following features:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Ability to automatically weave aspects on the jar generated
|
||||
by the jar plugin. This also includes the ability to add
|
||||
dependencies on reusable aspect libraries located in your Maven
|
||||
repository.
|
||||
</li>
|
||||
<li>
|
||||
Ability to generate and deploy a reusable aspect jar.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
For more information on the functionality provided by this plugin,
|
||||
please see the <a href="goals.html">Goals</a> document.
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
<properties>
|
||||
<title>Maven AspectJ Plugin Properties</title>
|
||||
<author email="dion@multitask.com.au">dIon Gillard</author>
|
||||
<author email="vmassol@pivolis.com">Vincent Massol</author>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
<section name="Maven AspectJ Plugin Settings">
|
||||
<p>Todo. For the time being, please refer to the plugin.properties file
|
||||
in the aspectj plugin directory.</p>
|
||||
<!--
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Property name</th>
|
||||
@@ -117,6 +122,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
-->
|
||||
</section>
|
||||
</body>
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user