Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Dr. Ant, or How I learned to stop worrying and love the build process

Sign in to follow this  


If theres been one thing I've been particularly bad at with previous games, its the build process. Sure the day-to-day compiling and running has been easy[1] from within Eclipse, but when it comes to packaging so other people can play them I've always had things held together with sticky tape.

With Quix[2] I made half an attempt, making a bunch of batch files to jar up and sign all my code and resources. However there were a number of problems with this:

- No single-click 'build all' script, no concept of dependancies (all done by me remembering/guessing)
- Lots of hard-coded paths
- Everything done manually (ie. every operation added by hand)
- Inconsistent loading methods and use of paths in my code
- Far too many jars (largely caused by the previous)

So I've moved over to using Ant (which runs inside of Eclipse with a single click) for the whole thing. Firstly I've added a 'build all' and Ant makes doing dependancies easy. Ant's 'properties' makes removing hardcoded paths easy too. With some poking around in the (rather good actually) Ant docs I can set file sets and avoid having to do lots of manual operations - signing of jars happens automatically after I've added the jar creation.

That was the 'build' half, the second was to clean up the code side of things to get it all more consistant. First I restructured my dirs, which now has 3 main sub dirs: 'Data' holds raw data which is loaded directly (such as hand-crafted xml). 'SourceData' is stuff like images that are compiled into a different form during the build process. 'CompiledData' is the result of this compilation, and is also loaded at runtime. I can now delete the entire compiled dir safe in the knowledge that it can all be rebuilt - and I'm not loosing any manually created files. Likewise I can be sure that nothing in SourceData needs to be included in the distribution.

Better, I reworked my loading code to always load from the classpath. Data and SourceData are in the classpath, and everything else is relative from there this means that I need only include two dirs in my classpath config (instead of the 8ish I had before when most things weren't relative) and the jar'ed up version looks identical - just instead of two dirs I get two jars, complete with the relative file structure within them. Again, this consitancy means the Ant build gets even simpler than before. [grin]

All in all a quite sucessful tranformation. Minimal code changes (a few paths here and there, one small change to a resource compiler) but lots more clarity and ease of use.

For no good reason than I like the result, heres what happens when I use the magical build button now:

Buildfile: F:\My Stuff\Code\Shooty Prototype\build.xml
[jar] Building jar: F:\My Stuff\Code\Shooty Prototype\Build\SkeletonCreator.jar
[jar] Building jar: F:\My Stuff\Code\Shooty Prototype\Build\SPGL.jar
[jar] Building jar: F:\My Stuff\Code\Shooty Prototype\Build\SPGLExtra.jar
[jar] Building jar: F:\My Stuff\Code\Shooty Prototype\Build\lwjgl_Win32.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\CompiledData.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\Data.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\SPGL.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\SPGLExtra.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\Shooty.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\SkeletonCreator.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\lwjgl.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\lwjgl_Win32.jar
[signjar] Signing JAR: F:\My Stuff\Code\Shooty Prototype\Build\lwjgl_util.jar
Total time: 14 seconds

Very nice.

[1] Very easy in fact, such is the joy that is Eclipse I don't ever have to manually compile, it all just happens in the background. Never a problem with a faulty build or a missing dependancy, and even a total rebuild (should I for some strange reason force one for curiosity) takes no longer than about 20 seconds.

[2] More on this later, but the Win32 version is now back up and running and available from OrangyTang.net
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!