2006-11-03

ant Flex compilação

Resolvi agilizar as compilações MXML utilizando ant, e busquei na web alguma solução, e a mais interessante que encontrei foi a desenvolvida por Paul BH, que publicou uma sequência sobre o assunto.

Continuous Integration with Flex - Introduction
Continuous Integration with Flex - Part 1
Continuous Integration with Flex - Part 2
Continuous Integration with Flex - Part 3
Continuous Integration with Flex - Part 4
title="arquivo"Continuous Integration with Flex - Part 5
Continuous Integration with Flex - Part 6

Ainda preciso instalar os jar para testar o python que ele desenvolveu, então ai vai o meu build.xml e o build.properties


#mxml
main.mxml.source=flex_labs_wsdl
primeiro.mxml.source=labs_xml_wsdl_1
segundo.mxml.source=labs_xml_wsdl_2
terceiro.mxml.source=labs_xml_wsdl_3
n.mxml.source=labs_xml_wsdl_n
#
main.swf.name=index
#
dir.src=/var/www/flex_labs/flex_xml_wsdl_1
dir.template=${dir.src}/html-template
dir.output=${dir.src}/bin
dir.flex=/opt/Flex2
dir.frameworks=${dir.flex}/frameworks
dir.mxmlc=${dir.flex}/lib
#
browser=/usr/bin/firefox



<?xml version="1.0"?>
<project name="myProject" basedir="." default="all">

<!-- carrega as propriedades -->
<property file="build.properties" />

<!-- executa todas as compilações e carrega a aplicação main -->
<target name="all" depends="compileN,compilePrimeiro,compileMain,runMain"/>

<!-- remove todas as compilações -->
<target name="clean">
<delete file="${dir.output}/${main.mxml.source}.swf" />
<delete file="${dir.output}/${main.mxml.source}.html" />
<delete file="${dir.output}/${primeiro.mxml.source}.swf" />
<delete file="${dir.output}/${primeiro.mxml.source}.html" />
<delete file="${dir.output}/${n.mxml.source}.swf" />
<delete file="${dir.output}/${n.mxml.source}.html" />
</target>

<target name="run" depends="compileN,compilePrimeiro,compileMain">
<exec executable="${browser}" spawn="no" >
<arg line="'${dir.output}/${n.mxml.source}.html'"/>
<arg line="'${dir.output}/${primeiro.mxml.source}.html'"/>
<arg line="'${dir.output}/${main.mxml.source}.html'"/>
</exec>
</target>


<!-- arquivo main -->

<!-- compila main -->
<target name="compileMain">
<!-- remove compilação -->
<delete file="${dir.output}/${main.mxml.source}.swf" />
<delete file="${dir.output}/${main.mxml.source}.html" />
<!-- nova compilação -->
<java jar="${dir.mxmlc}/mxmlc.jar" fork="true" failonerror="true" >
<arg line="-load-config '${dir.frameworks}/flex-config.xml'"/>
<arg line="-output '${dir.output}/${main.swf.name}.swf'"/>
<arg line="'${dir.src}/${main.mxml.source}.mxml'"/>
</java>
<!-- prepara cópia -->
<copy todir="${dir.output}">
<fileset dir="${dir.template}" casesensitive="yes">
<include name="**/*.*"/>
<exclude name="**/index.template.html" />
</fileset>
</copy>
<!-- atribuição de valores requeridos no template -->
<property name="title" value="" />
<property name="version_major" value="9" />
<property name="version_minor" value="0" />
<property name="version_revision" value="0" />
<property name="width" value="100%" />
<property name="height" value="100%" />
<property name="application" value="${main.mxml.source}" />
<property name="bgcolor" value="#ffffff" />
<property name="swf" value="${main.mxml.source}" />
<!-- copia -->
<copy file="${dir.template}/index.template.html" tofile="${dir.output}/${main.mxml.source}.html">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>

<!-- carrega main no browser -->
<target name="runMain" depends="compileMain">
<exec executable="${browser}" spawn="no" >
<arg line="'${dir.output}/${primeiro.mxml.source}.html'"/>
</exec>
</target>


<!-- arquivo primeiro -->

