沉睡森林@漂在北京

          本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處。

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評(píng)論 :: 0 Trackbacks

          晚上eclipse不知道怎么的,總是不停的編譯,一打開(kāi)tomcat就死掉。郁悶的很,自己寫(xiě)了一個(gè)ant命令來(lái)編譯和部署web了。代碼如下:

          配置信息build.properties

          # Source Directory

          src.dir=${basedir}/src

          # Resource Directory

          resources.dir=${basedir}/resources

          # War name

          war.name=${ant.project.name}

          # web context directory

          war.dir=${basedir}/WebContent

          # Library directory within project. Where third party jars reside.

          lib.dir = ${war.dir}/WEB-INF/lib

          # All artifacts produced by the build go somewhere underneath the target dir

          build.dir=${war.dir}/WEB-INF/classes

          # Directory we generate distribution units such as jars and zips to

          target.dir = ${basedir}/target

           

          # Test Directory

          test.dir=${basedir}/test

          test.target.dir=${basedir}/target/test/classes

          test.report.dir=${basedir}/target/test/report

          test.data=${basedir}/target/test/data

           

          funtest.dir=${basedir}/funtest

          funtest.target.dir=${basedir}/target/funtest/classes

          funtest.report.dir=${basedir}/target/funtest/report

          funtest.data=${basedir}/target/funtest/data

           

          # Tomcat Home Directory

          tomcat.home=C:\\Program Files\\apache-tomcat-6.0.18

          tomcat.port=8080

           

          # Release name and version

          project.version=0.1

          project.name=${ant.project.name}

           

          ant運(yùn)行的主要文件build.xml

          <?xml version="1.0" encoding="UTF-8"?>

          <project name="greatwall" basedir="." default="deploy">

                 <property file="build.properties" />

                

                 <property name="web.home" value="/C:/Program Files/apache-tomcat-6.0.18/webapps/greatwall" />

                

                 <path id="all-libs">

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

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

                        </fileset>

                        <fileset dir="${tomcat.home}/lib">

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

                        </fileset>

                 </path>

                

                 <!-- ===================================

                 編譯Java文件并復(fù)制資源文件

                 ==================================== -->

                 <target name="build" description="Compile main Java sources">

                        <mkdir dir="${build.dir}" />

                        <echo>Compile main Java sources...</echo>

                        <javac destdir="${build.dir}" target="1.5" debug="true" deprecation="true" optimize="false" failonerror="true">

                               <src path="${src.dir}" />

                               <!-- <compilerarg line="-encoding UTF-8" />  -->

                               <classpath refid="all-libs" />

                        </javac>

           

                        <!-- copy other none java files such as hibernate hbm.xml files, workflow files files -->

                        <echo>Copy other none java files...</echo>

                        <copy todir="${build.dir}" preservelastmodified="true">

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

                                      <exclude name="**/*.java" />

                                      <exclude name="**/*.bak" />

                               </fileset>

                        </copy>

                 </target>

                

                 <target name="war" depends="build" description="Create WAR deployment unit">

                        <mkdir dir="${target.dir}" />

                        <echo>Create WAR deployment unit...</echo>

                        <war warfile="${target.dir}/${war.name}.war" webxml="${war.dir}/WEB-INF/web.xml">

                               <!-- Include the css, images and other documents -->

                               <fileset dir="${war.dir}" excludes="WEB-INF/**" />

                               <webinf dir="${war.dir}/WEB-INF">

                                      <exclude name="classes/**" />

                                      <exclude name="web.xml" />

                               </webinf>

                               <!-- Include the compiled classes -->

                               <classes dir="${build.dir}" />

                               <lib dir="${lib.dir}" includes="*.jar" />

                               <exclude name="${war.dir}/WEB-INF/lib/servlet.jar" />

                        </war>

                 </target>

           

                 <target name="deploy" depends="build" description="Deploy the applycation to Tomcat">

                        <echo>Deploy the applycation to Tomcat...</echo>

                        <copy todir="${web.home}">

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

                                      <exclude name="**/*.bak" />

                                      <exclude name="CVS" />

                               </fileset>

                        </copy>

                 </target>

                

          </project>

           

          posted on 2008-11-09 23:14 王總兵 閱讀(350) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 玛沁县| 祁阳县| 鹤壁市| 工布江达县| 铜山县| 吉隆县| 博爱县| 柘荣县| 泾川县| 常山县| 万州区| 上杭县| 辉县市| 望城县| 双江| 峨山| 灌南县| 和静县| 周口市| 高雄县| 英吉沙县| 江达县| 庆阳市| 宝丰县| 汶川县| 炉霍县| 福鼎市| 迭部县| 云梦县| 梨树县| 托克托县| 长治县| 安康市| 荣昌县| 永登县| 公安县| 和政县| 论坛| 赣州市| 康定县| 铜川市|