<?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:ant="jelly:ant" 
  xmlns:define="jelly:define" 
  xmlns:j="jelly:core" 
  xmlns:license="license" 
  xmlns:log="jelly:log"
  xmlns:util="jelly:util">

  <!-- ================================================================ -->
  <!-- D E F A U L T  G O A L                                           -->
  <!-- ================================================================ -->
  <goal name="j2ee" prereqs="j2ee:validate-war"
    description="Check that a war file is valid" />

  <!-- ================================================================ -->
  <!-- V A L I D A T E  A  W A R                                        -->
  <!-- ================================================================ -->
  <goal name="j2ee:validate-war" prereqs="war:init"
    description="Check that a war file is valid">

    <ant:taskdef name="warvalidator" classname="org.apache.maven.j2ee.WarValidator">
      <ant:classpath>
        <ant:pathelement path="${plugin.resources}" />
        <ant:pathelement path="${plugin.dir}" />
        <ant:pathelement path="${plugin.getDependencyPath('ant')}"/>
        <ant:pathelement path="${plugin.getDependencyPath('dom4j')}"/>
        <ant:pathelement path="${plugin.getDependencyPath('xml-apis')}"/>
        <ant:pathelement path="${plugin.getDependencyPath('commons-logging')}"/>
      </ant:classpath>
    </ant:taskdef>
    
    <j:set var="warBuildDir"
      value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.build.dir')}"/>

    <ant:warvalidator warFileName="${warBuildDir}/${pom.artifactId}.war">
      <ant:formatter type="plain" usefile="false"/>
    </ant:warvalidator>
  </goal>

  <define:taglib uri="j2ee">
    <define:tag name="resolver">
      <j:new var="resolver" className="org.apache.maven.j2ee.J2EEEntityResolver" />
      <j:set var="${var}" value="${resolver}" scope="parent" />
    </define:tag>
  </define:taglib>

</project>
