Submitted by: Alexey Dashkevich New property maven.aspectj.dest to define output folder for aspectj:compile goal. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@390295 13f79535-47bb-0310-9956-ffa450edef68
326 lines
12 KiB
XML
326 lines
12 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!--
|
|
/*
|
|
* Copyright 2001-2006 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.
|
|
=============================================================================
|
|
-->
|
|
|
|
<project
|
|
xmlns:j="jelly:core"
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:define="jelly:define"
|
|
xmlns:log="jelly:log"
|
|
xmlns:maven="jelly:maven"
|
|
xmlns:util="jelly:util"
|
|
xmlns:doc="doc"
|
|
xmlns:aspectj="aspectj">
|
|
|
|
<!--
|
|
Taglib to compile aspects
|
|
|
|
Parameters:
|
|
- sourcePathRefid
|
|
- classpathRefid
|
|
- destDir
|
|
-->
|
|
<define:taglib uri="aspectj">
|
|
|
|
<define:tag name="compile">
|
|
|
|
<ant:iajc
|
|
fork="${maven.aspectj.fork}"
|
|
incremental="${maven.aspectj.incremental}"
|
|
XnoWeave="${maven.aspectj.noweave}"
|
|
Xlint="${maven.aspectj.lint}"
|
|
failonerror="${maven.aspectj.failonerror}"
|
|
destDir="${destDir}"
|
|
sourceRootCopyFilter="${maven.aspectj.sourceRootCopyFilter}"
|
|
debug="${maven.aspectj.debug}"
|
|
emacssym="${maven.aspectj.emacssym}"
|
|
verbose="${maven.aspectj.verbose}"
|
|
source="${maven.aspectj.source}"
|
|
time="${maven.aspectj.time}">
|
|
|
|
<j:if test="${context.getVariable('maven.aspectj.messageHolder') != null}">
|
|
<ant:setProperty name="messageHolderClass" value="${maven.aspectj.messageHolder}"/>
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.aspectj.fork') == true}">
|
|
<j:if test="${context.getVariable('maven.aspectj.maxmem') != null}">
|
|
<ant:setProperty name="maxmem" value="${maven.aspectj.maxmem}" />
|
|
</j:if>
|
|
</j:if>
|
|
|
|
<j:set var="weaveAspectSources" value="true"/>
|
|
<j:if test="${context.getVariable('maven.aspectj.argfiles') != null}">
|
|
<ant:argfiles>
|
|
<util:tokenize var="tokens" delim="," trim="true">${context.getVariable('maven.aspectj.argfiles')}</util:tokenize>
|
|
<j:forEach var="token" items="${tokens}">
|
|
<log:info>Using argument file ${token.trim()}</log:info>
|
|
<j:if test="${token != ''}">
|
|
<pathelement location="${token.trim()}" />
|
|
</j:if>
|
|
</j:forEach>
|
|
</ant:argfiles>
|
|
<j:set var="weaveAspectSources" value="false"/>
|
|
</j:if>
|
|
<j:if test="${context.getVariable('maven.aspectj.weaveAspectSources') != null}">
|
|
<j:set var="weaveAspectSources" value="${context.getVariable('maven.aspectj.weaveAspectSources')}"/>
|
|
</j:if>
|
|
|
|
<ant:sourceroots>
|
|
<j:if test="${context.getVariable('maven.aspectj.src.argfilesOnly') != 'true'}">
|
|
<ant:path refid="${sourcePathRefid}"/>
|
|
</j:if>
|
|
<j:if test="${aspectSourcesPresent and weaveAspectSources}">
|
|
<ant:pathelement location="${pom.build.aspectSourceDirectory}"/>
|
|
</j:if>
|
|
</ant:sourceroots>
|
|
|
|
<ant:classpath>
|
|
<ant:path refid="${classpathRefid}"/>
|
|
<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'}">
|
|
<log:info>Weaving with: ${dep.artifactId}</log:info>
|
|
<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'}">
|
|
<log:info>Weaving into: ${dep.artifactId}</log:info>
|
|
<ant:pathelement location="${artifact.path}"/>
|
|
</j:if>
|
|
</j:forEach>
|
|
</ant:inpath>
|
|
|
|
</ant:iajc>
|
|
|
|
|
|
</define:tag>
|
|
|
|
</define:taglib>
|
|
|
|
<!--
|
|
========================================================================
|
|
Default goal.
|
|
========================================================================
|
|
-->
|
|
<goal name="aspectj" description="Weave with AspectJ"
|
|
prereqs="aspectj:test-compile"/>
|
|
|
|
<!--
|
|
========================================================================
|
|
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:path refid="maven.dependency.classpath"/>
|
|
</ant:classpath>
|
|
</ant:taskdef>
|
|
|
|
<j:set var="shouldWeave" value="false"/>
|
|
|
|
<!-- Check if there are aspect sources -->
|
|
<j:choose>
|
|
<!-- if aspectSourceDirectory is defined in pom -->
|
|
<j:when test="${pom.build.aspectSourceDirectory != ''}">
|
|
<ant:available property="aspectSourcesPresent" file="${pom.build.aspectSourceDirectory}" type="dir"/>
|
|
<j:choose>
|
|
<!-- if dir exists -->
|
|
<j:when test="${aspectSourcesPresent == 'true'}">
|
|
<log:debug>Aspect sources present in directory: ${pom.build.aspectSourceDirectory}</log:debug>
|
|
<j:set var="aspectSourcesPresent" value="true"/>
|
|
</j:when>
|
|
<!-- if dir does not exist -->
|
|
<j:otherwise>
|
|
<log:error>Aspect source directory does not exist: ${pom.build.aspectSourceDirectory}</log:error>
|
|
<j:set var="aspectSourcesPresent" value="false"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</j:when>
|
|
<!-- if aspectSourceDirectory is not defined in pom -->
|
|
<j:otherwise>
|
|
<log:info>Aspect source directory not defined</log:info>
|
|
<j:set var="aspectSourcesPresent" value="false"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<!-- If there aren't aspect sources check if there are aspect libraries -->
|
|
<j:if test="${aspectSourcesPresent == 'false'}">
|
|
<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>
|
|
<log:info>No Aspects to weave</log:info>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Weave classes
|
|
========================================================================
|
|
-->
|
|
<goal name="aspectj:compile" prereqs="aspectj:init"
|
|
description="Weave classes with AspectJ">
|
|
|
|
<j:if test="${shouldWeave == 'true'}">
|
|
|
|
<!-- For the report -->
|
|
<ant:mkdir dir="${maven.build.dir}/aspectj" />
|
|
<ant:record name="${maven.build.dir}/aspectj/compile.txt" action="start" />
|
|
|
|
<!-- Weave classes -->
|
|
<aspectj:compile
|
|
sourcePathRefid="maven.compile.src.set"
|
|
classpathRefid="maven.dependency.classpath"
|
|
destDir="${maven.build.dest}"/>
|
|
|
|
<!-- For the report -->
|
|
<ant:record name="${maven.build.dir}/aspectj/compile.txt" action="stop" />
|
|
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Weave test classes
|
|
========================================================================
|
|
-->
|
|
<goal name="aspectj:test-compile" prereqs="aspectj:compile"
|
|
description="Weave tests with AspectJ">
|
|
|
|
<j:if test="${(shouldWeave == 'true') and (pom.build.unitTestSourceDirectory != '')}">
|
|
|
|
<j:choose>
|
|
<j:when test="${context.getVariable('maven.aspectj.dest') == null}">
|
|
<j:set var="maven.aspectj.dest" value="${maven.build.dest}"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<attainGoal name="java:compile"/>
|
|
<ant:path id="build.dest" location="${maven.build.dest}"/>
|
|
<maven:addPath id="maven.dependency.classpath" refid="build.dest"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
|
|
<maven:get var="maven.test.compile.src.set"
|
|
plugin="maven-test-plugin"
|
|
property="maven.test.compile.src.set"/>
|
|
|
|
<!-- Weave test classes -->
|
|
<ant:path id="testClasspath">
|
|
<ant:path refid="maven.dependency.classpath"/>
|
|
<ant:pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
</ant:path>
|
|
|
|
<aspectj:compile
|
|
sourcePathRefid="maven.test.compile.src.set"
|
|
classpathRefid="testClasspath"
|
|
destDir="${maven.aspectj.dest}"/>
|
|
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<goal name="maven-aspectj-plugin:register" prereqs="aspectj:init">
|
|
<j:if test="${shouldWeave == 'true'}">
|
|
|
|
<doc:registerReport
|
|
name="AspectJ Compile Report"
|
|
pluginName="maven-aspectj-plugin"
|
|
link="aspectj-compile"
|
|
description="Report on the compilation of AspectJ."/>
|
|
|
|
</j:if>
|
|
</goal>
|
|
|
|
<goal name="maven-aspectj-plugin:deregister" prereqs="aspectj:init">
|
|
<j:if test="${shouldWeave == 'true'}">
|
|
<doc:deregisterReport name="AspectJ Compile Report"/>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<goal name="maven-aspectj-plugin:report"
|
|
description="Generate AspectJ compilation result" prereqs="xdoc:init,aspectj:compile">
|
|
<j:if test="${shouldWeave == 'true'}">
|
|
<!-- load file in order to remove absolute paths -->
|
|
<util:file name="${maven.build.dir}/aspectj/compile.txt" var="inputFileObject"/>
|
|
<util:loadText var="inputText" file="${inputFileObject}"/>
|
|
|
|
<!-- remove [iajc] prefix from rows -->
|
|
<j:invokeStatic var="inputText" className="org.apache.commons.lang.StringUtils" method="replace">
|
|
<j:arg type="java.lang.String" value="${inputText}" />
|
|
<j:arg type="java.lang.String" value=" [iajc] " />
|
|
<j:arg type="java.lang.String" value="" />
|
|
</j:invokeStatic>
|
|
|
|
<!-- trim path to basedir/ -->
|
|
<j:set var="pathToTrim">${basedir}${file.separator}</j:set>
|
|
<j:invokeStatic var="inputText" className="org.apache.commons.lang.StringUtils" method="replace">
|
|
<j:arg type="java.lang.String" value="${inputText}" />
|
|
<j:arg type="java.lang.String" value="${pathToTrim}" />
|
|
<j:arg type="java.lang.String" value="" />
|
|
</j:invokeStatic>
|
|
|
|
<doc:text-xdoc
|
|
title="AspectJ Report"
|
|
section="AspectJ Compile Report"
|
|
inputText="${inputText}"
|
|
output="${maven.gen.docs}/aspectj-compile.xml"/>
|
|
</j:if>
|
|
</goal>
|
|
|
|
</project>
|