apache-flex 使用GradleFX插件将多个ant mxmlc目标转换为gradle

yi0zb3m4  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(98)

我有一个复杂的java和flash项目使用蚂蚁。我转换项目使用gradle代替。有人可以请帮助转换下面的样本蚂蚁目标。

<target name="compile-flash">

    <mxmlc file="./flash/src/com/test/Some1.as" output="${build.dir}/flash/Some1.swf" debug="${flash.debug}" fork="true" maxmemory="512m">
        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
        <load-config filename="./flash/conf/config1.xml" />
    </mxmlc>

    <mxmlc file="./flash/src/com/test/editor/Some2.as" output="${build.dir}/flash/Some2.swf" debug="${flash.debug}" fork="true" maxmemory="512m">
        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
        <load-config filename="./flash/conf/config2.xml" />
    </mxmlc>

    <mxmlc file="${build.dir}/flashtest/flexunitapplication.mxml" output="${build.dir}/flashtest/FlexUnitApplication.swf" debug="true" fork="true">
        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
        <load-config filename="flash/test/flexunit-config.xml" />
        <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
            <include name="libs" />
        </compiler.library-path>
        <compiler.library-path dir="${test.lib.dir}" append="true">
            <include name="swc"/>
        </compiler.library-path>
        <compiler.library-path dir="flash" append="true">
            <include name="lib/test" />
            <include name="lib" />
            <include name="bin" />
        </compiler.library-path>
        <compiler.headless-server>true</compiler.headless-server>
        <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
        <compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
    </mxmlc>

    <compc output="${build.dir}/swc/client_api_release.swc" incremental="false" benchmark="false" static-link-runtime-shared-libraries="true" compiler.debug="false" debug="false" compiler.optimize="true" compiler.strict="true" compiler.verbose-stacktraces="false" target-player="11.1.0">
        <include-sources dir="${generated.actionscript.dir}" includes="**/*.as" />
        <compiler.include-libraries dir="${dependencies.lib.dir}/swc/" append="true">
            <include name="*.swc" />
            <exclude name="*debug*.swc" />
        </compiler.include-libraries>
        <external-library-path file="${FLEX_HOME}/frameworks/libs/framework.swc" append="true"/>
    </compc>
</target>

我知道这不是惯例。但我不能改变结构,因为这是一个非常老的项目。我不能有不同的SWF或SWC不同的模块。

有人能帮助我使用gradleFX gradle插件实现同样的结果吗

先谢谢你。

ioekq8ef

ioekq8ef1#

您可能希望使用Gradle的UP-TO_DATE检查,因此您可能希望为每个任务设置TaskInputsTaskOutputs

apply plugin: 'base'

task compileFlash {}

task mxmlc1 {
    inputs.file 'flash/src/com/test/Some1.as'
    inputs.file '${FLEX_HOME}/frameworks/flex-config.xml'
    inputs.file 'flash/conf/config1.xml'
    outputs.file "${build.dir}/flash/Some1.swf"
    doLast {
        ant.mxmlc(
            file:"flash/src/com/test/Some1.as", 
            output:"${build.dir}/flash/Some1.swf",
            debug="${flash.debug}",
            fork="true",
            maxmemory="512m"
        ) {
            'load-config'(filename:"${FLEX_HOME}/frameworks/flex-config.xml")
            'load-config'(filename:"./flash/conf/config1.xml")
        }
    }
}

task mxmlc2 { ... }
task mxmlc3 { ... }

compileFlash.dependsOn [mxmlc1, mxmlc2, mxmlc3, ...]

compile.dependsOn compileFlash

这可能会开始变得冗长,因此您可以创建一个自定义任务,以便可以执行以下操作

task mxmlc1(type:Mxmlx) {
    file = '"./flash/conf/config1.xml'
    loadConfig "${FLEX_HOME}/frameworks/flex-config.xml"
    loadConfig "/flash/conf/config1.xml"
    // etc etc
}

也许有人甚至写了一个gradle插件来为你做这件事?

相关问题