Ant task

 

ANT 옵션

 

파일지정

ant -buildfile cc-build.xml

 

속성지정

ant -Dversion=1_0

 

설명

ant -proejcthelp

target의 description 속성의 내용을 볼 수 있음.

 

Ant주요 태스크

 

fileset 관련

<includesfiles name="includes.files/>

<excludesfiles name="excludes.files/>

<filelist id="libFiles" fiels="a.files b.files"/>

 

 

classpath 지정

<property="build.dir" location="build"/>

<property="build.prod.dir" location="${build.dir}/prod"/>

<property="build.test.dir" location="${build.dir}/test"/>

<property="lib.dir" location="${build.dir}/lib"/>

 

<path id="project.classpath">

<pathelement location="${build.prod.dir}"/>

<pathelement location="${build.test.dir}"/>

<fileset dir="${lib.dir}">

<include name="*.jar"/>

</fileset>

</path>

 

compile

<javac srcdir="${src.dir}" destdir="${build.prod.dir}">

<classpath refid="project.classpath"/>

</javac>

 

 

jsp compile

<jspc srcdir="${jsp}" destdir="${src}" pakcage="test.jsp">

<include name="**/*.jsp"/>

</jspc>

 

이후에 javac

 

junit test

<junit>

<test my="my.test.TestCase"/>

</junit>

 

 

Test결과를 XML로

<target name="test" depends="cimpoile-tests">

<delete dir="${test.xml.dir}"/>

<mkdir dir="${test.xml.dir}"/>

<junit errorProperty="test.failed" failureProperty="test.failed">

<classpath refid="project.classpath"/>

<formatter type="brief" usefile="false"/>

<formatter type="xml"/>

<batchtes todir="${test.xml.dir}">

<fileset dir="${build.test.dir}" includes="**/*Test.class"/>

</batchtests>

<sysproperty key="doc.dir" value="${doc.dir}"/>

<sysproperty key="index.dir" value="${index.dir}"/>

</junit>

<fail message="Tests failed!" if="test.failed"/>

</target>

 

 

jar파일생성

<jar destfile="{jar.path}" basedir="${build.prod.dir}" />

 

 

 

Zip파일 생성

 

<zip destfile="${zip.path}">

<zipfilest dir="bin" filemode="755" prefix="${release}/bin">

<include name="index.*"/>

</zipfileset>

</zip>

 

Tomcat deploy

 

<deploy url="$tomcat.manager.url"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"

path="/{webapp.name}"

war="file:${warfile.path}"

/>

 

java 클래스 실행

    <target name="manual">

        <java classname="mypackage.MyClassl" maxmemory="128m" fork="true" classpathref="classpath">

            <classpath path="${project.classes.dir}"/>

            <arg value="Sample"/>                    

            <arg value="Jsh"/>

<jvmarg value="-Dlog4j.configuration=file:${updater.src}/classes/log4j.xml"/> <jvmarg value="-XX:+UseParallelGC"/>

<jvmarg value="-Xms3072m"/> <jvmarg value="-Xmx3072m"/>

        </java>

    </target>      

 

 Sql 실행

 <target name="insert-data">
  <sql driver="${db.driver}"
    url="${db.url}"
    userid="${db.username}"
    password="${db.password}"
    src="${database.dir}/insert-data.sql">
    <classpath>
      <pathelement location="${mysql-connector.jar}"/>
    </classpath>
  </sql>
</target>