欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

[Editplus]_[制作Ant的代码Snippet]

程序员文章站 2022-05-18 07:50:35
  1.Editplus有一个功能,可以制作不同类型的常用的代码片段,以下是我制作的ant的代码片段。   2.存为ant.ctl,放在Editplus的安...
  1.Editplus有一个功能,可以制作不同类型的常用的代码片段,以下是我制作的ant的代码片段。

 

2.存为ant.ctl,放在Editplus的安装目录下。

3.喜欢用editplus做开发工具的自己动动手把。。其他的snippet..

 

 

[html]  

#TITLE=Ant  

; EditPlus Auto-completion file v1.0 written by ES-Computing.  

; This file is provided as a default auto-completion file for Ant.  

  

#CASE=n  

  

;项目  

#T=Project_property  

<property name="^!" value=""/>  

#T=Project_project  

<?xml version="1.0" encoding="UTF-8"?>  

<project name="test">  

</project>  

#T=Project_path  

<path id="cxf.lib">  

        <fileset file="${cxf}/*.jar"/>  

        <pathelement path="${basedir}/classes" />  

</path>  

  

#T=Project_import  

<!--The import task may only be used as a top-level task.   

    This means that it may not be used in a target.-->  

<import file="customTargets.xml" optional="true"/>  

  

#T=Project_taskdef_ant-contrib  

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>  

  

;任务  

#T=Target_target  

<target name="^!" if="">  

</target>  

#T=Target_antcall  

<antcall target="^!">  

    <param name="" value=""/>  

</antcall>  

#T=Target_ant  

<ant antfile="build.xml" target="" dir="">  

    <property name="^!" value=""/>  

</ant>  

#T=Target_param  

<param name="^!" value=""/>  

  

#T=Target_parallel  

<target name="modifyproperties" if="build.properties.exists">  

      <antcall target="service"/>  

      <parallel threadCount="2" failonany="true">  

         <sequential>  

            <antcall target="client"/>  

         </sequential>  

         <sequential>  

            <antcall target="service"/>  

         </sequential>  

      </parallel>  

      <antcall target="publish"/>  

</target>  

  

#T=Target_antcallback_ant-contrib  

<antcallback target="test" return="a"/>  

  

#T=Target_server_ant-contrib  

<antserver port="6090" />  

  

#T=Target_remoteant_ant-contrib  

 <target name="client">  

    <remoteant machine="localhost" port="6090">  

        <runtarget target="test">  

           <property name="foo" value="bar" />  

        </runtarget>  

    </remoteant>  

</target>  

  

<target name="client2">  

    <remoteant machine="localhost" port="6090">  

        <runant dir="G:\Script\JAVA\cxf2" target="compile">  

           <property name="build.type" value="full" />  

        </runant>  

    </remoteant>  

</target>  

  

;系统  

#T=System_exec  

<exec dir="." executable="${svn.exe}">  

    <env key="CATALINA_HOME" value="${CATALINA_HOME}"/>  

    <arg line="${svn.cmd} -r"/>  

</exec>  

  

;文件  

#T=File_delete  

<delete dir="^!" includes="*.xml"/>  

  

#T=File_mkdir  

<mkdir dir="^!"/>  

  

#T=File_copy  

<copy todir="^!">  

    <fileset dir="^!" includes="*.*"/>  

</copy>  

#T=File_fileset  

<fileset dir="^!" includes="" excludes=""/>  

<fileset dir=".">  

    <include name="h.zip"/>  

</fileset>  

  

#T=File_zip  

<zip destfile="${basedir}/SmartAvideo.zip">  

    <zipfileset dir="${basedir}/gui" prefix="SmartAvideo">  

        <include name="**/*.exe"/>  

    </zipfileset>  

    <fileset dir="simulator.gh.callcenter">  

        <include name="*.xml"/>  

        <include name="startup.bat"/>  

        <include name="readme.txt"/>  

    </fileset>  

</zip>  

  

#T=File_unzip  

<unzip dest="${artifactsDir}/${warname}_war" src="${artifactsDir}/${warname}.war"/>  

  

#T=File_propertyfile  

<!-- don't use it,it will lost comment -->  

<propertyfile  

    file="my.properties"  

    comment="My properties">  

  <entry  key="akey" value="avalue"/>  

  <entry  key="adate" type="date" value="now"/>  

  <entry  key="anint" type="int" operation="+"/>  

  <entry  key="formated.int" type="int" default="0013" operation="+" pattern="0000"/>  

  <entry  key="formated.date" type="date" value="now" pattern="DDD HH:mm"/>  

</propertyfile>  

  

#T=File_loadfile  

<!-- Load a text file into a single property -->  

<loadfile srcfile="buildnumber.txt"   

       encoding="UTF-8" property="buildnumber" failonerror="false">  

        <filterchain>  

          <expandproperties/>  

        </filterchain>  

</loadfile>  

#T=File_xmlproperty  

<xmlproperty file="somefile.xml"  

                semanticAttributes="true"/>  

<?xml version="1.0" encoding="UTF-8"?>  

<properties>  

    <tomcat.home>中文</tomcat.home>  

</properties>  

  

