<?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="RAT Scan build" default="dist" xmlns:rat='antlib:org.apache.rat.scan'>

    <target name='xsl'>
        <property name='src.rat' location='src/main'/>    
        <xslt 
            style="${src.rat}/org/apache/rat/scan/summary-txt.xsl" 
            in='${src.rat}/org/apache/rat/scan/diff.html'
            out='summary.xml'></xslt>   
    </target>

    
    <target name='run'>
        <property name='src.rat' location='src/main'/>   
        <taskdef uri="antlib:org.apache.rat.scan"
                    resource="org/apache/rat/scan/antlib.xml" classpath="${src.rat}"/>     
        <rat:Audit src='${src.rat}'/>
    </target>   
    
    <macrodef name="SetupBuildDirs">
        <sequential>
            <property name='home.build' value='target'/>
            <property name='vendor.id' value='org.apache'/> 
            <property name='vendor.name' value='Apache Software Foundation'/>          
            <property name='version.minor' value='0.1'/>
            <property name='version.point' value=''/>         
            <property name='version' value='${version.minor}${version.point}'/>
            <property name='artifact.name' value='apache-rat-scan-incubating'/>
            <mkdir dir='${home.build}'/>
        </sequential>
    </macrodef>

    <target 
        name='_setup'
        description=' - prepares environment (internal) '>
        <property name='home.src' value='src/main'/>

        <SetupBuildDirs/>
    </target>

    <target 
            name='clean' 
            description=' - cleans up temporary build files'
            depends='_setup'>
        <delete dir='${home.build}'/>
        <SetupBuildDirs/>
    </target>

    <target 
        name='assemble'
        description=' - assembles a jar containing the scan scripts'
        depends='_setup'>
        <jar 
            basedir="${home.src}"   
            destfile="${home.build}/${artifact.name}-${version}.jar">
            <manifest>
                <attribute name="Extension-Name" value="rat-scan"/>
                <attribute name="Specification-Title" value="Release Audit Tool Scan"/>
                <attribute name="Specification-Vendor" value="${vendor.name}"/>
                <attribute name="Specification-Version" value="${version.minor}"/>
                <attribute name="Implementation-Vendor-Id" value="${vendor.id}"/>
                <attribute name="Implementation-Title" value="Release Audit Tool Scan"/>
                <attribute name="Implementation-Vendor" value="${vendor.name}"/>
                <attribute name="Implementation-Version" value="${version}"/>
            </manifest>
            <metainf dir='${basedir}'>
                <include name='LICENSE.txt'/>  
                <include name='DISCLAIMER.txt'/>   
                <include name='NOTICE.txt'/>   
            </metainf>  
            <exclude name="**/*.pyc"/>   
        </jar>
    </target>

    <target 
            name='dist' 
            description=' - creates a distribution'
            depends='clean, _setup'>
        <antcall target='assemble'/>
    </target>
</project>