将Flex构建ant目标转换为gradle。在gradle中运行flex build需要什么?

时间:2016-05-10 00:48:14

标签: java gradle groovy

我正在研究gradle脚本。我对flex构建没有太多了解。我正在尝试将一个ant目标转换为gradle,但由于对flex的了解不多,我不知道如何实现这一目标?这个蚂蚁目标在linux平台上工作正常,但gradle无法正常工作

Ant Target

<target name="adminClient">
<if name="build.flash" value="true">
<echo message="mxmlc.exe ${mxmlc.exe}"/>
<echo message="Building AdminClient.swf"/>
<exec executable="${mxmlc.exe}" dir="${basedir}" failonerror="true">
<arg line="'${adminClient.src.module}'"/>
<arg line="-load-config='${build.dir}/ozswfconfig.xml'"/>
<arg line="-load-config+='${build.dir}/license.xml'"/>
<arg line="-output '${package.dir}/AdminClient.swf'"/>
<arg line="-library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'"/>
<arg line="-library-path+='${flexCommon.lib}'"/>
<arg line="-source-path '${adminClient.src.dir}'"/>
</exec>
<!--  build each tab separatley for new ui  -->
<exec executable="${mxmlc.exe}" dir="${basedir}" failonerror="true">
<arg line="'${adminClient.src.dir}/ConfigurationApp.mxml'"/>
<arg line="-load-config='${build.dir}/ozswfconfig.xml'"/>
<arg line="-load-config+='${build.dir}/license.xml'"/>
<arg line="-output '${package.dir}/ConfigurationApp.swf'"/>
<arg line="-library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'"/>
<arg line="-library-path+='${flexCommon.lib}'"/>
<arg line="-source-path '${adminClient.src.dir}'"/>
<exec executable="${mxmlc.exe}" dir="${basedir}" failonerror="true">
<arg line="'${adminClient.src.dir}/LargeResultsApp.mxml'"/>
<arg line="-load-config='${build.dir}/ozswfconfig.xml'"/>
<arg line="-load-config+='${build.dir}/license.xml'"/>
<arg line="-output '${package.dir}/LargeResultsApp.swf'"/>
<arg line="-library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'"/>
<arg line="-library-path+='${flexCommon.lib}'"/>
<arg line="-source-path '${adminClient.src.dir}'"/>
</exec>
</if>
</target>

我以下面的方式尝试使用gradle脚本,但它无法正常工作

task adminClient(dependsOn: prepConfigs) {
    println "mxmlc.exe ${mxmlcexe}"
    exec {
        workingDir = file("${projectDir}")
        executable "${mxmlcexe}"
        args ["${adminClientsrcModule}", "-load-config='${Folderdir}/ozswfconfig.xml", "-load-config+='${Folderdir}/license.xml", "-output '${packageDir}/AdminClient.swf", "-library-path+='${externallibDir}/PureMVC_AS3_MultiCore_1_0_4.swc", "-library-path+='${flexCommonLib}", "-source-path '${adminClientsrcDir}"]
   }
    exec {
        workingDir = file("${projectDir}")
        executable "${mxmlcexe}"
        args "${adminClientsrcDir}/ConfigurationApp.mxml", "-load-config='${Folderdir}/ozswfconfig.xml", "-load-config+='${Folderdir}/license.xml", "-output '${packageDir}/ConfigurationApp.swf", "-library-path+='${externallibDir}/PureMVC_AS3_MultiCore_1_0_4.swc", "-library-path+='${flexCommonLib}", "-source-path '${adminClientsrcDir}"
   exec {
        workingDir = file("${projectDir}")
        executable "${mxmlc.exe}"
        args "${adminClientsrcDir}/LargeResultsApp.mxml", "-load-config='${Folderdir}/ozswfconfig.xml", "-load-config+='${Folderdir}/license.xml", "-output '${packageDir}/LargeResultsApp.swf", "-library-path+='${externallibDir}/PureMVC_AS3_MultiCore_1_0_4.swc", "-library-path+='${flexCommonLib}", "-source-path '${adminClientsrcDir}"
   }

  }

如果我需要使用任何插件来构建flex或者如何以正确的方式将此ant目标转换为gradle,有人可以告诉我吗?

1 个答案:

答案 0 :(得分:1)

使用隐式Ant Builder对Gradle进行机械转换,如下所示:

task adminClient() << {
    // look for -Dbuild.flash on command-line
    def buildFlash = ant.properties['build.flash']

    if (buildFlash) {
        ant.echo(message: "Building AdminClient.swf")

        ant.exec(executable: "{mxmlc.exe}", dir: "${basedir}", failonerror: "true") {
            arg(line: " '${adminClient.src.module}'")
            arg(line: " -load-config='${build.dir}/ozswfconfig.xml'")
            arg(line: " -load-config+='${build.dir}/license.xml'")
            arg(line: " -output '${package.dir}/AdminClient.swf'")
            arg(line: " -library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'")
            arg(line: " -library-path+='${flexCommon.lib}'")
            arg(line: " -source-path '${adminClient.src.dir}'")
        }
    } else {
        // build each tab separatley for new ui 
        ant.exec(executable: "${mxmlc.exe}", dir: "${basedir}", failonerror: "true") {
            arg(line: " '${adminClient.src.dir}/ConfigurationApp.mxml'")
            arg(line: " -load-config='${build.dir}/ozswfconfig.xml'")
            arg(line: " -load-config+='${build.dir}/license.xml'")
            arg(line: " -output '${package.dir}/ConfigurationApp.swf'")
            arg(line: " -library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'")
            arg(line: " -library-path+='${flexCommon.lib}'")
            arg(line: " -source-path '${adminClient.src.dir}'")
        }

        ant.exec(executable: "${mxmlc.exe}", dir: "${basedir}", failonerror: "true") {
            arg(line: "'${adminClient.src.dir}/LargeResultsApp.mxml'")
            arg(line: " -load-config='${build.dir}/ozswfconfig.xml'")
            arg(line: " -load-config+='${build.dir}/license.xml'")
            arg(line: " -output '${package.dir}/LargeResultsApp.swf'")
            arg(line: " -library-path+='${external.lib.dir}/PureMVC_AS3_MultiCore_1_0_4.swc'")
            arg(line: " -library-path+='${flexCommon.lib}'")
            arg(line: " -source-path '${adminClient.src.dir}'")
        }
     }
 }

}

只要各种变量(例如${build.dir}${flexCommon.lib})被整理出来,这样的东西就应该有效。我以build.flash为开头说明了一个例子。