PHP字串長度找子字串與取代字串的常用函數

PHP在字串的操作上,有非常多的相關函數可以使用,我們在這裡只介紹經常會使用到的字串操作函數。像是如何取得字串的長度、在某一個字裏面尋找子字串首次出現的位置、以及字串的取代函數...等等。這些都是在編寫程式的時候,頻繁被程式設計師使用到的基礎函數。 取得字串長度 <?...

2012年7月4日 星期三

使用Eclipse Ant plugin操作流程

目前Ant工具已經內崁為Eclipse IDE的一部份,因此我們不需要額外再安裝Ant plugin套件,
其使用方法極為簡單,完整的操作流程可參考下列說明:

1. 開啟您的Eclipse IDE,建立一個TestProject的專案之後,於src/jcode/test套件目錄底下
   新增HelloTest類別且於程式進入點的main()函式,加入以下的一段程式代碼:

public static void main(String[] args) {
  System.out.println("Hello, everybody!");    
}

2. 把滑鼠指標移至TestProject的圖示,然後點擊滑鼠右鍵,出現上下文選單(context menu)點取Export項目,



   畫面帶出如下圖的"Export"對話方塊,選擇"Ant Buildfiles"圖示,來產出TestProject的build.xml文件檔:

 

3. 打開build.xml文檔,並且對該文件進行局部性的修改,其修改過的程式代碼以紅色粗體字表示。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="TestProject">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../eclipse-sdk-helios"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
      <property name="dist" location="dist"/>
   
    <path id="TestProject.classpath">
        <pathelement location="bin"/>
        <pathelement location="../../../jar-lib/ojdbc14.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>   
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <!--target depends="build-subprojects,build-project" name="build"/-->
   
      <target depends="dist" name="build"/>
   
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="TestProject.classpath"/>
        </javac>
    </target>
   
      <target name="dist" depends="build-subprojects,build-project" description="generate the distribution" >
        <!-- 創建放置jar檔目錄 -->
        <mkdir dir="${dist}/lib"/>
        
        <!-- build目錄內的所有檔案結構打包成一個TestProject.jar  -->
        <jar jarfile="${dist}/lib/${ant.project.name}.jar" basedir="bin"/>
      </target>
   
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
</project>


4. 將滑鼠指標移動到build.xml圖示,單點滑鼠右鍵後選取"Run As -> 1 Ant Build"項目執行,會於"Console"輸出Ant的腳本代碼:




Buildfile: D:\works\TestProject\build.xml
build-subprojects:
init:
build-project:
     [echo] TestProject: D:\works\TestProject\build.xml
dist:
    [mkdir] Created dir: D:\works\TestProject\dist\lib
      [jar] Building jar: D:\works\TestProject\dist\lib\TestProject.jar
build:
BUILD SUCCESSFUL
Total time: 526 milliseconds

1 則留言: