Hi all - I wanted to share my setup for plugin development as it's made my life a bit easier than following what's on the
docs right now. These docs suggest setting up a
standalone killbill instance, which doesn't seem strictly necessary to me if you aren't planning on debugging or changing killbill core. It also doesn't provide steps on setting up kaui (which isn't hard to do, but is additional overhead if you want that during development).
Also curious to know what other people's development setups are like in case I've missed anything, as I'm not too familiar with the java ecosystem.
Step 1.
Create a plugin repo. I've borrowed from the
hello-world example.
Step 2.
Building a killbill image with plugins included. This is mostly for convenience and is not strictly necessary, there are other ways to do this which are well documented. Dockerfile is attached.
docker build -t killbill-with-plugins .
Step 3.
Start kaui, mysql, and the docker image you created in step 2, adapted slightly from the
docker compose installation docs. Note that this configuration adds a bind mount from assumed location of your plugins .jar file to where it's loaded in your killbill's docker container. This isn't strictly necessary, and is a bit error prone given how I've done it, but it's required for step 4. I've also added the JVM_JDWP_PORT environment variable (which isn't documented as far as I'm aware) to be able to debug your plugin, which seems essential to me. You can find the docker compose yml file attached.
Step. 4
Create a script that rebuilds your plugin and restarts the killbill service. This is done as a convenience to avoid:
1. making changes to your plugin
2. rebuilding your plugin
3. rebuilding the killbill docker image that includes your plugin.
4. restarting the killbill service.
The script is pretty straightforward:
// ./update_plugin.sh
#!/bin/bash
# Define paths
PLUGIN_TARGET_DIR="target"
PLUGIN_JAR="hello-world-plugin-2.0.1-SNAPSHOT.jar" # Replace with your plugin jar name
KILLBILL_CONTAINER_NAME="killbill" # Replace with your Kill Bill container name
# Step 1: Build the plugin
echo "Building the plugin..."
cd "$PLUGIN_SOURCE_DIR"
mvn clean install
# Check if build was successful
if [ ! -f "$PLUGIN_TARGET_DIR/$PLUGIN_JAR" ]; then
echo "Build failed, plugin JAR not found."
exit 1
fi
# Step 2: Restart Kill Bill container to pick up the new plugin
echo "Restarting Kill Bill container..."
cd "$DOCKER_COMPOSE_DIR"
docker-compose restart "$KILLBILL_CONTAINER_NAME"
echo "Plugin updated and Kill Bill container restarted."
5. If you want to go so far as to support hot-reloading using this script, you can run
nodemon --watch . -e java,xml --exec "./update_plugin.sh"
I hope this helps someone! Curious to know how other people usually go about this.
Alex