make와 같은 ANT라는 컴파일러가 있는것 같다..물론 좀더 봐야 뭔지 알겠지만...
트랙백으로 좀 확인해 봐야 겠다.
이 내용은 하기 내용에서 trackback 해왔다.
ANT가 Make보다 좋은 점은 각종 서적과 문서에 나와 있으므로 패스.

우선, CVS에서 프로젝트를 checkout

[root@fedora cvs]# cvs checkout hibernate-start01
cvs checkout: Updating hibernate-start01
cvs checkout: Updating hibernate-start01/WebContent
U hibernate-start01/WebContent/test.jsp
cvs checkout: Updating hibernate-start01/WebContent/WEB-INF
U hibernate-start01/WebContent/WEB-INF/web.xml
cvs checkout: Updating hibernate-start01/WebContent/WEB-INF/classes
U hibernate-start01/WebContent/WEB-INF/classes/hibernate.cfg.xml
cvs checkout: Updating hibernate-start01/WebContent/WEB-INF/lib
U hibernate-start01/WebContent/WEB-INF/lib/antlr-2.7.6.jar
U hibernate-start01/WebContent/WEB-INF/lib/asm-attrs.jar
U hibernate-start01/WebContent/WEB-INF/lib/asm.jar
U hibernate-start01/WebContent/WEB-INF/lib/c3p0-0.9.1.jar
U hibernate-start01/WebContent/WEB-INF/lib/cglib-2.1.3.jar
U hibernate-start01/WebContent/WEB-INF/lib/commons-collections-3.1.jar
U hibernate-start01/WebContent/WEB-INF/lib/commons-logging-1.0.4.jar
U hibernate-start01/WebContent/WEB-INF/lib/dom4j-1.6.1.jar
U hibernate-start01/WebContent/WEB-INF/lib/ehcache-1.2.3.jar
U hibernate-start01/WebContent/WEB-INF/lib/hibernate3.jar
U hibernate-start01/WebContent/WEB-INF/lib/javassist-3.4.GA.jar
U hibernate-start01/WebContent/WEB-INF/lib/jta-1.1.jar
U hibernate-start01/WebContent/WEB-INF/lib/log4j-1.2.11.jar
U hibernate-start01/WebContent/WEB-INF/lib/servlet-api.jar
U hibernate-start01/WebContent/WEB-INF/lib/slf4j-api-1.5.6.jar
U hibernate-start01/WebContent/WEB-INF/lib/slf4j-jdk14-1.5.6.jar
cvs checkout: Updating hibernate-start01/resources
U hibernate-start01/resources/jdbc.properties
cvs checkout: Updating hibernate-start01/src
cvs checkout: Updating hibernate-start01/src/com
cvs checkout: Updating hibernate-start01/src/com/greatshin
cvs checkout: Updating hibernate-start01/src/com/greatshin/hibernatestart
U hibernate-start01/src/com/greatshin/hibernatestart/Event.hbm.xml
U hibernate-start01/src/com/greatshin/hibernatestart/Event.java
U hibernate-start01/src/com/greatshin/hibernatestart/EventManager.java
U hibernate-start01/src/com/greatshin/hibernatestart/EventServlet.java
U hibernate-start01/src/com/greatshin/hibernatestart/HibernateUtil.java
U hibernate-start01/src/com/greatshin/hibernatestart/Person.hbm.xml
U hibernate-start01/src/com/greatshin/hibernatestart/Person.java
U hibernate-start01/src/com/greatshin/hibernatestart/User.hbm.xml
U hibernate-start01/src/com/greatshin/hibernatestart/User.java
U hibernate-start01/src/com/greatshin/hibernatestart/UserManager.java
U hibernate-start01/src/com/greatshin/hibernatestart/UserServlet.java
[root@fedora cvs]# ls -al


방금 checkout한 hibernate-start01 프로젝트를 빌드해보자.

ANT는 빌드정보를 XML파일로 관리한다.

아래와 같이 작성하자.

build.xml의 속성 엘리먼트는 매뉴얼을 참조하자.

