<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************
 * 
 * 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="Check OpenOffice License Files" default="buildsources" 
         xmlns:rat="antlib:org.apache.rat.anttasks"
         xmlns="antlib:org.apache.tools.ant">
  <description>
    Check over Apache OpenOffice source files for license headers.
  </description>
  <property name="version" value="AOO 4.1.0"/>
  <property environment="env"/>
  <property name="src-dir" location="${env.SRC_ROOT}/.."/>

  <!-- Run the rat scan on a fileset whose ecludes are defined by main/rat-excludes.
       Note that ant adds a list of default excludes like **/*~ or **/.svn.
       For the complete list see here: http://ant.apache.org/manual/dirtasks.html#defaultexcludes
  -->
  <target name="buildsources"
          depends="taskdef"
          description="runs the tasks over OpenOffice tree.">
    <tstamp>
      <format property="scan.time" pattern="MM/dd/yyyy hh:mm aa"/>
    </tstamp>
    <echo level="info">
      Timestamp: ${scan.time}
    </echo>
    <rat:report format="xml" reportFile="${RAT_SCAN_OUTPUT}">
      <fileset dir="${src-dir}" id="included-files">
        <excludesfile name="${src-dir}/main/rat-excludes"/>
        <excludesfile name="${src-dir}/main/rat-excludes-solver"/>
        <exclude name=".buildbot-sourcedata"/>
      </fileset>
    </rat:report>
  </target>

  <!-- The negative file list of files that are excluded from scanning.
       It can be used to control the exclude list.
  -->
  <fileset dir="${src-dir}" id="excluded-files">
    <includesfile name="${src-dir}/main/rat-excludes"/>
    <include name=".buildbot-sourcedata"/>
  </fileset>
  <fileset dir="${src-dir}" id="excluded-solver">
    <includesfile name="${src-dir}/main/rat-excludes-solver"/>
  </fileset>
  <property name="excluded-files-property" refid="excluded-files"/>
  <property name="excluded-solver-property" refid="excluded-solver"/>
  <target name="show-excluded-files"
          depends="taskdef"
          description="create a list of the files excluded from the rat scan.">
    <echo file="${EXCLUDED_FILES_OUTPUT}" append="false">
Excluded files (without local or global solvers)
------------------------------------------------

    </echo>
    <echo file="${EXCLUDED_FILES_OUTPUT}" append="true">
${excluded-files-property}
    </echo>
    <echo file="${EXCLUDED_FILES_OUTPUT}" append="true">


Excluded files of local and global solvers
------------------------------------------

    </echo>
    <echo file="${EXCLUDED_SOLVER_OUTPUT}" append="true">
      ${excluded-solver-property}
    </echo>
  </target>

  <!-- Import the rat scan as ant command.
  -->
  <target name="taskdef">
    <typedef resource="org/apache/rat/anttasks/antlib.xml" 
             uri="antlib:org.apache.rat.anttasks">
      <classpath>
        <fileset dir="${RAT_JAR_HOME}">
          <include name="**/apache-rat*.jar"/>
          <include name="**/commons-*.jar"/>
        </fileset>
      </classpath>
    </typedef>
  </target>

</project>
