ant および flex SDK を使用した mxml ファイルのコンパイル
-
09-06-2019 - |
質問
私は flex を使い始めたばかりで、(Flex Builder ではなく) SDK を使用しています。ant ビルド スクリプトから mxml ファイルをコンパイルする最良の方法は何だろうと考えていました。
解決
Flex SDK には、一連の ant タスクが付属しています。詳細については、次をご覧ください。
http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html
以下は、Ant を使用して Flex SWC をコンパイルする例です。
http://www.mikechambers.com/blog/2006/05/19/example-using-ant-with-compc-to-compile-swcs/
マイク・チャンバー
他のヒント
私は間違いなく Flex に含まれる Ant タスクを使用するでしょう。これにより、ビルド スクリプトが非常にクリーンになります。これは、フレックス プロジェクトをコンパイルして実行するサンプル ビルド スクリプトです。
<?xml version="1.0"?>
<project name="flexapptest" default="buildAndRun" basedir=".">
<!--
make sure this jar file is in the ant lib directory
classpath="${ANT_HOME}/lib/flexTasks.jar"
-->
<taskdef resource="flexTasks.tasks" />
<property name="appname" value="flexapptest"/>
<property name="appname_main" value="Flexapptest"/>
<property name="FLEX_HOME" value="/Applications/flex_sdk_3"/>
<property name="APP_ROOT" value="."/>
<property name="swfOut" value="dist/${appname}.swf" />
<!-- point this to your local copy of the flash player -->
<property name="flash.player" location="/Applications/Adobe Flash CS3/Players/Flash Player.app" />
<target name="compile">
<mxmlc file="${APP_ROOT}/src/${appname_main}.mxml"
output="${APP_ROOT}/${swfOut}"
keep-generated-actionscript="true">
<default-size width="800" height="600" />
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.library-path dir="${APP_ROOT}/libs" append="true">
<include name="*.swc" />
</compiler.library-path>
</mxmlc>
</target>
<target name="buildAndRun" depends="compile">
<exec executable="open">
<arg line="-a '${flash.player}'"/>
<arg line="${APP_ROOT}/${swfOut}" />
</exec>
</target>
<target name="clean">
<delete dir="${APP_ROOT}/src/generated"/>
<delete file="${APP_ROOT}/${swfOut}"/>
</target>
</project>
別のオプションがあります - それはと呼ばれます プロジェクトスプラウト.
これは、Ruby、RubyGems、Rake で構築されたシステムで、Maven や ANT にある多くの機能を提供しますが、よりクリーンな構文とシンプルなビルド スクリプトを備えています。
たとえば、上に示した ANT スクリプトは、Sprouts では次のようになります。
require 'rubygems'
require 'sprout'
desc 'Compile and run the SWF'
flashplayer :run => 'bin/SomeProject.swf'
mxmlc 'bin/SomeProject.swf' do |t|
t.input = 'src/SomeProject.as'
t.default_size = '800 600'
t.default_background_color = '#ffffff'
t.keep_generated_actionscript = true
t.library_path << 'libs'
end
task :default => :run
Ruby と RubyGems をインストールした後は、次のようにしてこのスクリプトを呼び出すだけです。
rake
生成されたファイルを削除するには、次を実行します。
rake clean
利用可能なタスクを確認するには:
rake -T
Sprouts のもう 1 つの大きな利点は、インストールすると、いくつかの簡単なコマンド ライン アクションで開発ボックスを実行できるようにするプロジェクト、クラス、およびテスト ジェネレーターが提供されることです。
# Generate a project and cd into it:
sprout -n mxml SomeProject
cd SomeProject
# Compile and run the main debug SWF:
rake
# Generate a new class, test case and test suite:
script/generate class utils.MathUtil
# Compile and run the test harness:
rake test