<?xml version="1.0"?>
<project name="spring-template-web" basedir="." default="start">
 <property file="build.properties" /> 

 <property environment="env" />
 <property name="tomcat.home" value="${env.CATALINA_HOME}" />
 <property name="deploy.dir" value="${tomcat.home}/webapps/${webapp.name}" />

 <path id="classpath">
  <fileset dir="${lib.dir}" includes="*.jar" />
  <pathelement path="${build.dir}" />
 </path>

 <target name="compile" description="Compile main source tree java files">
  <mkdir dir="${build.dir}/classes" />

  <javac destdir="${build.dir}/classes" debug="true" optimize="false" deprecation="false" failonerror="true">
   <src path="${src.dir}/com" />
   <classpath refid="classpath" />
  </javac>

  <!-- Copy XML files to ${build.dir}/classes -->
  <copy todir="${build.dir}/classes">
   <fileset dir="${src.dir}" includes="**/*.xml" />
  </copy>

  <native2ascii src="${resources.dir}" dest="${build.dir}/classes" includes="**/*.properties" />
 </target>

 <patternset id="war.files">
  <include name="**/*.*" />
  <exclude name="**/cargo*.jar" />
  <exclude name="**/junit.jar" />
  <exclude name="**/jwebunit*.jar" />
  <exclude name="**/httpunit*.jar" />
  <exclude name="**/*mock*.jar" />
  <exclude name="**/servlet-api*.jar" />
  <exclude name="**/strutstestcase*.jar" />
  <exclude name="**/Tidy.jar" />
 </patternset>

 <target name="war" depends="compile" description="Packages app as WAR">
  <mkdir dir="${dist.dir}" />
  <lib dir="${common.lib.dir}">
   <exclude name="**/servlet-api.jar" />
   <exclude name="**/junit.jar" />
  </lib>
  <war destfile="${dist.dir}/${webapp.name}.war" webxml="${web.dir}/WEB-INF/web.xml" compress="true">
   <classes dir="${build.dir}/classes" />
   <fileset dir="${web.dir}">
    <patternset refid="war.files" />
    <exclude name="**/web.xml" />
   </fileset>
  </war>
 </target>

 <target name="deploy" depends="compile" description="Deploy application">
  <copy todir="${deploy.dir}" preservelastmodified="true">
   <fileset dir="${web.dir}">
    <patternset refid="war.files" />
   </fileset>
  </copy>
  <copy todir="${deploy.dir}/WEB-INF/classes" preservelastmodified="true">
   <fileset dir="${build.dir}/classes" />
  </copy>
  <copy todir="${deploy.dir}/WEB-INF/lib" preservelastmodified="true">
   <fileset dir="${lib.dir}">
    <exclude name="**/junit.jar" />
    <exclude name="**/servlet-api.jar" />
   </fileset>
  </copy>
 </target>

 <target name="deploywar" depends="war" description="Deploy application as a WAR file">
  <copy todir="${deploy.dir}" preservelastmodified="true" file="${dist.dir}/${webapp.name}.war" />
 </target>

 <target name="clean" description="Clean output directories">
  <delete dir="build" />
  <delete dir="${dist.dir}" />
 </target>

 <!-- Tomcat Ant Tasks -->
 <taskdef file="tomcatTasks.properties">
  <classpath>
   <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar" />
  </classpath>
 </taskdef>

 <target name="remove" description="Remove application from Tomcat">
  <undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${webapp.name}" />
 </target>

 <target name="reload" description="Reload application in Tomcat">
  <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${webapp.name}" />
 </target>

 <target name="start" depends="stop" description="Start Tomcat application">
  <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${webapp.name}" />
 </target>

 <target name="stop" depends="deploy" description="Stop Tomcat application">
  <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${webapp.name}" />
 </target>

 <target name="list" description="List Tomcat applications">
  <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />
 </target>

</project>

build.xml 파일 작성이 완료되었으면 아래와 같이 빌드한다.

위 설정파일에는 컴파일 후 배포까지 포함되어 있음을 참조하자.

[root@fedora hibernate-start01]# ant
Buildfile: build.xml
compile:
    [mkdir] Created dir: /home/cvs/hibernate-start01/build/classes
    [javac] Compiling 8 source files to /home/cvs/hibernate-start01/build/classes
     [copy] Copying 3 files to /home/cvs/hibernate-start01/build/classes
[native2ascii] Converting 1 file from /home/cvs/hibernate-start01/resources to /home/cvs/hibernate-start01/build/classes
deploy:
     [copy] Copying 12 files to /usr/local/tomcat/webapps/hibernate-start01/WEB-INF/classes
stop:
     [stop] OK - Stopped application at context path /hibernate-start01
start:
    [start] OK - Started application at context path /hibernate

+ Recent posts