沉睡森林@漂在北京

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

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

          晚上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文件并復(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 王總兵 閱讀(347) 評論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 黑水县| 东乡族自治县| 广安市| 临湘市| 德阳市| 阳原县| 哈密市| 休宁县| 永平县| 克拉玛依市| 吴桥县| 格尔木市| 克什克腾旗| 韶山市| 福州市| 交城县| 澳门| 成安县| 隆化县| 孙吴县| 车险| 丰顺县| 泉州市| 玉屏| 建宁县| 沙坪坝区| 铜陵市| 仲巴县| 池州市| 钟山县| 会东县| 贡山| 调兵山市| 吴川市| 大姚县| 宁海县| 绍兴市| 无锡市| 都安| 彭水| 江安县|