maven-plugins/aspectj/plugin.jelly
2004-05-10 18:23:05 +00:00

149 lines
5.0 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.
*/
-->
<!--
=============================================================================
AspectJ plugin for Maven.
TODO:
- Need to add back the ajdoc goal
- Add other iajc attributes as plugin properties
=============================================================================
-->
<project
xmlns:j="jelly:core"
xmlns:ant="jelly:ant">
<!--
========================================================================
Default goal.
========================================================================
-->
<goal name="aspectj" description="Weave with AspectJ">
<attainGoal name="aspectj:compile"/>
</goal>
<!--
========================================================================
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>
<j:set var="shouldWeave" value="false"/>
<!-- Are there aspect sources -->
<ant:available property="aspectSourcesPresent" file="${pom.build.aspectSourceDirectory}"/>
<!-- If there aren't aspect sources check if there are aspect libraries -->
<j:if test="${aspectSourcesPresent == null}">
<j:forEach var="artifact" items="${pom.artifacts}">
<j:set var="dep" value="${artifact.dependency}"/>
<j:if test="${dep.getProperty('aspectj.weaveWith')=='true' and dep.type=='jar'}">
<j:set var="aspectLibrariesPresent" value="true"/>
<j:break/>
</j:if>
<j:if test="${dep.getProperty('aspectj.weaveInto')=='true' and dep.type=='jar'}">
<j:set var="aspectLibrariesPresent" value="true"/>
<j:break/>
</j:if>
</j:forEach>
</j:if>
<j:choose>
<j:when test="${(aspectSourcesPresent == 'true') || (aspectLibrariesPresent == 'true')}">
<j:set var="shouldWeave" value="true"/>
</j:when>
<j:otherwise>
<echo>No Aspects to weave</echo>
</j:otherwise>
</j:choose>
</goal>
<!--
========================================================================
Weave aspect classes
========================================================================
-->
<goal name="aspectj:compile" prereqs="aspectj:init"
description="Weave with AspectJ">
<j:if test="${shouldWeave == 'true'}">
<ant:iajc
fork="${maven.aspectj.fork}"
maxmem="${maven.aspectj.maxmem}"
incremental="${maven.aspectj.incremental}"
destDir="${maven.build.dest}"
sourceRootCopyFilter="${maven.aspectj.sourceRootCopyFilter}"
debug="${maven.aspectj.debug}"
emacssym="${maven.aspectj.emacssym}"
verbose="${maven.aspectj.verbose}">
<ant:sourceroots>
<ant:path refid="maven.compile.src.set"/>
<j:if test="${aspectSourcesPresent == 'true'}">
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
</j:if>
</ant:sourceroots>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
<ant:pathelement path="${maven.build.dest}"/>
</ant:classpath>
<!-- 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.getProperty('aspectj.weaveWith')=='true'}">
<ant:echo>Weaving with: ${dep.artifactId}</ant:echo>
<ant:pathelement location="${artifact.path}"/>
</j:if>
</j:forEach>
</ant:aspectpath>
<!-- Look for libraries for weaving into -->
<ant:inpath>
<j:forEach var="artifact" items="${pom.artifacts}">
<j:set var="dep" value="${artifact.dependency}"/>
<j:if test="${dep.getProperty('aspectj.weaveInto')=='true'}">
<ant:echo>Weaving into: ${dep.artifactId}</ant:echo>
<ant:pathelement location="${artifact.path}"/>
</j:if>
</j:forEach>
</ant:inpath>
</ant:iajc>
</j:if>
</goal>
</project>