Reputation: 490
I have a complex java and flash project using ANT. I converting the project to use gradle instead. Can someone please help in converting the below sample ant target.
<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>
I know this is not in convention. But I can't change the structure bcoz it is a very old project. And I can't have different modules for different SWF or SWC.
Can someone help me achieving the same result using gradleFX gradle plugin
Thanks in advance.
Upvotes: 0
Views: 152
Reputation: 27994
You will likely want to make usage of Gradle's UP-TO_DATE
checks so you'll want to set the TaskInputs
and TaskOutputs
for each task. It would likely look something like
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
This would probably start to get verbose so you might make a custom task so you could do something like
task mxmlc1(type:Mxmlx) {
file = '"./flash/conf/config1.xml'
loadConfig "${FLEX_HOME}/frameworks/flex-config.xml"
loadConfig "/flash/conf/config1.xml"
// etc etc
}
Perhaps someone has even written a gradle plugin to do this for you?
Upvotes: 1