<?xml version="1.0"?>

<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>

</project>
