Added support for non-production aspects.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7271e8205d
commit
061173235c
@ -15,7 +15,9 @@
|
||||
<project
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:util="jelly:util">
|
||||
xmlns:u="jelly:util"
|
||||
xmlns:define="jelly:define"
|
||||
xmlns:aw="aspectwerkz">
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
@ -46,13 +48,79 @@
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
|
||||
<path id="classpath.main">
|
||||
<ant:pathelement location="${maven.dependency.classpath}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('dom4j:dom4j')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('trove:trove')}"/>
|
||||
<path id="classpath.compile">
|
||||
<ant:pathelement location="${maven.dependency.classpath}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz')}"/>
|
||||
</path>
|
||||
|
||||
<path id="classpath.main">
|
||||
<ant:path refid="classpath.compile"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('dom4j:dom4j')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('trove:trove')}"/>
|
||||
</path>
|
||||
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
Compile aspect sources.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectwerkz:compile" prereqs="aspectwerkz:init,java:compile"
|
||||
description="Compile AspectWerkz java sources">
|
||||
|
||||
<!-- If there are non-production aspect sources, compile them -->
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.src.dir') != null}">
|
||||
|
||||
<ant:javac destdir="${maven.aspectwerkz.build.dest}"
|
||||
excludes="**/package.html"
|
||||
debug="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.debug')}"
|
||||
deprecation="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.deprecation')}"
|
||||
target="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.target')}"
|
||||
optimize="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.optimize')}">
|
||||
|
||||
<ant:src path="${maven.aspectwerkz.src.dir}"/>
|
||||
|
||||
<ant:classpath>
|
||||
<ant:path refid="classpath.compile"/>
|
||||
<ant:pathelement path="${maven.build.dest}"/>
|
||||
</ant:classpath>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs')}">
|
||||
<ant:compilerarg line="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs')}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding')}">
|
||||
<ant:setProperty name="encoding" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding')}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable')}">
|
||||
<ant:setProperty name="executable" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable')}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork')}">
|
||||
<ant:setProperty name="fork" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork')}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source')}">
|
||||
<ant:setProperty name="source" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source')}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose')}">
|
||||
<ant:setProperty name="verbose" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose')}"/>
|
||||
</j:if>
|
||||
</ant:javac>
|
||||
|
||||
<!-- Copy non java source files -->
|
||||
<ant:copy todir="${maven.aspectwerkz.build.dest}">
|
||||
<ant:fileset dir="${maven.aspectwerkz.src.dir}">
|
||||
<ant:exclude name="**/*.java"/>
|
||||
<ant:exclude name="**/*.html"/>
|
||||
</ant:fileset>
|
||||
</ant:copy>
|
||||
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
@ -65,6 +133,8 @@
|
||||
description="Compile AspectWerkz javadoc attributes (xml-defined aspects)">
|
||||
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.mode') == 'xmldef'}">
|
||||
|
||||
<ant:echo>WARNING: aspectwerkz:attributec is not currently working very well...</ant:echo>
|
||||
|
||||
<!-- TODO: only run attributeC if sources are newer than target
|
||||
XML definition file -->
|
||||
@ -75,7 +145,11 @@
|
||||
<ant:sysproperty key="aspectwerkz.definition.validate"
|
||||
value="${maven.aspectwerkz.definition.validate}"/>
|
||||
|
||||
<!-- TODO: Use ${maven.compile.src.set} and ${maven.aspectwerkz.src.dir}.
|
||||
See aspectwerkz:aspectc for an example. However, I need to verify
|
||||
if attributec supports several input directories first -->
|
||||
<ant:arg file="${maven.aspectwerkz.src.dir}"/>
|
||||
|
||||
<ant:arg file="${maven.aspectwerkz.definition.file}"/>
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.definition.file.merge') != null}">
|
||||
<ant:arg line="-m ${maven.aspectwerkz.definition.file.merge}"/>
|
||||
@ -102,39 +176,33 @@
|
||||
them in the bytecode of the aspects themselves.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectwerkz:aspectc" prereqs="aspectwerkz:init,java:compile">
|
||||
<goal name="aspectwerkz:aspectc" prereqs="aspectwerkz:compile">
|
||||
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.mode') == 'attribdef'}">
|
||||
|
||||
<!-- TODO: only run aspectc if sources are newer than target
|
||||
XML definition file -->
|
||||
|
||||
<ant:mkdir dir="${maven.aspectwerkz.build.dir}"/>
|
||||
<ant:mkdir dir="${maven.aspectwerkz.weave.build.dir}"/>
|
||||
|
||||
<ant:java dir="${maven.build.dir}" failonerror="true" fork="true"
|
||||
classname="org.codehaus.aspectwerkz.attribdef.definition.AspectC">
|
||||
<!-- Transforming Ant path structure into a list of dirs that can be used
|
||||
to define an Ant fileset. We're using <pathconvert> to automatically
|
||||
separate dirs with a known delimiter independently of any
|
||||
platform -->
|
||||
<ant:pathconvert property="compileSrcSetString" pathSep="||||"
|
||||
refid="maven.compile.src.set"/>
|
||||
<u:tokenize var="srcDirs" delim="||||">${compileSrcSetString}</u:tokenize>
|
||||
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.verbose') == 'true'}">
|
||||
<ant:arg value="-verbose"/>
|
||||
</j:if>
|
||||
<!-- Parse all known source directories -->
|
||||
<j:forEach var="srcDir" items="${srcDirs}">
|
||||
<aw:aspectc src="${srcDir}" dest="${maven.build.dest}"/>
|
||||
</j:forEach>
|
||||
|
||||
<!-- Path to source dir -->
|
||||
<ant:arg file="${maven.aspectwerkz.src.dir}"/>
|
||||
|
||||
<!-- Path to classes dir -->
|
||||
<ant:arg file="${maven.build.dest}"/>
|
||||
|
||||
<!-- (optional) Path to where weaved classes will be generated -->
|
||||
<ant:arg file="${maven.aspectwerkz.build.dir}"/>
|
||||
|
||||
<ant:classpath>
|
||||
<ant:path refid="classpath.main"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz-core')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('qdox:qdox')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('bcel:bcel')}"/>
|
||||
</ant:classpath>
|
||||
|
||||
</ant:java>
|
||||
<!-- Parse non-production aspects if source directory has been defined -->
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.src.dir') != null}">
|
||||
<aw:aspectc src="${maven.aspectwerkz.src.dir}"
|
||||
dest="${maven.aspectwerkz.build.dest}"/>
|
||||
</j:if>
|
||||
|
||||
<!-- AspectC currently has a bug in that it creates a java.lang.Object class file in the output directory. Until
|
||||
this is fixed, we need to remove that files. Otherwise, AspectWerkc will try to instrument it, which will
|
||||
@ -151,10 +219,11 @@
|
||||
and "attribdef" modes.
|
||||
========================================================================
|
||||
-->
|
||||
<goal name="aspectwerkz:weave"
|
||||
prereqs="aspectwerkz:init,aspectwerkz:attributec,aspectwerkz:aspectc,java:compile">
|
||||
<goal name="aspectwerkz:weave"
|
||||
prereqs="aspectwerkz:attributec,aspectwerkz:aspectc"
|
||||
description="Weave aspects (offline mode)">
|
||||
|
||||
<!-- TODO: Add support for extension classes -->
|
||||
<!-- TODO: Add support for extension classes -->
|
||||
|
||||
<ant:java dir="${maven.build.dir}" failonerror="true" fork="true"
|
||||
classname="org.codehaus.aspectwerkz.compiler.AspectWerkzC">
|
||||
@ -170,7 +239,7 @@
|
||||
|
||||
<ant:arg value="-verify"/>
|
||||
|
||||
<ant:arg file="${maven.aspectwerkz.build.dir}"/>
|
||||
<ant:arg file="${maven.aspectwerkz.weave.build.dir}"/>
|
||||
|
||||
<ant:classpath>
|
||||
<ant:path refid="classpath.main"/>
|
||||
@ -185,4 +254,49 @@
|
||||
|
||||
</goal>
|
||||
|
||||
<!--
|
||||
========================================================================
|
||||
Custom tag library for factorizing common actions that need to be
|
||||
executed several times in this script.
|
||||
========================================================================
|
||||
-->
|
||||
<define:taglib uri="aspectwerkz">
|
||||
|
||||
<!--
|
||||
@param src source directory that will be parsed
|
||||
@param dest path where compiled sources are located
|
||||
-->
|
||||
<define:tag name="aspectc">
|
||||
|
||||
<ant:echo>Parsing [${src}] using [${dest}] ...</ant:echo>
|
||||
|
||||
<ant:java dir="${maven.build.dir}" failonerror="true" fork="true"
|
||||
classname="org.codehaus.aspectwerkz.attribdef.definition.AspectC">
|
||||
|
||||
<j:if test="${context.getVariable('maven.aspectwerkz.verbose') == 'true'}">
|
||||
<ant:arg value="-verbose"/>
|
||||
</j:if>
|
||||
|
||||
<!-- Path to source dir -->
|
||||
<ant:arg file="${src}"/>
|
||||
|
||||
<!-- Path to classes dir -->
|
||||
<ant:arg file="${dest}"/>
|
||||
|
||||
<!-- (optional) Path to where weaved classes will be generated -->
|
||||
<ant:arg file="${maven.aspectwerkz.weave.build.dir}"/>
|
||||
|
||||
<ant:classpath>
|
||||
<ant:path refid="classpath.main"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz-core')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('qdox:qdox')}"/>
|
||||
<ant:pathelement location="${plugin.getDependencyPath('bcel:bcel')}"/>
|
||||
</ant:classpath>
|
||||
|
||||
</ant:java>
|
||||
|
||||
</define:tag>
|
||||
|
||||
</define:taglib>
|
||||
|
||||
</project>
|
||||
|
||||
@ -12,11 +12,8 @@
|
||||
# Aspects/Advices/Pointcuts. The 2 valid values are "xmldef" and "attribdef".
|
||||
maven.aspectwerkz.mode = attribdef
|
||||
|
||||
# Location of AW sources
|
||||
maven.aspectwerkz.src.dir = ${basedir}/src/main
|
||||
|
||||
# Location where weaved classes will be generated.
|
||||
maven.aspectwerkz.build.dir = ${maven.build.dest}
|
||||
maven.aspectwerkz.weave.build.dir = ${maven.build.dest}
|
||||
|
||||
# Decide whether definition validation is turned on or off.
|
||||
maven.aspectwerkz.definition.validate = false
|
||||
@ -24,6 +21,16 @@ maven.aspectwerkz.definition.validate = false
|
||||
# Verbose mode
|
||||
maven.aspectwerkz.verbose = false
|
||||
|
||||
# (optional) The AW plugin looks for source files in ${pom.sourceDirectory}.
|
||||
# It also supports all source directories added to the ${maven.compile.src.set}
|
||||
# Ant path variable. Moreover, if you wish to keep non-production aspects in a
|
||||
# specific directory, you can define the property below.
|
||||
# maven.aspectwerkz.src.dir = ${basedir}/src/aspectwerkz
|
||||
|
||||
# (optional) Location where non-production aspect classes will be compiled to.
|
||||
# There are the classes defined by ${maven.aspectwerkz.src.dir}.
|
||||
# maven.aspectwerkz.build.dest = ${maven.build.dir}/aspectwerkz/classes
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# attribdef mode properties
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
<system id="test">
|
||||
<package name="org.apache.maven.aspectwerkz">
|
||||
<use-aspect class="SampleAspect"/>
|
||||
<use-aspect class="SampleNonProductionAspect"/>
|
||||
</package>
|
||||
</system>
|
||||
</aspectwerkz>
|
||||
|
||||
@ -3,3 +3,5 @@
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
maven.aspectwerkz.verbose = true
|
||||
maven.aspectwerkz.src.dir = ${basedir}/src/aspectwerkz
|
||||
maven.aspectwerkz.build.dir = ${maven.build.dir}/aspectwerkz/classes
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package org.apache.maven.aspectwerkz;
|
||||
|
||||
import org.codehaus.aspectwerkz.attribdef.Pointcut;
|
||||
import org.codehaus.aspectwerkz.attribdef.aspect.Aspect;
|
||||
import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
|
||||
|
||||
/**
|
||||
* @Aspect perJVM
|
||||
*
|
||||
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
||||
*/
|
||||
public class SampleNonProductionAspect extends Aspect
|
||||
{
|
||||
/**
|
||||
* @Execution * *..Target.someMethod(..)
|
||||
*/
|
||||
Pointcut sampleNonProductionPointcut;
|
||||
|
||||
/**
|
||||
* @Around sampleNonProductionPointcut
|
||||
*/
|
||||
public Object sampleNonProductionAdvice(final JoinPoint joinPoint)
|
||||
throws Throwable
|
||||
{
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,20 @@
|
||||
(i.e. <code>maven.aspectwerkz.mode = xmldef</code>).
|
||||
</description>
|
||||
</goal>
|
||||
<goal>
|
||||
<name>aspectwerkz:aspectc</name>
|
||||
<description>
|
||||
Parse files for custom javadoc tags (attribef mode only) and weave
|
||||
them in the bytecode of the aspects themselves.
|
||||
</description>
|
||||
</goal>
|
||||
<goal>
|
||||
<name>aspectwerkz:compile</name>
|
||||
<description>
|
||||
Compile both main runtime sources and any non-production source
|
||||
aspects.
|
||||
</description>
|
||||
</goal>
|
||||
<goal>
|
||||
<name>aspectwerkz:weave</name>
|
||||
<description>
|
||||
|
||||
@ -38,15 +38,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.aspectwerkz.src.dir</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Location of aspect sources. Default location is
|
||||
<code>${basedir}/src/main</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.aspectwerkz.build.dir</td>
|
||||
<td>maven.aspectwerkz.weave.build.dir</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Location where weaved classes will be generated. Default to
|
||||
@ -69,6 +61,30 @@
|
||||
this plugin's goals. Defaults to <code>false</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.aspectwerkz.src.dir</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Location of non-production aspect source files.
|
||||
The AW plugin looks for source files in
|
||||
<code>${pom.sourceDirectory}</code>. It also supports all source
|
||||
directories added to the <code>${maven.compile.src.set}</code>
|
||||
Ant path variable. Moreover, if you wish to keep non-production
|
||||
aspects in a specific directory, you can define the
|
||||
<code>maven.aspectwerkz.src.dir</code> property. For example
|
||||
<code>maven.aspectwerkz.src.dir = ${basedir}/src/aspectwerkz</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.aspectwerkz.build.dest</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Location where non-production aspect classes will be compiled to.
|
||||
These are the classes defined by
|
||||
<code>${maven.aspectwerkz.src.dir}</code>. For example
|
||||
<code>maven.aspectwerkz.build.dest = ${maven.build.dir}/aspectwerkz/classes</code>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user