build

How to turn a list of jar files into an Ant classpath string

Summary: Using a list of jar files to create a dynamic classpath to write to a manifest file in an Ant build script.

In this tutorial I'd like to demonstrate how to convert a list of jar files in a standard lib directory into a classpath string you can use to define a manifest file in an Ant build script. By converting this list of jar files into a classpath string, the build process for your jar file can depend on any number of external jar files, and you can create this classpath dynamically.

Java - Build an executable jar file by referencing your dependencies

Summary: How to build an executable jar file that has dependencies on other jar files.

If you ever need to create an executable jar file that has dependencies on other jar files, this tutorial is for you. I'll show you ever thing you need to do -- including the use of an Ant build script -- so your users can just type something like this at the command line:

java -jar my-application.jar

to run your Java application.

How to make an Ant script fail gracefully if a property file doesn't exist

Wow, I just realized that until this morning I hadn't done anything new with Ant in several months. It sure is nice when things just work. :)

Deploy only your JSP files with this Ant build task

A lot of times when you're working on a Java web application you only need to deploy your JSP files. This happens, for instance, when you're just editing the JSP files to modify the look and feel of your web application. In cases like this there's no need to rebuild your entire application, deploy it, then restart your application server (Tomcat, Glassfish, JBoss, whatever).

Example of the Ant war task (sample Ant build script)

Ant war task example: Here's another snippet of code from my most recent Ant build scripts. This example code shows how I use the Ant war task to create my war file:

Sample Ant clean, prepare, and compile tasks

Summary: An Ant clean, prepare, and compile example.

I'm not going to discuss the following Ant build script code too much, but I thought I would share it here. In short, it shows how I declare several Ant tasks, including my typical clean, prepare, and compile tasks.

Unit tests - documentation you can compile

In the category of best practices I have to include my thoughts today on unit tests as a form of "comments/documentation you can compile". Let me explain:

I recently had the experience of (a) working on a small but complicated software development project, (b) leaving that project for six months, and then (c) being asked to work on it again. All I can say it wow -- what a great experience it was to come back to a project that was loaded with unit and code coverage tests.

My Windows Ant/Tomcat web application build process

I don't like the off-the-shelf process of developing web applications with Ant and Tomcat on Windows computers. Rather than get into my angst, here's the way I think the Ant build process should work with Tomcat:

Debug Ant build problems with echo statements

Ant FAQ: How to use echo commands to debug Ant build scripts.

I've been moving back and forth between a ton of different computers lately -- Mac, Linux, and Windows computers -- and I had some problems with an Ant build script. This particular Ant script is complex, and I kept making mistakes, and needed a good way to debug the build process as I set up my application on these different systems.

Ant tip: How to dynamically add all your jar files to your classpath

Here's some sample code you can use in your Ant build scripts to add all the jar files in a directory tree (typically your lib directory) to define a classpath for your Ant build/compile task:

Syndicate content