<?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.
 */
 -->


<project
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant" 
  xmlns:define="jelly:define">

  <define:taglib uri="caller">

    <!-- Example of usage:
         <caller:call goalInterface="compile-java"/>
    -->       
    <define:tag name="call">                  

      <j:set var="callProperty" value="maven.caller.call.${goalInterface}"/>

      <!-- Search first in the caller's context -->
      <j:set var="goalName" 
        value="${context.findVariable(callProperty)}"/>

      <j:if test="${goalName == null}">

        <!-- Search in this plugin context -->
        <j:set var="goalName" 
          value="${pom.getPluginContext('maven-caller-plugin').findVariable(callProperty)}"/>

      </j:if>

      <j:if test="${goalName == null}">
        <ant:fail message="Property [maven.caller.call.${goalInterface}] is not defined"/>
      </j:if>

      <attainGoal name="${goalName}"/>

    </define:tag>

    <!-- Example of usage:
         <caller:set goalInterface="compile-java" goal="aspectj:compile"/>
    -->       
    <define:tag name="set">
      <j:set var="setProperty" value="maven.caller.call.${goalInterface}"/>
      <j:set var="${setProperty}" value="${goal}"/>
    </define:tag>

  </define:taglib>

</project>
