Package .swf for multiple target?

wenslayer's Avatar

wenslayer

15 Apr, 2015 04:14 AM

I'm trying to figure out how to package our .swf for multiple targets (AIR, Mobile (Android & iOS)), but I can't seem to figure out how to do this properly. I tried creating separate projects with different platforms and targets, but it seems to want to compile a swf there. I want to compile the AIR swf once, and then repackage it in different forms.

Any advice or suggestions to consider? Thanks for your help!

  1. 1 Posted by wenslayer on 17 Apr, 2015 06:33 PM

    wenslayer's Avatar

    I can get close to what I'm looking for by creating a subproject of 'mobile' type, disable compileFlex, set the buildDir to the parent project's buildDir location, and pull in the air configuration from the parent (in addition to setting an airMobile config block); however without being able to configure (override) the name of the .swf file that gets pulled into the package, I have to name the subproject the same as the parent, which imposes unreasonable project hierarchy & naming constraints.

    If I could configure the path of the .swf file that gets pulled in, that would certainly help; I may look at exposing that and proposing a PR for it.

    Generally though, working with packages doesn't feel as natural as it should. Is it necessary to use different task names for packaging (package vs packageMobile) between .air and mobile targets? Ideally, I'd like to declare the different packaging configurations for a single project and build them all, but I could live with using different projects if I can easily configure them so.

    Curious to hear additional thoughts on this approach. Thanks!

  2. 2 Posted by wenslayer on 17 Apr, 2015 08:02 PM

    wenslayer's Avatar

    It appears that in BaseAirMobilePackage.groovy we are overloading the meaning of 'project.output' to indicate the name of the .swf file used as input to packaging.

    Conventionally, that's fine, but breaks in my case where I want to pull in a .swf from another project (with different name). I'll see about exposing 'mainSwfName' that can be used in conjunction with mainSwfDir.

  3. 3 Posted by wenslayer on 17 Apr, 2015 09:15 PM

    wenslayer's Avatar

    Turns out I can additionally set the output property to the parent project's, and it will do what I want: package up the .swf into an .ipa and put it in the parent's build directory.

    Separately, it appears that the packaging tasks do not declare their outputs, so the package will be repeatedly built even if it's already up to date. I'll file a GitHub issue about it.

  4. 4 Posted by wenslayer on 17 Apr, 2015 10:51 PM

    wenslayer's Avatar

    (GitHub issue filed)

  5. Support Staff 5 Posted by Yennick Trevels on 19 Apr, 2015 08:43 AM

    Yennick Trevels's Avatar

    I think you're approach is good, I don't see a better way to accomplish this any other way right now.
    I agree that it isn't as straightforward as you want it to be, but keeping the one artifact per build/project is still good practice.

    You're probably right about the package vs packageMobile task names, this could get simplified to only having the package task. I've filed an issue for it so we can keep track of this suggestion: https://github.com/GradleFx/GradleFx/issues/178

  6. 6 Posted by wenslayer on 23 Apr, 2015 12:51 AM

    wenslayer's Avatar

    After working with this for a couple days, this workaround isn't going to meet our needs. You see, we package different kinds of iOS and Android packages (an official one, destined for the App/Play Store, and other debug and interpreter-enabled variants). Because they all have the same extension (.ipa, .apk), they would clobber each other when writing to the same parent.buildDir (where the input .swf file lives).

    Complicating matters, the application descriptor expects the .swf file to be named exactly, but I need to be able to rename the resulting package file; thus, I need to specify a different name for the input .swf and a different output name. The current approach is fixed to use project.output name for both. (Yeah yeah, I could have a post-package task to rename the artifact...)

    In essence, I need to be able to specify the input .swf used for packaging. It simply makes sense in terms of structuring projects to consume artifacts from another project. I'm not sure what the best way to do this is -- the easiest might be to expose a property in the air property block, such as swfFile that is defaulted to what it is now, "${project.buildDir}/${project.output}.{FlexType.swf}", but allows the user to specify the location.

    A better approach might be to leverage the dependencies block, perhaps for a package configuration? Currently, I manually express a dependency from the packageMobile task to the parent project's compileFlex task so this approach is probably the better.

    Any comments or suggestions? -Thanks

  7. 7 Posted by wenslayer on 27 Jul, 2015 04:27 PM

    wenslayer's Avatar

    Just to close the loop on this, I solved this by adding a dependent task to copy the .swf file into the expected place, and a doLast{} block to rename the artifact to the desired name.

  8. wenslayer closed this discussion on 27 Jul, 2015 04:27 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

21 Jun, 2017 06:38 AM
10 Jun, 2017 04:16 PM
24 Mar, 2017 07:10 PM
19 Mar, 2017 04:39 AM
22 Jan, 2017 07:46 AM

 

11 Oct, 2016 01:18 PM
20 Sep, 2016 04:36 PM
06 Sep, 2016 08:05 PM
03 Aug, 2016 11:15 AM
01 Jun, 2016 05:20 PM
03 May, 2016 09:17 PM