You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vm...@apache.org on 2004/01/02 15:09:03 UTC

cvs commit: maven-plugins/aspectwerkz/src/plugin-test project.properties

vmassol     2004/01/02 06:09:03

  Modified:    aspectwerkz plugin.jelly plugin.properties
               aspectwerkz/xdocs properties.xml goals.xml
               aspectwerkz/src/plugin-test/conf aspectwerkz.xml
               aspectwerkz/src/plugin-test project.properties
  Added:       aspectwerkz/src/plugin-test/src/aspectwerkz/org/apache/maven/aspectwerkz
                        SampleNonProductionAspect.java
  Log:
  Added support for non-production aspects.
  
  Revision  Changes    Path
  1.12      +149 -35   maven-plugins/aspectwerkz/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/plugin.jelly,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- plugin.jelly	2 Jan 2004 11:38:35 -0000	1.11
  +++ plugin.jelly	2 Jan 2004 14:09:03 -0000	1.12
  @@ -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,17 +48,83 @@
         </j:otherwise>
       </j:choose>
   
  +    <path id="classpath.compile">
  +      <ant:pathelement location="${maven.dependency.classpath}"/>
  +      <ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz')}"/>
  +    </path>    
  +
       <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')}"/>
  +      <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>
  +
  +  <!--
  +     ========================================================================
          Compile javadoc attributes and generate an XML definition file. Used
          only in xmldef mode.
        ========================================================================
  @@ -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: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="${maven.aspectwerkz.src.dir}"/>
  -
  -        <!-- Path to classes dir -->
  -        <ant:arg file="${maven.build.dest}"/>
  +      <ant:mkdir dir="${maven.aspectwerkz.weave.build.dir}"/>
   
  -        <!-- (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>
  +      <!-- 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>
  +
  +      <!-- Parse all known source directories -->
  +      <j:forEach var="srcDir" items="${srcDirs}">
  +        <aw:aspectc src="${srcDir}" dest="${maven.build.dest}"/>
  +      </j:forEach>
  +
  +      <!-- 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>
  
  
  
  1.7       +11 -4     maven-plugins/aspectwerkz/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/plugin.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- plugin.properties	27 Dec 2003 13:11:25 -0000	1.6
  +++ plugin.properties	2 Jan 2004 14:09:03 -0000	1.7
  @@ -12,17 +12,24 @@
   # 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
   
   # 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
  
  
  
  1.5       +25 -9     maven-plugins/aspectwerkz/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/xdocs/properties.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- properties.xml	27 Dec 2003 13:11:25 -0000	1.4
  +++ properties.xml	2 Jan 2004 14:09:03 -0000	1.5
  @@ -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
  @@ -67,6 +59,30 @@
             <td>
               Decide whether to use verbose output or not during execution of
               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>
  
  
  
  1.4       +14 -0     maven-plugins/aspectwerkz/xdocs/goals.xml
  
  Index: goals.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/xdocs/goals.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- goals.xml	27 Dec 2003 13:11:25 -0000	1.3
  +++ goals.xml	2 Jan 2004 14:09:03 -0000	1.4
  @@ -15,6 +15,20 @@
           </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>
              Weave aspects at build time (offline mode). Works for both "xmldef"
  
  
  
  1.3       +1 -0      maven-plugins/aspectwerkz/src/plugin-test/conf/aspectwerkz.xml
  
  Index: aspectwerkz.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/src/plugin-test/conf/aspectwerkz.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- aspectwerkz.xml	25 Dec 2003 16:31:23 -0000	1.2
  +++ aspectwerkz.xml	2 Jan 2004 14:09:03 -0000	1.3
  @@ -5,6 +5,7 @@
     <system id="test">
       <package name="org.apache.maven.aspectwerkz">
         <use-aspect class="SampleAspect"/>
  +      <use-aspect class="SampleNonProductionAspect"/>
       </package>
     </system>
   </aspectwerkz>
  
  
  
  1.1                  maven-plugins/aspectwerkz/src/plugin-test/src/aspectwerkz/org/apache/maven/aspectwerkz/SampleNonProductionAspect.java
  
  Index: SampleNonProductionAspect.java
  ===================================================================
  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(); 
    }
}
  
  
  1.6       +2 -0      maven-plugins/aspectwerkz/src/plugin-test/project.properties
  
  Index: project.properties
  ===================================================================
  RCS file: /home/cvs/maven-plugins/aspectwerkz/src/plugin-test/project.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.properties	27 Dec 2003 13:11:25 -0000	1.5
  +++ project.properties	2 Jan 2004 14:09:03 -0000	1.6
  @@ -3,3 +3,5 @@
   # -------------------------------------------------------------------
   
   maven.aspectwerkz.verbose = true
  +maven.aspectwerkz.src.dir = ${basedir}/src/aspectwerkz
  +maven.aspectwerkz.build.dir = ${maven.build.dir}/aspectwerkz/classes
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org