<?xml version="1.0" encoding="UTF-8"?>
<project name="agentinfo" default="all">
  
  
  <property file="agentinfo.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="700m"/>
  <patternset id="ignored.files">
    <exclude name="**/*.hprof/**"/>
    <exclude name="**/*.pyc/**"/>
    <exclude name="**/*.pyo/**"/>
    <exclude name="**/*.rbc/**"/>
    <exclude name="**/*~/**"/>
    <exclude name="**/.DS_Store/**"/>
    <exclude name="**/.git/**"/>
    <exclude name="**/.hg/**"/>
    <exclude name="**/.svn/**"/>
    <exclude name="**/CVS/**"/>
    <exclude name="**/RCS/**"/>
    <exclude name="**/SCCS/**"/>
    <exclude name="**/__pycache__/**"/>
    <exclude name="**/_svn/**"/>
    <exclude name="**/rcs/**"/>
  </patternset>
  <patternset id="library.patterns">
    <include name="*.egg"/>
    <include name="*.jar"/>
    <include name="*.ear"/>
    <include name="*.ane"/>
    <include name="*.klib"/>
    <include name="*.apk"/>
    <include name="*.swc"/>
    <include name="*.war"/>
    <include name="*.zip"/>
  </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="**/?*.ftl"/>
    <include name="**/?*.groovy"/>
  </patternset>
  
  <!-- JDK definitions -->
  
  <property name="jdk.bin.1.6" value="${jdk.home.1.6}/bin"/>
  <path id="jdk.classpath.1.6">
    <fileset dir="${jdk.home.1.6}">
      <include name="../Classes/charsets.jar"/>
      <include name="../Classes/classes.jar"/>
      <include name="../Classes/jsse.jar"/>
      <include name="../Classes/ui.jar"/>
      <include name="lib/deploy.jar"/>
      <include name="lib/dt.jar"/>
      <include name="lib/ext/apple_provider.jar"/>
      <include name="lib/ext/dnsns.jar"/>
      <include name="lib/ext/localedata.jar"/>
      <include name="lib/ext/sunjce_provider.jar"/>
      <include name="lib/ext/sunpkcs11.jar"/>
      <include name="lib/javaws.jar"/>
      <include name="lib/jce.jar"/>
      <include name="lib/jconsole.jar"/>
      <include name="lib/management-agent.jar"/>
      <include name="lib/plugin.jar"/>
      <include name="lib/sa-jdi.jar"/>
    </fileset>
  </path>
  
  <property name="jdk.bin.1.8" value="${jdk.home.1.8}/bin"/>
  <path id="jdk.classpath.1.8">
    <fileset dir="${jdk.home.1.8}">
      <include name="jre/lib/charsets.jar"/>
      <include name="jre/lib/deploy.jar"/>
      <include name="jre/lib/ext/cldrdata.jar"/>
      <include name="jre/lib/ext/dnsns.jar"/>
      <include name="jre/lib/ext/jaccess.jar"/>
      <include name="jre/lib/ext/jfxrt.jar"/>
      <include name="jre/lib/ext/localedata.jar"/>
      <include name="jre/lib/ext/nashorn.jar"/>
      <include name="jre/lib/ext/sunec.jar"/>
      <include name="jre/lib/ext/sunjce_provider.jar"/>
      <include name="jre/lib/ext/sunpkcs11.jar"/>
      <include name="jre/lib/ext/zipfs.jar"/>
      <include name="jre/lib/javaws.jar"/>
      <include name="jre/lib/jce.jar"/>
      <include name="jre/lib/jfr.jar"/>
      <include name="jre/lib/jfxswt.jar"/>
      <include name="jre/lib/jsse.jar"/>
      <include name="jre/lib/management-agent.jar"/>
      <include name="jre/lib/plugin.jar"/>
      <include name="jre/lib/resources.jar"/>
      <include name="jre/lib/rt.jar"/>
      <include name="lib/ant-javafx.jar"/>
      <include name="lib/dt.jar"/>
      <include name="lib/javafx-mx.jar"/>
      <include name="lib/jconsole.jar"/>
      <include name="lib/packager.jar"/>
      <include name="lib/sa-jdi.jar"/>
      <include name="lib/tools.jar"/>
    </fileset>
  </path>
  
  <property name="project.jdk.home" value="${jdk.home.1.8}"/>
  <property name="project.jdk.bin" value="${jdk.bin.1.8}"/>
  <property name="project.jdk.classpath" value="jdk.classpath.1.8"/>
  
  
  <!-- Project Libraries -->
  
  <path id="library.teamcity_open_api_agent.classpath">
    <pathelement location="${path.variable.teamcitydistribution}/devPackage/agent-api.jar"/>
  </path>
  
  <path id="library.teamcity_open_api_common.classpath">
    <pathelement location="${path.variable.teamcitydistribution}/devPackage/common-api.jar"/>
  </path>
  
  <path id="library.teamcity_third-party.classpath">
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/annotations.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/idea-obsolete-openapi.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/idea-openapi.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/logging.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/openapi.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-beans.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-context.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-context-support.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-core.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-web.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring-webmvc.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/spring.jar"/>
    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/util.jar"/>
  </path>
  
  
  <!-- Application Server Libraries -->
  
  <!-- Modules -->
  
  
  <!-- Module agent-info -->
  
  <dirname property="module.agent-info.basedir" file="${ant.file}"/>
  
  
  <property name="module.jdk.home.agent-info" value="${jdk.home.1.6}"/>
  <property name="module.jdk.bin.agent-info" value="${jdk.bin.1.6}"/>
  <property name="module.jdk.classpath.agent-info" value="jdk.classpath.1.6"/>
  
  <property name="compiler.args.agent-info" value="-encoding UTF-8 -source 6 -target 6 ${compiler.args}"/>
  
  <property name="agent-info.output.dir" value="${module.agent-info.basedir}/out/production/AgentInfo"/>
  <property name="agent-info.testoutput.dir" value="${module.agent-info.basedir}/out/test/AgentInfo"/>
  
  <path id="agent-info.module.bootclasspath">
    <!-- Paths to be included in compilation bootclasspath -->
  </path>
  
  <path id="agent-info.module.production.classpath">
    <path refid="${module.jdk.classpath.agent-info}"/>
    <path refid="library.teamcity_open_api_agent.classpath"/>
    <path refid="library.teamcity_open_api_common.classpath"/>
    <path refid="library.teamcity_third-party.classpath"/>
  </path>
  
  <path id="agent-info.runtime.production.module.classpath">
    <pathelement location="${agentinfo.output.dir}"/>
    <path refid="library.teamcity_open_api_agent.classpath"/>
    <path refid="library.teamcity_open_api_common.classpath"/>
    <path refid="library.teamcity_third-party.classpath"/>
  </path>
  
  <path id="agent-info.module.classpath">
    <path refid="${module.jdk.classpath.agent-info}"/>
    <pathelement location="${agentinfo.output.dir}"/>
    <path refid="library.teamcity_open_api_agent.classpath"/>
    <path refid="library.teamcity_open_api_common.classpath"/>
    <path refid="library.teamcity_third-party.classpath"/>
  </path>
  
  <path id="agent-info.runtime.module.classpath">
    <pathelement location="${agentinfo.testoutput.dir}"/>
    <pathelement location="${agentinfo.output.dir}"/>
    <path refid="library.teamcity_open_api_agent.classpath"/>
    <path refid="library.teamcity_open_api_common.classpath"/>
    <path refid="library.teamcity_third-party.classpath"/>
  </path>
  
  
  <patternset id="excluded.from.module.agent-info">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.agent-info">
    <patternset refid="excluded.from.module.agent-info"/>
  </patternset>
  
  <path id="agent-info.module.sourcepath">
    <dirset dir="${module.agent-info.basedir}">
      <include name="src"/>
    </dirset>
  </path>
  
  
  <target name="compile.module.agent-info" depends="compile.module.agent-info.production,compile.module.agent-info.tests" description="Compile module agent-info"/>
  
  <target name="compile.module.agent-info.production" description="Compile module agent-info; production classes">
    <mkdir dir="${agent-info.output.dir}"/>
    <javac destdir="${agent-info.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.agent-info}/javac">
      <compilerarg line="${compiler.args.agent-info}"/>
      <bootclasspath refid="agent-info.module.bootclasspath"/>
      <classpath refid="agent-info.module.production.classpath"/>
      <src refid="agent-info.module.sourcepath"/>
      <patternset refid="excluded.from.compilation.agent-info"/>
    </javac>
    
    <copy todir="${agent-info.output.dir}">
      <fileset dir="${module.agent-info.basedir}/src">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
    </copy>
  </target>
  
  <target name="compile.module.agent-info.tests" depends="compile.module.agent-info.production" description="compile module agent-info; test classes" unless="skip.tests"/>
  
  <target name="clean.module.agent-info" description="cleanup module">
    <delete dir="${agent-info.output.dir}"/>
    <delete dir="${agent-info.testoutput.dir}"/>
  </target>
  
  
  <!-- Module AgentInfo -->
  
  <dirname property="module.agentinfo.basedir" file="${ant.file}"/>
  
  
  <property name="module.jdk.home.agentinfo" value="${project.jdk.home}"/>
  <property name="module.jdk.bin.agentinfo" value="${project.jdk.bin}"/>
  <property name="module.jdk.classpath.agentinfo" value="${project.jdk.classpath}"/>
  
  <property name="compiler.args.agentinfo" value="-encoding UTF-8 -source 8 -target 8 ${compiler.args}"/>
  
  <property name="agentinfo.output.dir" value="${module.agentinfo.basedir}/out/production/AgentInfo"/>
  <property name="agentinfo.testoutput.dir" value="${module.agentinfo.basedir}/out/test/AgentInfo"/>
  
  <path id="agentinfo.module.bootclasspath">
    <!-- Paths to be included in compilation bootclasspath -->
  </path>
  
  <path id="agentinfo.module.production.classpath">
    <path refid="${module.jdk.classpath.agentinfo}"/>
  </path>
  
  <path id="agentinfo.runtime.production.module.classpath">
    <pathelement location="${agentinfo.output.dir}"/>
  </path>
  
  <path id="agentinfo.module.classpath">
    <path refid="${module.jdk.classpath.agentinfo}"/>
    <pathelement location="${agentinfo.output.dir}"/>
  </path>
  
  <path id="agentinfo.runtime.module.classpath">
    <pathelement location="${agentinfo.testoutput.dir}"/>
    <pathelement location="${agentinfo.output.dir}"/>
  </path>
  
  
  <patternset id="excluded.from.module.agentinfo">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.agentinfo">
    <patternset refid="excluded.from.module.agentinfo"/>
  </patternset>
  
  
  <target name="compile.module.agentinfo" depends="compile.module.agentinfo.production,compile.module.agentinfo.tests" description="Compile module AgentInfo"/>
  
  <target name="compile.module.agentinfo.production" description="Compile module AgentInfo; production classes"/>
  
  <target name="compile.module.agentinfo.tests" depends="compile.module.agentinfo.production" description="compile module AgentInfo; test classes" unless="skip.tests"/>
  
  <target name="clean.module.agentinfo" description="cleanup module">
    <delete dir="${agentinfo.output.dir}"/>
    <delete dir="${agentinfo.testoutput.dir}"/>
  </target>
  
  
  <!-- Module tests -->
  
  <dirname property="module.tests.basedir" file="${ant.file}"/>
  
  
  <property name="module.jdk.home.tests" value="${project.jdk.home}"/>
  <property name="module.jdk.bin.tests" value="${project.jdk.bin}"/>
  <property name="module.jdk.classpath.tests" value="${project.jdk.classpath}"/>
  
  <property name="compiler.args.tests" value="-encoding UTF-8 -source 8 -target 8 ${compiler.args}"/>
  
  <property name="tests.output.dir" value="${module.tests.basedir}/out/production/tests"/>
  <property name="tests.testoutput.dir" value="${module.tests.basedir}/out/test/tests"/>
  
  <path id="tests.module.bootclasspath">
    <!-- Paths to be included in compilation bootclasspath -->
  </path>
  
  <path id="tests.module.production.classpath">
    <path refid="${module.jdk.classpath.tests}"/>
    <pathelement location="${agentinfo.output.dir}"/>
    <pathelement location="${basedir}/lib-test/testng-6.8.jar"/>
  </path>
  
  <path id="tests.runtime.production.module.classpath">
    <pathelement location="${tests.output.dir}"/>
    <path refid="agent-info.runtime.production.module.classpath"/>
    <pathelement location="${basedir}/lib-test/testng-6.8.jar"/>
  </path>
  
  <path id="tests.module.classpath">
    <path refid="${module.jdk.classpath.tests}"/>
    <pathelement location="${tests.output.dir}"/>
    <pathelement location="${agentinfo.testoutput.dir}"/>
    <pathelement location="${agentinfo.output.dir}"/>
    <fileset dir="${path.variable.teamcitydistribution}/devPackage/tests">
      <patternset refid="library.patterns"/>
    </fileset>
    <fileset dir="${path.variable.teamcitydistribution}/buildAgent/lib">
      <patternset refid="library.patterns"/>
    </fileset>
    <pathelement location="${basedir}/lib-test/testng-6.8.jar"/>
  </path>
  
  <path id="tests.runtime.module.classpath">
    <pathelement location="${tests.testoutput.dir}"/>
    <pathelement location="${tests.output.dir}"/>
    <path refid="agent-info.runtime.module.classpath"/>
    <fileset dir="${path.variable.teamcitydistribution}/devPackage/tests">
      <patternset refid="library.patterns"/>
    </fileset>
    <fileset dir="${path.variable.teamcitydistribution}/buildAgent/lib">
      <patternset refid="library.patterns"/>
    </fileset>
    <pathelement location="${basedir}/lib-test/testng-6.8.jar"/>
  </path>
  
  
  <patternset id="excluded.from.module.tests">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.tests">
    <patternset refid="excluded.from.module.tests"/>
  </patternset>
  
  <path id="tests.module.test.sourcepath">
    <dirset dir="${module.tests.basedir}">
      <include name="tests"/>
    </dirset>
  </path>
  
  
  <target name="compile.module.tests" depends="compile.module.tests.production,compile.module.tests.tests" description="Compile module tests"/>
  
  <target name="compile.module.tests.production" depends="compile.module.agent-info" description="Compile module tests; production classes"/>
  
  <target name="compile.module.tests.tests" depends="compile.module.tests.production" description="compile module tests; test classes" unless="skip.tests">
    <mkdir dir="${tests.testoutput.dir}"/>
    <javac destdir="${tests.testoutput.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.tests}/javac">
      <compilerarg line="${compiler.args.tests}"/>
      <bootclasspath refid="tests.module.bootclasspath"/>
      <classpath refid="tests.module.classpath"/>
      <src refid="tests.module.test.sourcepath"/>
      <patternset refid="excluded.from.compilation.tests"/>
    </javac>
    
    <copy todir="${tests.testoutput.dir}">
      <fileset dir="${module.tests.basedir}/tests">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
    </copy>
  </target>
  
  <target name="clean.module.tests" description="cleanup module">
    <delete dir="${tests.output.dir}"/>
    <delete dir="${tests.testoutput.dir}"/>
  </target>
  
  <target name="init" description="Build initialization">
    <!-- Perform any build initialization in this target -->
  </target>
  
  <target name="clean" depends="clean.module.agent-info, clean.module.agentinfo, clean.module.tests" description="cleanup all"/>
  
  <target name="build.modules" depends="init, clean, compile.module.agent-info, compile.module.agentinfo, compile.module.tests" description="build all modules"/>
  
  <target name="all" depends="build.modules" description="build all"/>
</project>