This is my ant build script used for building app.
You know FlashDevelop can build swf however it only compiles minimum classes directly used in the program. So I always run ant build script in order to compile all ".as" and ".mxml" source files
If you would like to use my ant script, need some preparation....
This is an example property file.
You know FlashDevelop can build swf however it only compiles minimum classes directly used in the program. So I always run ant build script in order to compile all ".as" and ".mxml" source files
If you would like to use my ant script, need some preparation....
- Flex PMD: You can download Flex PMD, which is used in my ant script, from here.
- PMD xslt: I just downloaded official sourceforge PMD zip (the version is 5.0.0 when I wrote this article) and simply picked up some useful xslt from pmd-src-5.0.0/etc/xslt
- My project directory hierarchy is something like this...
<?xml version="1.0" encoding="utf-8" ?> <project name="DukeSoftwareBuildAS3" default="all" basedir="."> <property name="root.dir" value=".." /> <property file="${root.dir}/proj.properties" /> <property file="build.properties" /> <property name="build.dir" value="${root.dir}/build" /> <property name="mxmlc.jar.path" value="${FLEX_HOME}/lib/mxmlc.jar" /> <property name="adt.jar" value="${FLEX_HOME}/lib/adt.jar"/> <property name="asdoc.exe.path" value="${FLEX_HOME}/bin/asdoc.exe" /> <property name="asdoc.output.dir" value="${build.dir}/asdoc" /> <property name="src.dir" value="${root.dir}/src" /> <property name="lib.dir" value="${root.dir}/lib" /> <property name="flex.flexcover.lib" value="${flex.flexcover.home}/lib" /> <property name="flex.flexcover.bin" value="${flex.flexcover.home}/bin" /> <property name="storetype" value="pkcs12" /> <property name="keystore.path" value="${root.dir}/build/SelfSigned.pfx" /> <property name="app.pacakge.name" value="${project.name}.air" /> <!-- PMD --> <property name="flexpmd.output.dir" value="${build.dir}/flexpmd" /> <property name="pmd.version" value="4.2.5" /> <property name="incremental" value="true" /> <property name="configname" value="true" /> <property name="benchmark" value="true" /> <property name="APP_ROOT" value="src" /> <property name="swc.dir" value="${build.dir}/swc" /> <property name="swc.optimize" value="false" /> <property name="swc.verbose.stacktrace" value="false" /> <property name="swc.show.actionscript.warnings" value="true" /> <property name="swc.show.binding.warnings" value="true" /> <property name="target.player" value="11" /> <property name="name" value="SelfSigned" /> <target name="check-requied-program-exists"> <available file="${flex.flexcover.home}" property="flex.flexcover.home.exists"/> <fail unless="flex.flexcover.home.exists" message="could not found Flex3 including flexcover." /> <available file="${flexpmd.dir}" property="flexpmd.dir.exists"/> <fail unless="flexpmd.dir.exists" message="could not found FlexPMD directory" /> </target> <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> <taskdef name="flexPmd" classname="com.adobe.ac.pmd.ant.FlexPmdAntTask" classpath="${flexpmd.dir}/flex-pmd-ant-task-${flexpmd.version}.jar"> <classpath> <pathelement location="${flexpmd.dir}/flex-pmd-ruleset-api-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/flex-pmd-ruleset-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/flex-pmd-core-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/as3-plugin-utils-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/as3-parser-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/pmd-${pmd.version}.jar"/> <pathelement location="${flexpmd.dir}/commons-lang-2.4.jar"/> <pathelement location="${flexpmd.dir}/flex-pmd-files-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/as3-parser-api-${flexpmd.version}.jar"/> <pathelement location="${flexpmd.dir}/plexus-utils-1.0.2.jar"/> </classpath> </taskdef> <taskdef name="flexCpd" classname="com.adobe.ac.cpd.ant.FlexCpdAntTask" classpath="${flexpmd.dir}/flex-pmd-cpd-ant-task-${flexpmd.version}.jar"> <classpath> <pathelement location="${flexpmd.dir}/flex-pmd-files-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/flex-pmd-cpd-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-plugin-utils-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-parser-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-parser-api-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/pmd-${pmd.version}.jar" /> </classpath> </taskdef> <taskdef name="flexMetrics" classname="com.adobe.ac.pmd.metrics.ant.FlexMetricsAntTask" classpath="${flexpmd.dir}/flex-pmd-metrics-ant-task-${flexpmd.version}.jar"> <classpath> <pathelement location="${flexpmd.dir}/flex-pmd-files-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/flex-pmd-metrics-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-plugin-utils-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-parser-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/as3-parser-api-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/commons-lang-2.4.jar" /> <pathelement location="${flexpmd.dir}/flex-pmd-ruleset-api-${flexpmd.version}.jar" /> <pathelement location="${flexpmd.dir}/pmd-4.2.5.jar" /> <pathelement location="${flexpmd.dir}/dom4j-1.6.1.jar"/> </classpath> </taskdef> <target name="clean"> <delete dir="${build.dir}" /> </target> <target name="makedir"> <mkdir dir="${build.dir}" /> <mkdir dir="${swc.dir}" /> <mkdir dir="${asdoc.output.dir}" /> <mkdir dir="${flexpmd.output.dir}" /> </target> <target name="compile" depends="makedir"> <mxmlc file="${APP_ROOT}/${target.file}" output="${build.dir}/${project.name}.swf" locale="en_US" optimize="${swc.optimize}" verbose-stacktraces="${swc.verbose.stacktrace}" show-actionscript-warnings="${swc.show.actionscript.warnings}" show-binding-warnings="${swc.show.binding.warnings}" target-player="${target.player}" debug="${debug.enable}" > <load-config filename="${FLEX_HOME}/frameworks/air-config.xml" /> <compiler.source-path path-element="${APP_ROOT}"/> <compiler.library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true"> <include name="**/*.swc" /> </compiler.library-path> <compiler.library-path dir="${lib.dir}" append="true"> <include name="**/*.swc" /> </compiler.library-path> </mxmlc> </target> <target name="make-swc" depends="makedir"> <compc output="${swc.dir}/${project.name}.${build.current.version}.${build.current.revision}.swc" locale="en_US" optimize="${swc.optimize}" verbose-stacktraces="${swc.verbose.stacktrace}" show-actionscript-warnings="${swc.show.actionscript.warnings}" show-binding-warnings="${swc.show.binding.warnings}" target-player="${target.player}"> <load-config filename="${FLEX_HOME}/frameworks/air-config.xml" /> <include-sources dir="${src.dir}" includes="**/*.as **/*.mxml" /> <compiler.source-path path-element="${APP_ROOT}"/> <external-library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true"> <include name="**/*.swc" /> </external-library-path> <external-library-path dir="${lib.dir}" append="true"> <include name="**/*.swc" /> </external-library-path> </compc> </target> <target name="asdoc" depends="makedir"> <exec executable="${asdoc.exe.path}" failonerror="true"> <arg value="-doc-sources"/> <arg line=""${basedir}/${src.dir}"" /> <arg value="-output" /> <arg line=""${basedir}/${asdoc.output.dir}""/> <arg value="+configname=air"/> <arg value="-source-path"/> <arg line=""${basedir}/${src.dir}"" /> <arg value="-library-path"/> <arg line=""${basedir}/${lib.dir}"" /> </exec> </target> <target name="pmd" depends="makedir"> <flexPmd sourceDirectory="${src.dir}" outputDirectory="${flexpmd.output.dir}"/> <xslt in="${flexpmd.output.dir}/pmd.xml" style="flexpmd/xslt/pmd-report.xslt" out="${flexpmd.output.dir}/pmd.html" /> <xslt in="${flexpmd.output.dir}/pmd.xml" style="flexpmd/xslt/pmd-report-per-class.xslt" out="${flexpmd.output.dir}/pmd-per-class.html" /> </target> <target name="cpd" depends="makedir"> <property name="cpd.src.temp.dir" value="${flexpmd.output.dir}/src" /> <mkdir dir="${cpd.src.temp.dir}" /> <fixcrlf srcdir="${src.dir}" destdir="${cpd.src.temp.dir}" encoding="MS932" outputencoding="UTF-8"> <include name="**/*.as" /> <include name="**/*.mxml"/> </fixcrlf> <flexCpd minimumTokenCount="50" outputFile="${flexpmd.output.dir}/cpd.xml" encoding="UTF-8"> <fileset dir="${cpd.src.temp.dir}"> <include name="**/*.as"/> <include name="**/*.mxml"/> </fileset> </flexCpd> <xslt in="${flexpmd.output.dir}/cpd.xml" style="flexpmd/xslt/cpdhtml.xslt" out="${flexpmd.output.dir}/cpd.html" /> </target> <target name="metrics" depends="makedir"> <!-- Duplicated with cpd --> <property name="cpd.src.temp.dir" value="${flexpmd.output.dir}/src" /> <mkdir dir="${cpd.src.temp.dir}" /> <fixcrlf srcdir="${src.dir}" destdir="${cpd.src.temp.dir}" encoding="MS932" outputencoding="UTF-8"> <include name="**/*.as" /> <include name="**/*.mxml"/> </fixcrlf> <flexMetrics sourcedirectory="${cpd.src.temp.dir}" outputfile="${flexpmd.output.dir}/javancss.xml"/> </target> <target name="certificate"> <java jar="${adt.jar}" fork="true" failonerror="true"> <arg value = "-certificate"/> <arg value = "-cn"/> <arg value = "${name}"/> <arg value = "1024-RSA"/> <arg value = "${keystore.path}"/> <arg value = "${store.password}"/> </java> </target> <target name="package" > <copy file="${root.dir}/application.xml" tofile="${build.dir}/application.xml" encoding="UTF-8" overwrite="true" /> <replaceregexp file="${build.dir}/application.xml" match="<content>.+</content>" replace="<content>${project.name}.swf</content>" encoding="UTF-8" /> <replaceregexp file="${build.dir}/application.xml" match="<id>.+</id>" replace="<id>${project.name}</id>" encoding="UTF-8" /> <replaceregexp file="${build.dir}/application.xml" match="<title>.+</title>" replace="<title>${project.name}</title>" encoding="UTF-8" /> <replaceregexp file="${build.dir}/application.xml" match="<filename>.+</filename>" replace="<filename>${project.name}</filename>" encoding="UTF-8" /> <java jar="${adt.jar}" fork="true" failonerror="true"> <arg value = "-package"/> <arg value = "-storetype"/> <arg value = "${storetype}"/> <arg value = "-keystore"/> <arg value = "${keystore.path}"/> <arg value = "-storepass"/> <arg value = "${store.password}"/> <arg line = "${build.dir}/${project.name}.air"/> <arg line = "${build.dir}/application.xml"/> <arg line = "-C"/> <arg line = "${build.dir}" /> <arg line = "${project.name}.swf" /> </java> </target> <target name="all" description="Execute all targets"> <antcall target="check-requied-program-exists" /> <antcall target="html-report" /> <antcall target="make-swc" /> </target> </project>
This is an example property file.
project.name=DukeSoftwareUtilsAS3 target.file=Main.mxml debug.enable=false store.password=hogehogehoe app.name=DukeSoftwareUtils flexpmd.dir=C:/flex-pmd-all-in-one-bundle-1.2 FLEX_HOME=C:/FlexSDK build.current.version=1 build.current.revision=0
コメント