Ant命令列操作

來源:互聯網
上載者:User

標籤:des   style   http   java   使用   os   io   檔案   

Ant命令列操作

 

Ant構建檔案可以將項目編譯,打包,測試,它是Apache軟體基金會jakarta檔案夾中的一個子項目,具有跨平台性,操作簡單,並且非常easy上手。

 

關於Ant執行,能夠在項目中找到build.xml直接執行,還能夠在命令列切換到構建檔案檔案夾執行。前者比較的快,而後者相對來說慢點,在命令列中輸入Ant命令就能夠執行Ant,若沒有指定不論什麼參數, Ant會在當前檔案夾下檢索build.xml檔案,假設找到了就執行該檔案,假設沒有找到了會,會提示沒有找到相關的build.xml檔案。

 

 

project視圖:

 

 

 

 

 

 

 

代碼清單:

 

build.xml

 

<?xml version="1.0" encoding="UTF-8"?><project name="myAnt" default="" basedir="."> <description> simple example build file </description> <!--定義項目源檔案存放路徑--> <property name="srcDir" location="src"/><!--定義項目編譯檔案存放路徑--> <property name="buildDir" location="bin"/><!--定義項目打包檔案存放路徑--> <property name="distDir" location="dist"/><!--初始項目類檔案--> <target name="init" if="ant.java.version" unless="argmin"> <tstamp> <format property="offset_time" pattern="HH:mm:ss" offset="10" unit="minute"/> </tstamp> <mkdir dir="${buildDir}"/> <mkdir dir="${distDir}"/> <echo message="正在建立編譯檔案夾...."/> </target> <!--編譯項目類檔案--> <target name="compile" depends="init" description="compile the source" > <javac srcdir="${srcDir}" destdir="${buildDir}" debug="false" fork="true"/> <echo message="正在編譯檔案檔案夾...."/> </target> <!--打包項目源檔案--> <target name="dist" depends="compile" description="generate the distribution"> <jar basedir="${buildDir}" destfile="${distDir}/package-${DSTAMP}.jar" update="true"> <manifest> <attribute name="Built-By" value="${user.name}"/> <attribute name="Main-Class" value="package.Main"/> </manifest> </jar><jar basedir="${srcDir}" destfile="${distDir}/package-src-${DSTAMP}.jar" update="true"/> <echo message="正在打包編譯檔案,源檔案..."/> </target> <!--清除專案檔包--> <target name="clean" description="clean up"> <delete dir="${buildDir}"/> <delete dir="${distDir}"/> <echo message="清空編譯檔案夾,源檔案夾..."/> </target></project>

 

 

Ant命令清單具體解釋:

 

一般而言,執行一個Ant命令,它的組成是:

Ant -arguments [target1,target2,target3,target4......]

 

1,Ant  -h

     作用:表示提供Ant命令參數任務

 

 

2,Ant -projecthelp | -p

作用:顯示當前build.xml的主要任務

 

 

3,Ant -version

作用:顯示當前Ant的最新的版本號碼

 

4,Ant -diagnostics

作用:診斷當前Ant的全部的配置

 

 

 

5,Ant -debug | -d

作用:檢索當前構建檔案配置情況

 

 

 

6,Ant -quiet | -q

作用:顯示當前構建檔案無依賴任務

 

7,Ant -emacs | -e

作用:調用編輯當前構建檔案編輯器

 

 

8,Ant -lib [path]

作用:調用當前項目中jar,class檔案

 

 

9,Ant -logfile |-l

作用:調用執行當前項目中*.log檔案

 

10,Ant -buildfile |- f | -file

作用:調用執行相似build.xml的檔案

 

11,Ant -propertyfile [name]

作用:調用執行指定的屬性檔案

 

 

12,Ant -find | -s file

作用:檢索執行指定的構建檔案

 

13,Ant -autoproxy

作用:使用系統自己主動代理構建檔案

 

14,Ant-main class

作用:設定系統類別庫檔案裡主要類

 

15,Ant -nice number

作用:設定主類線程同意的線程數

 

這些Ant命令是經常使用的,希望能給大家有所協助!

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.