[ 
http://jira.codehaus.org/browse/MASPECTJ-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=188934#action_188934
 ] 

Torsten Juergeleit commented on MASPECTJ-9:
-------------------------------------------

To celebrate the first anniversary of this feature request I'm adding a 
description of our current use-case for this feature :-P

We're using woven classes in our unit tests. To not create an additional Maven 
project for running the unit tests with the woven classes packaged in a jar we 
need this feature. This provides us with the possibility to weave class files 
created by the compiler plugin without packaging them into a jar first.

To keep ajc from [struggling with already woven 
classes|http://www.nabble.com/badWeaverState-exception-on-iajc-w-out-prior-clean-to2999998.html]
 we have to force the maven compiler plugin  to create our (unweaved) classes 
in a separate directory via the [command line option 
"-d"|http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html] :

{code:xml}
  <build>
      <plugins>
          <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <executions>
                  <execution>
                      <!-- Modifying output directory of default compile 
because non-weaved classes must be stored
                           in separate folder to not confuse ajc by reweaving 
already woven classes (which leads to
                           to ajc error message like "bad weaverState.Kind: 
-115") -->
                      <id>default-compile</id>
                      <configuration>
                          <compilerArguments>
                              <d>${project.build.directory}/unwoven-classes</d>
                          </compilerArguments>
                      </configuration>
                  </execution>
              </executions>
            </plugin>
       </plugins>
   <build>
{code}

To keep javac from bailing-out due to a non-existent directory 
"target/unwoven-classes/" we have to create this first. The following is a hack 
of (mis-) using the {{copy-resources}} goal of the Maven resource plugin for 
this:
{code:xml}
<build>
   <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              
<outputDirectory>${project.build.directory}/unwoven-classes</outputDirectory>
              <resources>
                <resource>
                    <directory>${basedir}</directory>
                    <includes>
                        <include>non-existent</include>
                    </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
   </plugins>
<build>
{code}

By separating the unwoven classes from the woven ones we can add an additional 
check to trigger ajc only if javac created new unwoven classes.

To weave the unwoven classes created by javac we're using the plugin option 
{{<weaveDirectories>}} introduced with the feature request:
{code:xml}
    <build>
      <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <configuration>
                    <weaveDirectories>
                        
<weaveDirectory>${project.build.directory}/unwoven-classes</weaveDirectory>
                    </weaveDirectories>
                </configuration>
                <executions>
                    <execution>
                        <!-- Compile and weave aspects after all classes 
compiled by javac -->
                        <phase>process-classes</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
               </executions>
           </plugin>
       </plugins>
   <build>
{code}


> Add support for weaving classes in folders instead of jars
> ----------------------------------------------------------
>
>                 Key: MASPECTJ-9
>                 URL: http://jira.codehaus.org/browse/MASPECTJ-9
>             Project: Mojo AspectJ Plugin
>          Issue Type: New Feature
>    Affects Versions: 1.0
>            Reporter: Torsten Juergeleit
>         Attachments: weavedirectories.patch, weavedirectories.patch
>
>   Original Estimate: 0 minutes
>  Remaining Estimate: 0 minutes
>
> Currently the plugin only supports adding jars to the ajc commandline 
> parameter "-inpath". But "-inpath" supports folders with classes as well.
> The attached patch adds the new plugin option "weaveDirectories" to specify a 
> list of folders with .class files to be added to the value for the "-inpath" 
> parameter. A unit test and documentation is included as well.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to