<!-- compila primeiro -->
<target name="compilePrimeiro">
<!-- remove compilação -->
<delete file="${dir.output}/${primeiro.mxml.source}.swf" />
<delete file="${dir.output}/${primeiro.mxml.source}.html" />
<!-- nova compilação -->
<java jar="${dir.mxmlc}/mxmlc.jar" fork="true" failonerror="true" >
<arg line="-load-config '${dir.frameworks}/flex-config.xml'"/>
<arg line="-output '${dir.output}/${primeiro.mxml.source}.swf'"/>
<arg line="-file-specs '${dir.src}/${primeiro.mxml.source}.mxml'"/>
</java>
<!-- prepara cópia -->
<copy todir="${dir.output}">
<fileset dir="${dir.template}" casesensitive="yes">
<include name="**/*.*"/>
<exclude name="**/index.template.html" />
</fileset>
</copy>
<!-- atribuição de valores requeridos no template -->
<property name="title" value="" />
<property name="version_major" value="9" />
<property name="version_minor" value="0" />
<property name="version_revision" value="0" />
<property name="width" value="100%" />
<property name="height" value="100%" />
<property name="application" value="${primeiro.mxml.source}" />
<property name="bgcolor" value="#ffffff" />
<property name="swf" value="${primeiro.mxml.source}" />
<!-- copia -->
<copy file="${dir.template}/index.template.html" tofile="${dir.output}/${primeiro.mxml.source}.html">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>

<!-- carrega primeiro no browser -->
<target name="runPrimeiro" depends="compilePrimeiro">
<exec executable="${browser}" spawn="no" >
<arg line="'${dir.output}/${primeiro.mxml.source}.html'"/>
</exec>
</target>



<!-- arquivo n -->

<!-- compila n -->
<target name="compileN">
<!-- remove compilação -->
<delete file="${dir.output}/${n.mxml.source}.swf" />
<delete file="${dir.output}/${n.mxml.source}.html" />
<!-- nova compilação -->
<java jar="${dir.mxmlc}/mxmlc.jar" fork="true" failonerror="true" >
<arg line="-load-config '${dir.frameworks}/flex-config.xml'"/>
<arg line="-output '${dir.output}/${n.mxml.source}.swf'"/>
<arg line="-file-specs '${dir.src}/${n.mxml.source}.mxml'"/>
</java>
<!-- prepara cópia -->
<copy todir="${dir.output}">
<fileset dir="${dir.template}" casesensitive="yes">
<include name="**/*.*"/>
<exclude name="**/index.template.html" />
</fileset>
</copy>
<!-- atribuição de valores requeridos no template -->
<property name="title" value="" />
<property name="version_major" value="9" />
<property name="version_minor" value="0" />
<property name="version_revision" value="0" />
<property name="width" value="100%" />
<property name="height" value="100%" />
<property name="application" value="${n.mxml.source}" />
<property name="bgcolor" value="#ffffff" />
<property name="swf" value="${n.mxml.source}" />
<!-- copia -->
<copy file="${dir.template}/index.template.html" tofile="${dir.output}/${n.mxml.source}.html">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>

<!-- carrega primeiro no browser -->
<target name="runN" depends="compileN">
<exec executable="${browser}" spawn="no" >
<arg line="'${dir.output}/${n.mxml.source}.html'"/>
</exec>
</target>

</project>


E a execução ant fica assim.
Buildfile: /var/www/flex_labs/flex_xml_wsdl_1/build.xml
compileN:
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_n.swf
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_n.html
[java] Loading configuration file /opt/Flex2/frameworks/flex-config.xml
[java] /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_n.swf (225094 bytes)
[copy] Copying 1 file to /var/www/flex_labs/flex_xml_wsdl_1/bin
compilePrimeiro:
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_1.swf
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_1.html
[java] Loading configuration file /opt/Flex2/frameworks/flex-config.xml
[java] /var/www/flex_labs/flex_xml_wsdl_1/bin/labs_xml_wsdl_1.swf (225074 bytes)
[copy] Copying 1 file to /var/www/flex_labs/flex_xml_wsdl_1/bin
compileMain:
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/flex_labs_wsdl.swf
[delete] Deleting: /var/www/flex_labs/flex_xml_wsdl_1/bin/flex_labs_wsdl.html
[java] Loading configuration file /opt/Flex2/frameworks/flex-config.xml
[java] /var/www/flex_labs/flex_xml_wsdl_1/bin/index.swf (115391 bytes)
[copy] Copying 1 file to /var/www/flex_labs/flex_xml_wsdl_1/bin
runMain:
[exec]
all:
BUILD SUCCESSFUL
Total time: 55 seconds

Nenhum comentário: