Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,49 @@ verify:
javadoc:
./mvnw javadoc:javadoc
@echo "Javadoc: target/site/apidocs/index.html"

# Format all Java files using Google Java Format
format:
./mvnw spotless:apply

# Check if Java files are properly formatted (for CI/hooks)
format-check:
./mvnw spotless:check

# Validate YAML files syntax
yaml-check:
#!/usr/bin/env bash
set -euo pipefail
yaml_files=$(find . -name "*.yml" -o -name "*.yaml" | grep -v ".git" | grep -v "target")
if [ -z "$yaml_files" ]; then
echo "No YAML files found"
exit 0
fi
for file in $yaml_files; do
if ! ./mvnw validate -f "$file" &>/dev/null; then
# Fallback to basic syntax check using Python or yq if available
if command -v python3 &>/dev/null; then
python3 -c "import yaml; yaml.safe_load(open('$file'))" || {
echo "YAML validation failed for: $file"
exit 1
}
elif command -v yq &>/dev/null; then
yq eval "$file" > /dev/null || {
echo "YAML validation failed for: $file"
exit 1
}
else
echo "Warning: No YAML validator available (install python3 or yq)"
exit 0
fi
fi
done
echo "All YAML files are valid"

# Install git hooks using lefthook
hooks-install:
lefthook install

# Uninstall git hooks
hooks-uninstall:
lefthook uninstall
24 changes: 24 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Lefthook configuration for java-faker
# Install hooks with: just hooks-install
# See: https://github.com/evilmartians/lefthook

pre-commit:
parallel: true
commands:
compile:
run: just build

format-check:
glob: "*.java"
run: just format-check

yaml-validate:
glob: "*.{yml,yaml}"
run: just yaml-check

# Optional: enforce conventional commit messages
# Uncomment to enable
# commit-msg:
# commands:
# conventional:
# run: just commit-msg-check {1}
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.45.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.27.0</version>
<style>GOOGLE</style>
</googleJavaFormat>
<removeUnusedImports/>
<formatAnnotations/>
</java>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down