<?xml version="1.0"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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 name="modules" default="test" basedir=".">
  <dirname file="${ant.file.modules}" property="modules.dir"/> 
  <import file="${modules.dir}/../lucene/tools/custom-tasks.xml" /> 

  <macrodef name="forall-modules">
    <attribute name="target" />
    <sequential>
      <subant target="@{target}" inheritall="false" failonerror="true">
         <propertyset refid="uptodate.and.compiled.properties"/>
        <fileset dir="${modules.dir}" includes="*/build.xml" />
      </subant>
    </sequential>
  </macrodef>

  <propertyset id="uptodate.and.compiled.properties" dynamic="true">
    <propertyref regex=".*\.uptodate$$"/>
    <propertyref regex=".*\.compiled$$"/>
  </propertyset>


  <target name="test" description="Test all modules">
    <forall-modules target="test" />
  </target>

  <target name="compile" description="Compile all modules" depends="validate">
    <forall-modules target="compile" />
  </target>

  <target name="resolve">
    <forall-modules target="resolve"/>
  </target>

  <target name="compile-test" description="Compile all tests">
    <forall-modules target="compile-test" />
  </target>

  <target name="javadocs" description="Generate javadocs">
    <forall-modules target="javadocs" />
  </target>

  <target name="generate-maven-artifacts" description="Generate Maven Artifacts for Modules">
    <ant target="get-maven-poms" dir=".."/>
    <forall-modules target="dist-maven" />
  </target>

  <target name="validate" depends="resolve" description="Validate legal stuff.">
    <!-- The order here is important because forall compiles tools. -->
    <forall-modules target="validate" />
    <license-check-macro dir="${basedir}" />
  </target>

  <target name="clean" description="Clean all modules">
    <delete dir="dist"/>
    <forall-modules target="clean" />
  </target>

  <!-- TODO: in the future, we don't need to actually put
       jars in the lib/ folders, but can just put in classpath.
       only packaging tasks really need that (and could do it
       under build/ directories) -->
  <target name="clean-jars" description="Clean local jars">
     <delete>
       <fileset dir="." includes="**/*.jar"/>
     </delete>
  </target>
</project>