flexの環境整備(ant)

ここからflex-ant-taskを落とす。解凍したらantのlib下にコピーする。

sudo cp ~/Downloads/flex_ant_tasks_022607/lib/flexTasks.jar /usr/share/ant/lib

環境変数の設定

環境変数は以下のように設定しておく。

~/.bash_profile
export FLEX_HOME=/Applications/flex2_sdk
export ANT_HOME=/usr/share/ant
export PATH=$PATH:$FLEX_HOME/bin

ディレクトリ構成

適当に作業ディレクトリをつくそこに下記のbuild.xmlとbuild.propertiesを配置する。
ソースファイルはsrcディレクトリを作ってそこに配置。

  work
   build.properties
   build.xml
   src

buildx.ml

<?xml version="1.0" encoding="UTF-8" ?>
<project name="javapress" default="build" basedir="." >
  <property file="build.properties"/>
  <property environment="env"/>
  <property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
  <property name="project.swf" value="${project.name}.swf"/>

  <taskdef resource="flexTasks.tasks" classpath="${env.ANT_HOME}/lib/flexTasks.jar" />

  <path id = "project.class.path">
    <pathelement path="${classpath}" />
    <fileset dir="libs" >
      <include name="**/*.swc" />
    </fileset>
    <!--pathelement location="classes" /-->
  </path>

  <target name="all" depends="clean, build" />
  <target name="build" depends="dist" />

  <target name="clean">
    <delete dir="src/generated"/>
    <delete>
      <fileset dir="src">
        <include name="**/*.cache"/>
      </fileset>
    </delete>
    <delete file="dist/${project.swf}"/>
    <delete>
      <fileset dir="${deploy.dir}" includes="${project.swf}"/>
    </delete>
  </target>

  <target name="init">
    <mkdir dir="dist" />
  </target>

  <target name="compile" depends="init">
    <mxmlc
       file="${main.file}"
       output="dist/${project.swf}"
       actionscript-file-encoding="${encoding}"
       keep-generated-actionscript="true"
       incremental="true"
       default-background-color="${project.color}"
       >
      <default-size width="${project.width}" height="${project.height}"/>
      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
      <source-path path-element="${FLEX_HOME}/frameworks"/>
      <compiler.source-path path-element="src"/>
   </mxmlc>
  </target>

<!--       template="client-side-detection" -->
  <target name="dist" depends="compile">
    <copy todir="${deploy.dir}">
      <fileset dir="dist"/>
    </copy>
  </target>

  <target name="run" depends="dist">
  </target>

  <target name="html">
    <html-wrapper
       title="${project.name}"
       height="${project.height}"
       width="${project.width}"
       bgcolor="red"
       application="app"
       swf="${project.name}"
       version-major="9"
       version-minor="0"
       version-revision="0"
       history="true"
       template="express-installation"
       output="dist"/>
  </target>

</project>

build.properties

project.name=Particle
project.width=640
project.height=400
project.color=0x000000
deploy.dir=/Library/WebServer/Documents/downloads/flex/test
encoding=UTF-8
main.file=src/Particle.as

同期に使っているrsync

sourceforgesshログインできるので、rsyncで同期をとれる。便利!

rsync  -acnpvz  -e ssh -C --delete --include-from=includes.txt
 --exclude-from=excludes.txt src_dir host:dst_dir

include.txt
 .htaccess

exclude.txt
 .* #ドットで始まるファイル
 GPATH
 GRTAGS
 GSYMS
 GTAGS
 README