Compiling Flex Modules Using Ant

I am trying to compile a Flex 4 project using Ant. I can compile the main application, and I can compile some of my modules in order. Any module that has dependencies in a subcomplex does not say Error: Type was not found or was not a compile-time constant. I am doing all my development on Windows using Flash Builder 4, so I can compile everything, but I need to compile to a headless Linux-based server (where Ant is located).

I created a simple project to test my problem:

src-> Main.mxml
 |->modules
       |-> module1-> Module1.mxml
       |-> module2-> Module2.mxml
               |-> subPackage-> SubClass.as

There are no classes in module 1 except Flex classes, where Module2 has an instance of SubClass. Compiling the main application is working fine, as well as Module1. When he tries to compile Module2, I get an error message Error: Type was not found or was not a compile-time constant: SubClass..

My full Ant script:

<project name="Test" basedir=".">

<property file="build.properties" />
<target name="properties">
    <fail unless="mxmlc">The "mxmlc" property must be set in build.properties.</fail>
</target>

<target name="build-app" depends="properties">
    <exec executable="${mxmlc}" dir="${src.dir}" failonerror="true">

        <!-- Point to the mxml file -->
        <arg line="${app.name}.mxml" />

        <!-- Don\t generate debug swf -->
        <arg line="-debug=false" />

        <!-- Generate optimized swf -->
        <arg line="-optimize=true" />

        <!-- Don't build incrementally -->
        <arg line="-incremental=false" />

        <!-- Place the built .swf file in the "bin" directory -->
        <arg line="-output '${build.dir}/${app.name}.swf'" />

        <!--
           Create a linker report that lists all the classes already in the main app
           This gets passed to the modules so that they don't load up the shared libs again.
        -->
        <arg line="-link-report='${temp.dir}/link-report.xml'"/>

    </exec>
</target>

<target name="build-modules" description="Build Modules">
    <build.module dir="${module.dir}/module1" file="Module1"/>
    <build.module dir="${module.dir}/module2" file="Module2"/>
</target>

<macrodef name="build.module">
    <attribute name="dir" />
    <attribute name="file" />
    <sequential>
        <echo>@{file}</echo>
        <exec executable="${mxmlc}" dir="${src.dir}"  failonerror="true">
            <!-- Point to the mxml file -->
            <arg line="'@{dir}/@{file}.mxml'" />

            <!-- Don't generate debug swf -->
            <arg line="-debug=false" />

            <!-- Generate optimized swf -->
            <arg line="-optimize=true" />

            <!-- Don't build incrementally -->
            <arg line="-incremental=false" />

            <!-- Place the built .swf file in the "bin" directory -->
            <arg line="-output '${module.build.dir}/@{file}.swf'" />

            <!-- Exclude all classes that are already in the main application -->
            <arg line="-load-externs='${temp.dir}/link-report.xml'"/>
         </exec>
    </sequential>
</macrodef>

, .

,

-

+3
1

, . ANTs <exec>. , <mxmlc> ANT ( flexTasks.jar Flex SDK ant/lib/flexTasks.jar).

<macrodef name="build.module">
    <attribute name="moduleDir" />
    <attribute name="dir" />
    <attribute name="file" />
    <sequential>
        <echo>@{file}</echo>
        <mxmlc file="@{moduleDir}/@{dir}/@{file}.mxml"
                output='${module.build.dir}/@{dir}/@{file}.swf' 
                optimize="true" 
                debug="false" 
                load-externs="${temp.dir}/link-report.xml" 
                incremental="false"
                fork="true" maxmemory="${maxMem}">
            <compiler.source-path path-element="${src.dir}"/>
            <source-path path-element="${FLEX_HOME}/frameworks"/>
            <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
                <include name="libs" />
            </compiler.library-path>
            <source-path path-element="${src.dir}"/>
            <compiler.library-path dir="${libs.dir}/" append="true">
                <include name="*" />
            </compiler.library-path>
        </mxmlc>
    </sequential>
</macrodef>

. ( , ) .

+3

Source: https://habr.com/ru/post/1776940/


All Articles