Gradle, Actionscript, Unit Testing and Flash Builder

Recently, Gradle has become my preferred build tool. A week or so ago, I was given the responsibility of migrating our build system and creating a continuous integration environment. I’ve done similar for another department moving to Maven, but my new preferred tool has recently been blessed by corporate and I was given the OK to at least begin experimenting with it for my team’s builds.

GradleFX is the Adobe Flex plugin for Gradle. Its new and somewhat immature, which, when coupled with the ideosyncractic Flash Builder, makes for an interesting time. My goal for this project is to have working unit testing in both Flash Builder and in Gradle. Unfortunately, the two tools together make for a tough build.

Flash Builder does not support .swc (library) projects that have an executable (mxml), so unit tests must be in a separate flash builder project file.

GradleFX does not (appear to) support dependency resolution (yet), so having the unit test project be dependent on the library project isn’t an easy option.

After fighting with it for a few afternoons, the solution is to modify the source code include directories of the test project to include the source code directories of the library project. This does have the unfortunate side effect of compiling those directories twice, but I consider it to be a workable solution.

The project is organised as such:


/ - project root
/build.gradle - master build file that does some configuration injection and inter-module dependencies
/settings.gradle - instructs Gradle which sub-projects to build.
/lib/ - contains the library project to be tested.
/lib/build.gradle - instructs Gradle about specificities of the lib project
/lib/src/main/actionscript/ - source code for the library subproject
/test/build.gradle - instructs Gradle about the specificities of the test project
/test/src/test/actionscript/ - source code for the tests
/test/src/main/actionscript/ - test driver

The parent module. This is at the root of the project path.

Gradle requires a second configuration file (settings.gradle) to instruct it which sub-projects to build. This is also at the root of the project path.

The library (swc) module.

The test (swf) module.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s