假設我有兩個專案:
* HelloWorldAS3Lib
* HelloWorldAS3
1.
開發 HelloWorldAS3Lib 專案,準備 build.xml,其中使用 compc 編譯 *.swc 的部分如下:
<target name="compile flex project" depends="init">
<compc output="${DEPLOY_DIR}/Lib.swc">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
<include-sources dir="${SRC_DIR}" includes="*" />
</compc>
</target>
使用方法,可參考官方 Using Flex Ant Tasks 的說明:
http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html
這份 ant,會在 HelloWorldAS3Lib 專案的 DEPLOY 資料夾下,產生 Lib.swc 檔案。
2.
在 HelloWorldAS3 專案中,不管 Flash Builder 4 開發環境怎麼設定,或任何你喜歡的開發工具如何設定,這裡要討論的是 ant 的部分。
build.properties 中,增加一變數定義 Lib.swc 的放置位置:
LIBS_DIR_EXTERNAL =${basedir}/../HelloWorldAS3Lib/DEPLOY
build.xml 中,也要增加 include-libraries 的段落:
<target name="compile flex project" depends="init">
<mxmlc file="${SRC_DIR}/HelloWorldAS3.as" output="${DEPLOY_DIR}/HelloWorldAS3.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
<compiler.include-libraries dir="${LIBS_DIR_EXTERNAL}" append="true">
<include name="Lib.swc" />
</compiler.include-libraries>
</mxmlc>
</target>
在本機使用 ant build 測試一下,至少要先測通這段。
3.
將 HelloWorldAS3Lib 與 HelloWorldAS3 都 commit 到 SVN 上,在 SVN 上的 Repository URL 可以與本機開發環境時的專案資料夾名稱完全不一樣。等下在 Hudson CI-Server 將這兩個專案下載到 workspace 時,可以指定下載的資料夾路徑,到時候再定義成與開發環境相同的資料夾名稱即可,以確保 build.xml 可以找得到 Lib.swc。
4.
這裡,我們先來看一下之前 Hudson 上 HelloWorldAS3 專案的建置結果,現在因為 HelloWorldAS3 專案中使用到某個 HelloWorldAS3Lib 專案所提供的程式碼,所以若是在 Hudson 上仍用原本的 build file,就會發生錯誤訊息:
所以,接下來我們要重新建立一個範例,會從 SVN 下載兩個專案,並且依照順序執行兩個專案的 build.xml。
5.
新開一個 free style 專案,取名 "HelloWorldAS3_demo2",
設定 SCM 使用 SVN,建立兩筆 SVN 資料,特別注意的部分是 "Local module directory (optional)" 可以用來決定將 SVN 專案下載到 hudson 的 workspace 時,要放在哪個資料夾中:
設定 Ant Build 的部分,先建立 HelloWorldAS3Lib 專案,再建立 HelloWorldAS3 專案,最後才進行 HelloWorldAS3 的 FlexPMD 的 task,只要特別注意 build file 位置不要搞錯就好:
最後設定 PMD 分析檔案放在哪裡:
建置畫面,順利完成:





0 意見:
張貼意見