#T=File_sync  

<sync todir="sync" overwrite="false" includeEmptyDirs="true" failonerror="true">  

      <fileset dir="G:/repository2"/>  

</sync>  

  

;消息  

#T=Message_echo  

<echo message=""/>  

  

#T=Message_input  

<input message="All data is going to be deleted from DB continue (y/n)?"  

        validargs="y,n"  

        addproperty="do.delete"/>  

<condition property="do.abort">  

<equals arg1="n" arg2="${do.delete}"/>  

</condition>  

<fail if="do.abort">Build aborted by user.</fail>  

  

;字符串  

#T=String_replacereg  

<replaceregexp match="--.*" replace="" flags="i" byline="true">  

    <fileset dir="" includes="*.sql"/>  

</replaceregexp >  

#T=String_replace  

<replace dir="${artifactsDir}/tempsqls" token=";" value="~  

" casesensitive="false" summary="true">  

    <include name="*.sql"/>  

</replace>  

  

;数据库  

#T=SQL_sql  

<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.password}"  

                onerror="stop" print="true" delimiter="~"  autocommit="true" keepformat="true">  

    <classpath refid="all.lib" />  

    <fileset dir="${artifactsDir}/tempsqls">  

        <include name="*.*"/>  

    </fileset>  

</sql>  

  

;时间  

#T=Date_time  

<tstamp>  

    <format property="version.no" pattern="yyyyMMddHHmmss" locale="en"/>  

</tstamp>  

  

;java  

#T=Java_java  

<java classname="org.eclipse.core.launcher.Main" failonerror="true" fork="true" dir="">  

    <arg value="-application" />  

    <classpath refid="lib"/>  

    <classpath>  

        <path path="${eclipse.home}/startup.jar" />  

    </classpath>  

</java>  

  

#T=Java_javac  

<javac destdir="${build}"  

         classpath="xyz.jar"  

         debug="on">  

    <src path="${src}"/>  

    <src path="${src2}"/>  

    <include name="mypackage/p1/**"/>  

    <include name="mypackage/p2/**"/>  

    <exclude name="mypackage/p1/testpackage/**"/>  

</javac>  

  

#T=Java_war  

<war destfile="${artifactsDir}/${warname}.war" webxml="${war.source}/web.xml" update="false" duplicate="preserve">  

    <webinf dir="data.common/src">  

        <include name="hbm/**/*.xml" />  

        <exclude name="hbm/**/*Test*.xml" />  

    </webinf>  

    <fileset file="${war.source}/index.jsp" />  

    <classes file="${war.source}/ehcache.xml" />  

    <lib dir="${artifactsDir}">  

        <include name="*.jar" />  

        <exclude name="*.test.*.jar" />  

    </lib>  

</war>  

  

#T=Java_java.version  

<target name="java.version">    

      <java classname="org.eclipse.core.launcher.Main" failonerror="true" fork="true" dir="">    

          <jvmarg value="-version"/>    

      </java>    

</target>  

  

  

;条件语句  

#T=Condition_condition  

<condition property="fetchTag" value="HEAD">  

    <equals arg1="${buildType}" arg2="N" />  

    <not>  

    <isset property="performance.base" />  

    </not>  www.2cto.com

</condition>  

#T=Condition_available  

<available file="${buildDirectory}/label.properties" property="label.properties.exists" />  

  

#T=Condition_if_ant-contrib  

<if>  

 <equals arg1="${foo}" arg2="bar" />  

 <then>  

   <echo message="The value of property foo is bar" />  

 </then>  

 <else>  

   <echo message="The value of property foo is not bar" />  

 </else>  

</if>  

  

#T=Condition_matches  

;支持正则  

<condition property="build.error">  

           <matches string="${build.output}" pattern="[eE]rror"/>  

</condition>  

<fail if="build.error"/>  

  

;邮件  

#T=Mail_mail  

<mail mailhost="mail.sysway.com" ssl="false" mailport="25" subject="extern.ip" user="" password="" charset="utf-8" failonerror="true">  

    <from address="huid@syway.com" />  

    <to address="huid@sysway.com" />  

    <message>The ${buildname} nightly build has completed</message>  

    <fileset dir="dist">  

    <includes name="**/*.zip"/>  

    </fileset>  

</mail>  

  

;网络  

#T=Network_get  

<!-- 时间戳是用来查看文件是否是最新的 -->  

<get src="${libs.location}/ant.jar" dest="lib/ant.jar" usetimestamp="true"/>  

  

#T=Exception_trycatch_ant-contrib  

<trycatch property="foo" reference="bar">  

    <try>  

        <antcall target="fail"/>  

    </try>  

  

    <catch>  

        <echo>In <catch>.</echo>  

    </catch>  

  

    <finally>  

        <echo>In <finally>.</echo>  

    </finally>  

</trycatch>  

<echo>As property: ${foo}</echo>  

<property name="baz" refid="bar" />  

<echo>From reference: ${baz}</echo>  

<property name="a" value="success"/>  

  

#  

 

3.截图,双击即可自动在文本编辑区添加配置好的代码片段,提高开发效率。

[Editplus]_[制作Ant的代码Snippet]