<project name="Calculadora" basedir=".." default="integrate">
  <property name="project.dir" value="${ant.project.name}"/>
  <property name="backup.dir" value="Backup${project.dir}"/>
  <property name="src.dir" value="${project.dir}/src"/>
  <property name="srcTeste.dir" value="${project.dir}/srcTeste"/>
  <property name="build.dir" value="${project.dir}/bin"/>
  <property name="lib.dir" value="${project.dir}/lib"/>
  <property name="allTests.class" value="jm.AllTests"/>
  <property name="cvsroot" value=
      ":pserver:vinicius@vini-mac:/usr/local/cvs/desenvolvimento"/>
	
  <path id="project.classpath">
    <pathelement location="${build.dir}"/>
    <fileset dir="${lib.dir}">
      <include name="*.jar"/>
    </fileset>
  </path>
  <taskdef name="junit" classname= "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
    <classpath refid="project.classpath"/>
  </taskdef>

  <target name="backup">
    <delete dir="${backup.dir}"/>
    <copy todir="${backup.dir}">
      <fileset dir="${project.dir}" defaultexcludes="false" />
    </copy>
  </target>
  <target name="update">
    <cvs cvsroot="${cvsroot}" command="update -d ${ant.project.name}" failonerror="true"/>
  </target>

  <target name="build">
    <mkdir dir="${build.dir}"/>
    <javac debug="on" srcdir="${src.dir}" destdir="${build.dir}" failonerror="true">
      <classpath refid="project.classpath"/>
    </javac>
    <javac debug="on" srcdir="${srcTeste.dir}" destdir="${build.dir}" failonerror="true">
      <classpath refid="project.classpath"/>
    </javac>
  </target>
 
 <target name="test" depends="build">
    <dirname file="build.xml" property="current.dir"/>
    <junit haltonfailure="true" haltonerror="true" fork="true" dir="${current.dir}">
      <classpath>
        <path refid="project.classpath"/>
      </classpath>
      <formatter type="plain" usefile="false"/>
      <test name="${allTests.class}"/>
    </junit>
  </target>

  <target name="commit">
    <cvs cvsroot="${cvsroot}" command="commit -m '' ${ant.project.name}" failonerror="true"/>
  </target>

  <target name="checkout">
    <delete dir="${project.dir}"/>
    <cvs cvsroot="${cvsroot}" command="checkout -P ${ant.project.name}" />
  </target>

  <target name="integrate" depends="test, backup, update, test, commit, checkout">
    <antcall target="test"/>
    <echo message="Integracao concluida com sucesso."/>
  </target>
</project>
