Reducing compilation time of Starling & Feathers projects

idea-starling-feathers

When using Starling together with Feathers I always use the source files instead of precompiled SWCs. Using the source files has a few benefits thanks to which you can:

  • Look under the hood to get an idea of how things work
  • Use the latest version from the GitHub (as the SWCs are not rebuilt after every fix)
  • Make changes to some of the APIs very quickly

None of this is possible if you’re using the precompiled SWCs. On the other hand, project compilation takes a little bit longer. Luckily, if you’re one of the many Starling/Feathers developers who use IntelliJ IDEA then there’s an easy way to achieve faster compilation times while having the ability to browse and edit the sources.

With IntelliJ you can divide your project into multiple modules/build configurations where one can depend on another. This way you can move Starling, Feathers and other libraries out of your core module and avoid their compilation (which isn’t necessary most of the time). To do this, navigate to File > Project Structure and add a new library module as shown in the video below.

IntelliJ will create a new folder (with the module’s name) in your project root. Next, copy and paste the source files of Starling and Feathers into MODULE_NAME/src folder. Finally, add this new module’s build configuration as a dependency to your core module (make sure Starling/Feathers is no longer included anywhere in your core module).

When you build your project for the first time, IntelliJ will create a SWC out of your library configuration so it may take a little longer. It will also rebuild the SWC if you ever change any of the source files included in the library module. Most of the time, however, IntelliJ won’t have to do anything and will go straight to compiling your core module. This reduces compilation time (in my case from around 19 to 11 seconds) while still allows for peeking into sources and making changes when needed.

1 Comment

  1. Look under the hood to get an idea of how things work – works with swc too, you can just add source path in the library properties

Leave a Comment