01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

habits <strong>of</strong> good build scripts<br />

Good build scripts...<br />

A build script captures the details that developers probably don’t need to know right<br />

from the start about how to compile and package an application, like BeatBox. The<br />

information isn’t trapped in one person’s head; it’s captured in a version-controlled,<br />

repeatable process. But what exactly should a standard build script do?<br />

...generate documentation<br />

Remember those description tags in the<br />

build file? Just type ant -projecthelp<br />

and you’ll get a nice printout <strong>of</strong> what<br />

targets are available, a description <strong>of</strong> each,<br />

and what the default target is (which is<br />

usually what you want to use).<br />

...compile your project<br />

Most importantly, your build scripts compile the code in your project. And in most scripts, you want a<br />

single command that you can run to handle everything, from setup to compilation to packaging.<br />

Here you can<br />

see the target<br />

dependencies in<br />

action: our build<br />

script tells<br />

Ant to run the<br />

dist target by<br />

default, but<br />

in order to do<br />

that, it has to<br />

run compile, and<br />

in order to do<br />

that, it has to<br />

run init.<br />

Your build tool probably has a way<br />

to generate documentation about<br />

itself and your project, even if<br />

you’re not using Ant and Java.<br />

228 Chapter 6 ½<br />

File Edit Window Help Build<br />

hfsd> ant<br />

Buildfile: build.xml<br />

You’ll probably add tasks to your own<br />

build scripts, but all build scripts<br />

should do a few common things...<br />

init:<br />

[mkdir] Created dir: C:\Users\Developer\workspaces\HFSD\BeatBox\bin<br />

[mkdir] Created dir: C:\Users\Developer\workspaces\HFSD\BeatBox\dist<br />

compile:<br />

[javac] Compiling 4 source files to C:\Users\Developer\workspaces\HFSD\BeatBox\bin<br />

dist:<br />

[jar] Building jar: C:\Users\Developer\workspaces\HFSD\BeatBox\dist\BeatBox.jar<br />

BUILD SUCCESSFUL<br />

Total time: 16 seconds<br />

hfsd><br />

File Edit Window Help Huh?<br />

hfsd> ant -projecthelp<br />

Buildfile: build.xml<br />

Main targets:<br />

clean Cleans up the build and dist directories.<br />

compile Compiles the source files to the bin directory.<br />

dist Packages up BeatBox into BeatBox.jar<br />

init Creates the needed directories.<br />

Default target: dist<br />

hfsd><br />

Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!