|
1 | | -This is just a reference for setting up a new Java project. It |
2 | | -contains some of the little Ant tricks I've learned. |
| 1 | +This is a reference for setting up a new Ant-based Java project. It |
| 2 | +contains most of the little Ant tricks I've learned over the |
| 3 | +years. When I start a new Java project I clone this repository, remove |
| 4 | +sections of build.xml that I don't care about for that particular |
| 5 | +project, set the project properties, clear out the sample sources, and |
| 6 | +get to work. |
3 | 7 |
|
4 | 8 | Building this project requires that Ivy be available to Ant. All you |
5 | 9 | need is ivy.jar in Ant's classpath (in your $CLASSPATH, $ANT_HOME/lib, |
@@ -9,33 +13,44 @@ You will need to have Astyle installed and in your path for the |
9 | 13 | "format" target to work. If it's missing, that's fine. It won't affect |
10 | 14 | any other targets. |
11 | 15 |
|
12 | | -Ant will be looking for Checkstyle, which provides the "check" |
13 | | -target. Except the extra target, I think it should work without |
14 | | -it. Like a hardcore bureaucrat, Checkstyle will harshly criticize your |
15 | | -code, requiring you to add every bit of excessive and needless |
16 | | -boilerplate. That can keep some idle hands pretty busy. |
| 16 | +Ant will be looking for Checkstyle if you try to use the "check" |
| 17 | +target. Like a hardcore bureaucrat, Checkstyle will harshly criticize |
| 18 | +any stylistic mistakes and missing documentation, requiring you to dot |
| 19 | +every "i" and cross every "t". That can keep idle hands pretty busy. |
17 | 20 |
|
18 | | -Ant will be looking for ProGuard, which provides the "optimize" |
19 | | -target. You should still be able to build the project without it. Only |
20 | | -the "optimize" target will not work. |
| 21 | +Ant will be looking for ProGuard if you try to use the "optimize" |
| 22 | +target. This tool does a bytecode analysis to shorten (and obfuscate) |
| 23 | +identifiers and remove unreachable code. |
21 | 24 |
|
22 | 25 | There is a "hotswap" target for replacing live code while an |
23 | 26 | application is running. You'll need the hotswap Ant extension |
24 | | -installed in Ant's classpath to use it. It's to be used alongside the |
25 | | -"run-hotswap" target, which enables hotswapping in the |
26 | | -JVM. Hotswapping has no practical use in this particular sample |
27 | | -project because it exits immediately. |
| 27 | +installed to use it. This target is to be used alongside the |
| 28 | +"run-hotswap" target, which enables hotswapping in the JVM. You can |
| 29 | +demo this for yourself by running "run-hotswap" in a terminal, editing |
| 30 | +the printed string in the code, and running "hotswap" in another |
| 31 | +terminal. The printed message in the running program should change to |
| 32 | +the new string. |
28 | 33 |
|
29 | | -Note that ProGuard and Checkstyle are needed only in the build |
30 | | -classpath, not your project's classpath. That means you probably don't |
31 | | -want them in lib/. Like Ivy, they should be where Ant can get to them. |
| 34 | +Note that ProGuard, hotswap, Ivy, and Checkstyle are needed only in |
| 35 | +the build classpath, not your project's classpath. That means you |
| 36 | +probably don't want them in lib/. They should be where Ant can get to |
| 37 | +them, not your project. |
| 38 | + |
| 39 | +Take note of the sample pom.xml file. This is not actually for Maven |
| 40 | +builds -- this is an Ant project afterall -- but for publishing builds |
| 41 | +for a Maven repository. It's packed up by the "bundle" target, which |
| 42 | +creates a bundle.jar containing your project's signed artifacts. To |
| 43 | +use the "bundle" target you need to have GnuPG set up in your path, a |
| 44 | +generated key pair, and a running gpg-agent, unless you like typing |
| 45 | +your passphrase a bunch of times in a row. |
32 | 46 |
|
33 | 47 | I hate coding absolute paths in my build script and I hate including |
34 | 48 | built files as part of the base project. My philosophy is that the |
35 | 49 | *environment* should be set up so that the tool can easily find the |
36 | 50 | external resources they need (JUnit, etc.) from the system, not within |
37 | | -the project. It's the system that provides the libraries. Anyone who |
38 | | -has the proper development environment set up -- one that carries |
39 | | -across many projects -- should be able to clone the repository and do |
40 | | -the build without editing anything or installing anything else into |
41 | | -the project space. |
| 51 | +the project. It's the system or dependency manager that provides the |
| 52 | +libraries. Anyone who has the proper development environment set up -- |
| 53 | +one that works across many projects -- should be able to clone the |
| 54 | +repository and do a build simply by running the build program with no |
| 55 | +special arguments. There should be no need to edit or install anything |
| 56 | +into the project space for the initial build. |