so

Java configurations

Volume 5, Issue 13; 05 Jul 2021

A tool for managing the configurations (dependencies and the classpath, system properties, etc.) of Java applications.

Back at the end of May, I had brief conversation on Twitter about configuring Java applications. I threatened to clean up and post my script for managing Maven dependencies, the classpath, system properties, etc.

The elevator pitch is this: in order to run, for example, XML Calabash or Saxon or most any modern Java application, you need to get the dependencies on your classpath. You can do this by hand, but it’s a pain.

Maven provides a robust ecosystem for dealing with this problem. It has a common declarative format for describing the dependencies and there are web repositories to support it. So in an environment like a Gradle build script, this is relatively painless.

But I still have shell scripts that run commands and I wanted to make that less painful.

Years ago, I wrote a Perl script to bridge the gap. Over time it grew new features, as these things do, until I had a configuration file that made it easy to specify:

  • Maven dependencies and other classpath requirements
  • Java options and system properties
  • Environment variables
  • Default arguments and parameters

It was fine, if a kind of uninspiring ball of Perl. But it fell over when Perl kind of fell over on my machine. (In particular, some C-level version mismatch between the Perl executable and Expat meant I couldn’t parse XML with Perl anymore.)

I spent a couple of evenings porting it to Python and cleaning it up a bit. I wrote some tests and used it to practice writing Python libraries.

It’s very definitely aimed at the kinds of Java programs I run every day. In particular, it was written to handle the kinds of command lines that XML Calabash and Saxon expose. But it’s fairly general and sort of documented now.

YMMV.

Share and enjoy! https://github.com/ndw/javaconfig

Please provide your name and email address. Your email address will not be displayed and I won’t spam you, I promise. Your name and a link to your web address, if you provide one, will be displayed.

Your name:

Your email:

Homepage:

Do you comprehend the words on this page? (Please demonstrate that you aren't a mindless, screen-scraping robot.)

What is nine times three?   (e.g. six plus two is 8)

Enter your comment in the box below. You may style your comment with the CommonMark flavor of Markdown.

All comments are moderated. I don’t promise to preserve all of your formatting and I reserve the right to remove comments for any reason.