2004-09-15 20:15:43 +00:00

214 lines
6.5 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<document>
<properties>
<title>Maven AspectJ plugin</title>
<author email="dion@multitask.com.au">dIon Gillard</author>
<author email="vmassol@pivolis.com">Vincent Massol</author>
<author email="carlos@apache.org">Carlos Sanchez</author>
</properties>
<body>
<section name="Maven AspectJ Plug-in">
<p>
AspectJ plugin for Maven. It offers the ability to
weave aspects on the classes generated and dependency libraries.
This also includes the ability to add dependencies on libraries
with aspects.
</p>
<p>
For more information on the functionality provided by this plugin,
please see the <a href="goals.html">Goals</a> document.
</p>
<p>
For more information on how to customise the functionality provided
by this plugin, please see the <a href="properties.html">properties</a>
document.
</p>
</section>
<section name="Installing">
<p>
To install or update the plugin do the following:<br/>
<code>maven plugin:download -DgroupId=maven -DartifactId=maven-aspectj-plugin -Dversion=&lt;version&gt;</code>
</p>
</section>
<section name="Compiling aspect sources">
<p>You must add the property aspectSourceDirectory in your project.xml</p>
<source>
<![CDATA[
<aspectSourceDirectory>src/aspectj</aspectSourceDirectory>
]]>
</source>
</section>
<section name="Using aspects from other libraries">
<p>You must tell Maven what aspects you want to weave project classes with
in addition to the source aspects in your project. This is achieved by
specifying meta-information in the POM, using the
<code>aspectj.weaveWith</code> property
</p>
<source>
<![CDATA[
<dependency>
<groupId>groupid</groupId>
<artifactId>jarid</artifactId>
<version>jarversion</version>
<properties>
<aspectj.weaveWith>true</aspectj.weaveWith>
</properties>
</dependency>
]]>
</source>
</section>
<section name="Weaving classes from other libraries">
<p>You must tell Maven what libraries you want to weave with project aspects
or aspect libraries. This is achieved by
specifying meta-information in the POM, using the
<code>aspectj.weaveInto</code> property
</p>
<source>
<![CDATA[
<dependency>
<groupId>groupid</groupId>
<artifactId>jarid</artifactId>
<version>jarversion</version>
<properties>
<aspectj.weaveInto>true</aspectj.weaveInto>
</properties>
</dependency>
]]>
</source>
<p>The jar contents, with classes weaved, are extracted to maven.build.dest.</p>
</section>
<section name="Creating a deployable file">
<p>If you are creating a deployable file like a war you
need to add the aspectjrt library to your dependencies so it
gets included in the file. You shouldn't need to add it for
other operations.
</p>
<source>
<![CDATA[
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.2</version>
<url>http://www.eclipse.org/aspectj</url>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
]]>
</source>
</section>
<section name="Calling AspectJ goal automatically">
<p>If you want to call the aspectj goal every time you compile
add the following to your maven.xml file.
</p>
<source>
<![CDATA[
<preGoal name="java:compile">
<attainGoal name="aspectj"/>
</preGoal>
]]>
</source>
<p>If you don't want to weave test classes use the following code instead.
</p>
<source>
<![CDATA[
<preGoal name="java:compile">
<attainGoal name="aspectj:compile"/>
</preGoal>
]]>
</source>
</section>
<section name="Sample project">
<source>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<groupId>examples</groupId>
<id>example-with-aspects</id>
<currentVersion>1.0</currentVersion>
<dependencies>
<dependency>
<groupId>company-jars</groupId>
<artifactId>jar-one</artifactId>
<version>1.0</version>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>company-aspects</groupId>
<artifactId>example-aspects</artifactId>
<version>1.0</version>
<properties>
<aspectj.weaveWith>true</aspectj.weaveWith>
</properties>
</dependency>
<dependency>
<groupId>company-jars</groupId>
<artifactId>jar-two</artifactId>
<version>1.0</version>
<properties>
<aspectj.weaveInto>true</aspectj.weaveInto>
</properties>
</dependency>
<!-- if you are creating a deployable file like a war you
need to add the aspectjrt library -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.2</version>
<url>http://www.eclipse.org/aspectj</url>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/java</sourceDirectory>
<aspectSourceDirectory>src/aspectj</aspectSourceDirectory>
</build>
</project>
]]>
</source>
</section>
</body>
</document>