ANT

Apache ANT
http://ant.apache.org/
Ant是将软件编译、测试、部署等步骤加以自动化的工具,大多用于Java软件开发,由Apache软件基金会所提供。(百度百科)
ant + target/default target (build.xml)
project (default/name) -> target(depends) -> javac/jar cmd -> delete/copy/mkdir for init/clean target -> property -> include/exculde/dir/file/value




Eclipse ANT build:
1. project右键 -> Properties -> Builders -> New (Ant builder) -> (Main) Name: tool_ANT, Buildfile: default build.xml, Base Directory: current -> (Targets) Manual Build + clean -> (Classpath) 移除invalid classpath -> Eclipse build/clean button即可替换为new ANT target
2. project build.xml右键 -> (Main) buildfile + Base Directory -> (Build) Build before launch - Specific projects -> (Targets) run target -> Eclipse run button




注意:
1. eclipse可以直接导出project General->ANT Buildfiles (可参考)
2. eclipse在导出Runnable JAR file时可以export ANT (可用)
3. eclipse可导出Deployable plugin时的ANT, 基于eclipse pde.exportPlugins (不可用)
   可直接用eclipse antRunner来build
java -jar "D:\Program Files\eclipse-rcp-mars-R-win32-x86_64\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar" -debug -application org.eclipse.ant.core.antRunner -buildfile build.xml




网络资料:
ANT基础  http://www.cnblogs.com/huozhicheng/archive/2010/04/08/2533199.html
ANT标签  http://www.cnblogs.com/clarkchen/archive/2011/03/10/1980194.html
         http://blog.csdn.net/ccit0519/article/details/17348331
ANT在eclipse用法    http://zhangjunhd.blog.51cto.com/113473/128317/




以下是tool plugin build.xml的示例:
<?xml version="1.0" encoding="UTF-8"?> 
<project default="plugin_export" name="build">
    <property name="ECLIPSE_HOME" value="D:/Program Files/eclipse-rcp-mars-R-win32-x86_64/eclipse/"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
    <path id="Plug-in Dependencies.libraryclasspath">
        <pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.swt.win32.win32.x86_64_3.104.0.v20150528-0211.jar"/>
        <pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.jface_3.11.0.v20150602-1400.jar"/>
        <pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.runtime.compatibility.registry_3.6.0.v20150318-1505/runtime_registry_compatibility.jar"/>
        <pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.contenttype_3.5.0.v20150421-2214.jar"/>
        <pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.equinox.app_1.3.300.v20150423-1356.jar"/>
    </path>
    <path id="com.songpu.testplugin.classpath">
        <path refid="Plug-in Dependencies.libraryclasspath"/>
        <pathelement location="bin"/>
        <pathelement location="libs/tool.jar"/>
    </path>


    <!-- Define build directories --> 
    <property name="root" location="." /> 
    <property name="buildout" location="${root}/product" /> 


    <tstamp> 
        <format property="date" pattern="yyyyMMddHHmm" /> 
    </tstamp>


    <target name="init" depends="clean">
        <!-- Create build directories --> 
        <delete dir="bin" /> 
        <mkdir dir="bin" />
        <delete dir="${buildout}" /> 
        <mkdir dir="${buildout}" />
    </target>
    
    <target name="build-project" depends="init" >
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac srcdir="src" destdir="bin" source="${source}" target="${target}">
            <classpath refid="com.songpu.testplugin.classpath"/>
        </javac>
    </target>
    
   <target name="plugin_export" depends="build-project" > 
        <!-- Read the MANIFEST.MF 
        <
        <replace file="${buildout}/MANIFEST.MF"> 
           <replacefilter token=":=" value="=" /> 
           <replacefilter token=":" value="=" /> 
           <replacetoken>;</replacetoken> 
           <replacevalue> 
           </replacevalue> 
        </replace> 
        <property file="${buildout}/MANIFEST.MF"/>--> 
         <!-- Plugin locations --> 
        <property name="plugin.jarname" value="com.songpu.testplugin_1.0.0.${date}" /> 
        <property name="plugin.jar" location="${buildout}/jars/${plugin.jarname}.jar" /> 
        <property name="product.zip" value="${buildout}/${plugin.jarname}.zip" /> 
        <!-- Assemble plug-in JAR --> 
        <mkdir dir="${buildout}/jars" />
        <mkdir dir="${buildout}/META-INF" />
        <copy file="META-INF/MANIFEST.MF" todir="${buildout}/META-INF" /> 
        <replace file="${buildout}/META-INF/MANIFEST.MF"> 
           <replacefilter token="qualifier" value="${date}" /> 
        </replace>
        <zip destfile="${plugin.jar}"> 
            <zipfileset dir="bin" /> 
            <zipfileset dir="${buildout}" includes="META-INF/MANIFEST.MF" /> 
            <zipfileset dir="." includes="plugin.xml" /> 
            <zipfileset dir="." includes="icons/*" /> 
            <zipfileset dir="." includes="libs/tool.jar" /> 
        </zip> 
        <!-- Assemble the product zip --> 
        <zip destfile="${product.zip}"> 
           <fileset dir="${buildout}/jars/" /> 
        </zip>
        <delete dir="${buildout}/jars" /> 
   </target> 
   
    <target name="clean">
        <delete dir="bin" /> 
        <delete dir="${buildout}" /> 
    </target>
   
</project>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值