<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2000-2013 JetBrains s.r.o.
  ~
  ~ 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 name="clearcase-server" default="all" basedir=".">


    <property file="clearcase-server.properties"/>
    <!-- Uncomment the following property if no tests compilation is needed -->
    <!-- 
  <property name="skip.tests" value="true"/>
   -->

    <!-- Compiler options -->

    <property name="compiler.debug" value="on"/>
    <property name="compiler.generate.no.warnings" value="off"/>
    <property name="compiler.args" value=""/>
    <property name="compiler.max.memory" value="128m"/>
    <patternset id="ignored.files">
        <exclude name="**/CVS/**"/>
        <exclude name="**/SCCS/**"/>
        <exclude name="**/RCS/**"/>
        <exclude name="**/rcs/**"/>
        <exclude name="**/.DS_Store/**"/>
        <exclude name="**/.svn/**"/>
        <exclude name="**/.sbas/**"/>
        <exclude name="**/.IJI.*/**"/>
        <exclude name="**/vssver.scc/**"/>
        <exclude name="**/vssver2.scc/**"/>
        <exclude name="**/.pyc/**"/>
        <exclude name="**/.pyo/**"/>
        <exclude name="**/*.pyc/**"/>
        <exclude name="**/*.pyo/**"/>
        <exclude name="**/.git/**"/>
    </patternset>
    <patternset id="compiler.resources">
        <include name="**/?*.properties"/>
        <include name="**/?*.xml"/>
        <include name="**/?*.gif"/>
        <include name="**/?*.png"/>
        <include name="**/?*.jpeg"/>
        <include name="**/?*.jpg"/>
        <include name="**/?*.html"/>
        <include name="**/?*.dtd"/>
        <include name="**/?*.tld"/>
        <include name="**/?*.js"/>
        <include name="**/?*.css"/>
        <include name="**/?*.jsp"/>
        <include name="**/?*.exe"/>
        <include name="**/?*.pdb"/>
        <include name="**/?*.dll" />
        <include name="**/?*.ftl" />
        <include name="**/?*.xsd" />
    </patternset>

    <!-- Project Libraries -->
    <path id="library.dist.classpath">
        <fileset dir="${dist}">
            <include name="*.jar" />
        </fileset>
    </path>

    <path id="library.teamcity_openapi.classpath">
        <pathelement location="${path.variable.teamcitydistribution}/devPackage/serviceMessages.jar"/>
        <pathelement location="${path.variable.teamcitydistribution}/devPackage/common-api.jar"/>
        <pathelement location="${path.variable.teamcitydistribution}/devPackage/server-api.jar"/>
        <pathelement location="${path.variable.teamcitydistribution}/devPackage/agent-api.jar"/>
    </path>

    <path id="library.teamcity_utils.classpath">
        <fileset dir="${path.variable.teamcitydistribution}">
            <include name="webapps/ROOT/WEB-INF/lib/**/*.jar" />
            <include name="lib/**/*.jar" />
        </fileset>
    </path>

    <path id="library.log4j.classpath">
        <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/log4j-1.2-api-2.17.2.jar"/>
        <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/log4j-api-2.17.2.jar"/>
        <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/log4j-core-2.17.2.jar"/>
    </path>


    <!-- Global Libraries -->


    <!-- Application Server Libraries -->

    <!-- Modules -->


    <!-- Module clearcase-standalone -->
    <property name="compiler.args.clearcase-standalone" value="${compiler.args}"/>
    
    <path id="clearcase-standalone.module.bootclasspath">
        <!-- Paths to be included in compilation bootclasspath -->
    </path>

    <path id="clearcase-standalone.module.classpath">
        <path refid="library.teamcity_openapi.classpath"/>
        <path refid="library.teamcity_utils.classpath"/>
        <path refid="library.log4j.classpath"/>
        <path refid="library.dist.classpath"/>
    </path>

    <path id="clearcase-standalone.runtime.module.classpath">
        <pathelement location="${clearcase-standalone.output.dir}"/>
        <pathelement location="${clearcase-standalone.testoutput.dir}"/>
        <path refid="library.teamcity_openapi.classpath"/>
        <path refid="library.teamcity_utils.classpath"/>
        <path refid="library.log4j.classpath"/>
        <path refid="library.dist.classpath"/>
    </path>


    <patternset id="excluded.from.module.clearcase-standalone">
        <patternset refid="ignored.files"/>
    </patternset>

    <patternset id="excluded.from.compilation.clearcase-standalone">
        <patternset refid="excluded.from.module.clearcase-standalone"/>
    </patternset>

    <path id="clearcase-standalone.module.sourcepath">
        <dirset dir="${basedir}">
            <include name="resources"/>
            <include name="src"/>
        </dirset>
    </path>

    <target name="package">
        <jar destfile="${dist}\clearcase.jar">
            <fileset dir="${clearcase-standalone.output.dir}" />
        </jar>
    </target>

    <target name="compile.module.clearcase-standalone" depends="compile.module.clearcase-standalone.production,compile.module.clearcase-standalone.tests" description="Compile module clearcase-standalone"/>

    <target name="compile.module.clearcase-standalone.production" description="Compile module clearcase-standalone; production classes">
        <!--mkdir dir="${clearcase-standalone.output.dir}"/-->
        <javac destdir="${clearcase-standalone.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}">
            <compilerarg line="${compiler.args.clearcase-standalone}"/>
            <bootclasspath refid="clearcase-standalone.module.bootclasspath"/>
            <classpath refid="clearcase-standalone.module.classpath"/>
            <src refid="clearcase-standalone.module.sourcepath"/>
            <patternset refid="excluded.from.compilation.clearcase-standalone"/>
        </javac>

        <copy todir="${clearcase-standalone.output.dir}">
            <fileset dir="${basedir}/resources">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
            <fileset dir="${basedir}/src">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
        </copy>
    </target>

    <target name="compile.module.clearcase-standalone.tests" depends="compile.module.clearcase-standalone.production" description="compile module clearcase-standalone; test classes" unless="skip.tests"/>

    <target name="clean.module.clearcase-standalone" description="cleanup module">
        <delete dir="bin" quiet="true"/>
    </target>

    <target name="init" description="Build initialization">
        <!-- Perform any build initialization in this target -->
    </target>

    <target name="clean" depends="clean.module.clearcase-standalone" description="cleanup all"/>

    <target name="all" depends="init, clean, compile.module.clearcase-standalone, package" description="build all"/>
</project>