沉睡森林@漂在北京

          本處文章除注明“轉載”外均為原創,轉載請注明出處。

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評論 :: 0 Trackbacks
          <2008年11月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          隨筆分類(115)

          隨筆檔案(154)

          技術blog

          搜索

          最新評論

          晚上eclipse不知道怎么的,總是不停的編譯,一打開tomcat就死掉。郁悶的很,自己寫了一個ant命令來編譯和部署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運行的主要文件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文件并復制資源文件

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

                 <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 王總兵 閱讀(348) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 嘉义县| 岚皋县| 长乐市| 博湖县| 新平| 汉源县| 方城县| 盈江县| 普兰店市| 广东省| 中卫市| 阿拉善盟| 天长市| 佛山市| 平南县| 正安县| 宁陕县| 新闻| 延寿县| 大庆市| 晋城| 甘泉县| 罗甸县| 电白县| 台州市| 彰化县| 遂溪县| 辽宁省| 沧州市| 左云县| 隆化县| 波密县| 明溪县| 海晏县| 长丰县| 曲松县| 宝坻区| 江阴市| 东山县| 九寨沟县| 任丘市|