Ant’s cool morale booster: splash task
# 2003-08-14 17:06:00 -0400 | Java | 5 CommentsSpotted the use of the <splash> task in the Hibernate build.xml today (via BPH). So of course I had to add it to Clover’s build file. You can see the results in the following screenshot. The <splash> task shows an image and a progress bar while the build is executing (the image can even be an animated .gif).
This is cool and fun, but “cool” is not the only reason why I added it to a production build file. In a previous life, I was working on a huge GUI client in Java (in pre-1.0 Swing!). We would release to system test quite often (twice a month?), and for each release we would come up with a humorous and on-topic splash screen for the application. It was a good release valve, and was good for morale.
I’m sure that my co-workers will now replace the build splash image from time to time.
You’ll do a cvs -q update -dP and then an ant build and all
of a sudden some humorous picture will pop up. Nothing like a good chuckle between coders.
To put this into your own build, you will need something like the following. But things to note about this Ant snipet:
- We use an “-init” target that most “core” targets depend on, but you’ll get the idea.
- We prefix any target with “-” if that target shouldn’t really be called from the command line (this idiom is documented in the Ant manual)
- When doing a “production” build using the “prod.build” target, I turn the splash screen off.
<target name="-splash" unless="nosplash">
<property name="splash.dir" location="."/>
<splash imageurl="file:${splash.dir}/fun/buildsplash.gif" />
</target>
<target name="-nosplash">
<property name="nosplash" value="foo"/>
</target>
<target name="-init" depends="-splash">
<tstamp>
<format property="build.date" pattern="MMMM dd yyyy"/>
</tstamp>
...
</target>
<target name="prod.build" depends="-nosplash, -init, ..."/>
The <splash> task should be used to maximum effect in combination with the <sound> task.
I just added splash to my build file and found that by default it pauses for 5 seconds to show the splash. This was pretty annoying. You can change this with the ’showduration’ attribute though.
<splash imageurl="file:image.jpg" showduration="0"/>
Yeah, we had the same problem (it is a little annoying)
Well, I agree that this can be a real eye candy and be used to make people laugh. But today I really had a hard time surviving the inquisition of our build manager who told me that the splash task I added to our buildfile caused the build process to fail. This was because we use a headless display for our builds. It crashed because it couldn’t find the X11 Libraries and the necessary display resources. So take good care of when and where to use, or it can cause you a real pain in the ass….and result in a lower morale ;)
Just a little addition to what Joe said, you can check the OS (we develop on osx and windows, build on headless linux boxes…) which might solve the problem sometimes =)
I’m struggling with this, I can’t seem to get any image displayed other than the default - I even tried changing that for something else!!
I’ve got a pirate gif - does the size matter?
Ta!
Gem