From f2153e51679a1e06e25bf5c2dee6953717d59ca0 Mon Sep 17 00:00:00 2001 From: Fabian Pichler Date: Thu, 19 Feb 2026 03:15:21 +0100 Subject: [PATCH] add format-java.sh using eclips format.xml --- mvn/format-java.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 mvn/format-java.sh diff --git a/mvn/format-java.sh b/mvn/format-java.sh new file mode 100644 index 0000000..7993aee --- /dev/null +++ b/mvn/format-java.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -euo pipefail + +# Calculate script directory +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +FORMATTER_CONFIG="$DIR/../eclipse/synventis-code-formatter.xml" + +# Help message +function show_help { + echo "Usage: $0 [options] [maven-args]" + echo "" + echo "Formats Java code using the Synventis code formatter." + echo "" + echo "Options:" + echo " -h, --help Show this help message" + echo "" + echo "All other arguments are passed to the Maven command." +} + +# Parse arguments for help +for arg in "$@"; do + case $arg in + -h|--help) + show_help + exit 0 + ;; + esac +done + +# Check if formatter config exists +if [ ! -f "$FORMATTER_CONFIG" ]; then + echo "Error: Formatter config file not found at $FORMATTER_CONFIG" + exit 1 +fi + +mvn net.revelc.code.formatter:formatter-maven-plugin:2.23.0:format \ + -Dformatter.configFile="$FORMATTER_CONFIG" \ + -Dencoding=UTF-8 \ + -Dproject.build.sourceEncoding=UTF-8 \ + "$@"