<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    JAVA進行式
    讓我們把JAVA進行到底!
    posts - 13,comments - 21,trackbacks - 0

    說明:
    ??????? 下面是我在開發中使用的build.xml文件以及其附屬文件,為使層次清晰我將公用任務放入common.xml中,另外還有一些配置文件,這個build.xml會在今后開發中不斷完善。

    ??????? 1、build.xml文件
    <?xml version="1.0" encoding="gb2312"?>
    <project name="message" basedir="." default="help">
    ? <property name="webapp.name" value="message"/>
    ? <import file="../message/common.xml"/>

    ? <!-- "test" 任務用于執行junit的單元測試 -->
    ? <target name="test" description="Run junit test.">
    ??? <mkdir dir="${build.dir}/test"/>
    ??? <mkdir dir="${build.dir}/report"/>
    ??
    ??? <junit printsummary="yes">
    ????? <formatter type="xml"/>
    ?? <test name="cn.hxex.message.test.AllTests"/>
    ?? <classpath refid="classpath"/>
    ??? </junit>
    ???
    ??? <junitreport todir="${build.dir}/test">
    ????? <fileset dir=".">
    ???? <include name="TEST-*.xml"/>
    ?? </fileset>
    ?? <report format="noframes" todir="${build.dir}/report"/>
    ??? </junitreport>
    ? </target>
    ?
    ? <!-- "run"任務用于運行指定程序 -->?
    ? <target name="run">
    ??? <java classname="cn.hxex.basic.exercise.LifeCycle">
    ????? <classpath refid="classpath"/>
    ??? </java>
    ? </target>
    </project>

    ??????? 2、common.xml文件
    <?xml version="1.0" encoding="gb2312"?>
    <project>
    ? <!-- 直接設置項目文件夾變量,也可以寫一個配置文件,用file屬性引入 -->
    ? <!--
    ? <property file="webapp.properties"/>
    ?? -->
    ? <property name="src.dir" value="src"/>
    ? <property name="build.dir" value="WebRoot"/>
    ? <property name="webpage.dir" value="${build.dir}/webpage"/>
    ? <property name="webinf.dir" value="${build.dir}/webinf"/>
    ? <property name="lib.dir" value="${webinf.dir}/lib"/>
    ? <property name="classes.dir" value="${webinf.dir}/classes"/>
    ?
    ? <!-- 取得環境變量TOMCAT_HOME的值 -->
    ? <property environment="env"/>
    ? <property name="tomcat.home" value="${env.TOMCAT_HOME}"/>
    ? <property name="ant.home" value="${env.ANT_HOME}"/>
    ?
    ? <!-- 引入有關tomcat的變量配置文件,也可以象上面一樣,直接在這里設置 -->
    ? <property file="tomcat.properties"/>
    ? <!--
    ? <property name="tomcat.server" value="localhost"/>
    ? <property name="tomcat.manager.url" value="http://${tomcat.server}/manager"/>
    ? <property name="tomcat.username" value="admin"/>
    ? <property name="tomcat.password" value=""/>
    ?? -->
    ?
    ? <!-- 設置任務要執行的類操作 -->
    ? <!-- 可引入設置tomcat任務的配置文件 -->
    ? <taskdef file="tomcatTasks.properties">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <!-- 也可逐一設置任務
    ? <taskdef name="deployc" classname="org.apache.catalina.ant.DeployTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="list" classname="org.apache.catalina.ant.ListTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ?
    ? <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
    ??? <classpath>
    ????? <pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
    ??? </classpath>
    ? </taskdef>
    ? -->
    ? <!--
    ? <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
    ??? <classpath>
    ????? <pathelement path="${ant.home}/lib/ant-junit.jar"/>
    ??? </classpath>
    ? </taskdef>-->
    ?????
    ? <!-- 設置類路徑 -->
    ? <path id="classpath">
    ??? <fileset dir="${lib.dir}">
    ????? <include name="*.jar"/>
    ??? </fileset>
    ?
    ??? <fileset dir="${tomcat.home}/common/lib">
    ????? <include name="*.jar"/>
    ??? </fileset>
    ???
    ??? <fileset dir="${ant.home}/lib">
    ????? <include name="*.jar"/>
    ??? </fileset>
    ???
    ??? <pathelement path="${classes.dir}"/>
    ? </path>

    ? <!-- "help"任務用于顯示幫助信息 -->
    ? <target name="help">
    ??? <echo message=""/>
    ??? <echo message="${webapp.name} build file"/>
    ??? <echo message="----------------------------------------------------------"/>
    ??? <echo message=""/>
    ??? <echo message="Available targets are:"/>
    ??? <echo message=""/>
    ??? <echo message="help??? --> Print this screen."/>
    ??? <echo message="start?? --> Start Tomcat application."/>
    ??? <echo message="stop??? --> Stop Tomcat application."/>
    ??? <echo message="list??? --> List Tomcat applications."/>
    ??? <echo message="compile --> Compile all Java files."/>
    ??? <echo message="deploy? --> Deploy the project to the tomcat."/>
    ??? <echo message="clean?? --> Clean output directories."/>
    ??? <echo message="new???? --> Creates a new project with the specified name."/>
    ??? <echo message="test??? --> Run junit test."/>
    ? </target>

    ? <!-- "start"任務用于啟動Tomcat -->
    ? <target name="start" description="Start Tomcat application">
    ??? <start url="${tomcat.manager.url}"
    ?????????? username="${tomcat.username}"
    ?????????? password="${tomcat.password}"
    ?????????? path="/${webapp.name}"/>
    ? </target>

    ? <!-- "stop"任務用于停止Tomcat -->
    ? <target name="stop" description="Stop Tomcat application">
    ??? <stop url="${tomcat.manager.url}"
    ????????? username="${tomcat.username}"
    ????????? password="${tomcat.password}"
    ????????? path="/${webapp.name}"/>
    ? </target>

    ? <!-- "list"任務用于顯示Tomcat中應用名 -->
    ? <target name="list" description="List Tomcat applications">
    ??? <list url="${tomcat.manager.url}"
    ????????? username="${tomcat.username}"
    ????????? password="${tomcat.password}"/>
    ? </target>?
    ?
    ? <!-- "clean"任務用于清除所有文件及文件夾 -->
    ? <target name="clean" description="Clean output directories">
    ??? <delete dir="${classes.dir}"/>
    ??? <delete dir="${tomcat.home}/webapps/${webapp.name}"/>
    ? </target>

    ? <!-- "compile"任務用于編譯源代碼和復制Hibernate配置文件到指定類文件夾 -->
    ? <target name="compile" description="compile the java source and copy the configuration file">
    ??? <mkdir dir="${classes.dir}"/>
    ??? <javac destdir="${classes.dir}"
    ?????????? target="1.5" source="1.5" debug="true"
    ?????????? deprecation="true" optimize="false" failonerror="true">
    ????? <src path="${src.dir}"/>
    ????? <classpath refid="classpath"/>
    ??? </javac>
    ?
    ??? <!-- 復制hibernate映射文件到項目下的classes文件中 -->
    ??? <copy todir="${classes.dir}">
    ????? <fileset dir="${src.dir}" includes="**/*.xml"/>
    ????? <fileset dir="${src.dir}" includes="**/*.properties"/>
    ??? </copy>
    ?
    ??? <!-- 復制配置文件到項目下的classes文件中 -->
    ??? <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes">
    ????? <fileset dir="${classes.dir}" includes="**/*.xml"/>
    ????? <fileset dir="${classes.dir}" includes="**/*.properties">
    ??????? <exclude name="**/*_zh.properties"/>
    ????? </fileset>?
    ??? </copy>
    ?
    ??? <!-- 對中文配置文件進行編碼編譯 -->
    ??? <native2ascii dest="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes"
    ????????????????? encoding="UTF-8"
    ????????????????? src="${classes.dir}" includes="**/*_zh.properties"/>
    ? </target>

    ? <!-- "deploy"任務用于部署項目和復制配置文件到tomcat容器 -->
    ? <target name="deploy" depends="compile" description="deploy the project to the tomcat!">
    ??? <!-- 復制web網頁文件 -->
    ??? <copy todir="${tomcat.home}/webapps/${webapp.name}" preservelastmodified="true">
    ????? <fileset dir="${webpage.dir}">
    ??????? <include name="**/*.*"/>
    ??????? <exclude name="**/readme.txt"/>
    ????? </fileset>
    ??? </copy>
    ?
    ??? <!-- 復制類文件 -->
    ??? <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes"
    ????????? preservelastmodified="true">
    ????? <fileset dir="${classes.dir}"/>
    ??? </copy>
    ???
    ??? <!-- 復制庫文件 -->
    ??? <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/lib"
    ????????? preservelastmodified="true">
    ????? <fileset dir="${lib.dir}">
    ??????? <exclude name="**/readme.txt"/>
    ????? </fileset>
    ??? </copy>
    ?
    ??? <!-- 復制配置文件 -->
    ??? <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF"
    ????????? preservelastmodified="true">
    ????? <fileset dir="${webinf.dir}">
    ??????? <exclude name="**/readme.txt"/>
    ????? </fileset>
    ????? <fileset dir="${build.dir}">
    ??????? <include name="*.xml"/>
    ??????? <include name="*..properties"/>
    ????? </fileset>
    ??? </copy>
    ? </target>

    ? <!-- "new"任務用于創建一個新的項目,復制原項目,并改為新項目名 -->
    ? <target name="new" description="creates a new project with the specified name">
    ??? <echo level="info">
    ????? +----------------------------------------------------------+
    ????? |??? -- Welcome to the AppDemo New Application Wizard! --? |
    ????? |????????????????????????????????????????????????????????? |
    ????? | To create a new application, please answer the following |
    ????? | questions.?????????????????????????????????????????????? |
    ????? +----------------------------------------------------------+
    ??? </echo>
    ??? <echo/>
    ?
    ??? <!-- 提示用戶輸入新建的項目名 -->
    ??? <input message="What would you like to name your application [myapp]?"
    ?????????? addproperty="app.name" defaultvalue="myapp"/>
    ?
    ??? <echo level="info">
    ????? Creating new application named '${app.name}'...
    ??? </echo>
    ??? <copy todir="../${app.name}">
    ????? <fileset dir="${basedir}">
    ??????? <exclude name="${lib.dir}/*.txt"/>
    ????? </fileset>
    ??? </copy>
    ?
    ??? <!-- 替換應用名 -->
    ??? <replaceregexp flags="g">
    ????? <regexp pattern="message"/>
    ????? <substitution expression="${app.name}"/>
    ????? <fileset dir="../${app.name}">
    ??????? <include name="**"/>
    ??????? <exclude name="**/*.jar"/>
    ????? </fileset>
    ??? </replaceregexp>
    ? </target>
    </project>

    ??????? 3、webapp.properties文件
    src.dir=src
    build.dir=WebRoot
    webpage.dir=${build.dir}/webpage
    webinf.dir=${build.dir}/webinf
    lib.dir=${webinf.dir}/lib
    classes.dir=${webinf.dir}/classes

    ??????? 4、tomcatTasks.properties文件
    deploy=org.apache.catalina.ant.DeployTask
    install=org.apache.catalina.ant.InstallTask
    list=org.apache.catalina.ant.ListTask
    reload=org.apache.catalina.ant.ReloadTask
    remove=org.apache.catalina.ant.RemoveTask
    resources=org.apache.catalina.ant.ResourcesTask
    roles=org.apache.catalina.ant.RolesTask
    start=org.apache.catalina.ant.StartTask
    stop=org.apache.catalina.ant.StopTask
    undeploy=org.apache.catalina.ant.UndeployTask

    ??????? 5、tomcat.properties文件
    tomcat.server=localhost
    tomcat.manager.url=http://${tomcat.server}/manager
    tomcat.username=admin
    tomcat.password=

    posted on 2006-08-05 10:18 水秀清靈 閱讀(847) 評論(1)  編輯  收藏 所屬分類: 學習筆記

    FeedBack:
    # re: 在開發中使用ant
    2006-08-10 06:45 | 楓中玎玲
    小巫不錯哈,ant都看的差不多了,呵呵
    過段時間我也要學ant老,到時少不了問你問題哦
    ^_^  回復  更多評論
      
    主站蜘蛛池模板: 亚洲最新永久在线观看| 日本高清不卡中文字幕免费| 免费国产人做人视频在线观看| 亚洲国产电影在线观看| 中国一级毛片视频免费看| 亚洲AV无码一区二区三区人 | 香蕉视频免费在线播放| 国产a级特黄的片子视频免费| 亚洲人成网站18禁止久久影院| 黑人大战亚洲人精品一区| 免费精品国产日韩热久久| 黄色网站软件app在线观看免费| 亚洲色偷偷色噜噜狠狠99| 久久久久亚洲AV无码网站| 亚洲av不卡一区二区三区| 亚洲片国产一区一级在线观看| 免费国产成人午夜电影| 国产免费私拍一区二区三区| 四虎影视久久久免费观看| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 又大又黄又粗又爽的免费视频| 国产精品综合专区中文字幕免费播放| 亚洲裸男gv网站| 成年性生交大片免费看| 91手机看片国产永久免费| 久久香蕉国产线看免费| 99久久免费国产特黄| 国产免费AV片在线观看播放| 中国一级特黄的片子免费 | 免费在线观看一级片| 99精品一区二区免费视频| 久久久久国产精品免费免费不卡| 西西人体免费视频| 三年片在线观看免费观看大全动漫 | 亚洲成色WWW久久网站| 亚洲人成网站影音先锋播放| 五月天网站亚洲小说| 亚洲高清不卡视频| 亚洲精品色在线网站| 在线播放免费人成视频网站| 久久久久久久久久免免费精品|