Kevin Ledesma c38c054d7b
Implement spotless gradle pre-commit hook (#105)
* Add precommit hook definition to perform basic formatting using spotless on indexer plugins

* Add formatter configuration file for spotless tool

* Update command-manager's build.gradle to use the spotless tool

* Update spotless implementation on setup plugin

- Order build.gradle blocks
- Add spotless plugin to build.gradle
- Update formatting.gradle for both plugins

* Add formatter config for spotless on setup plugin

* Add license header validation on java files

- Add license-header.txt file with the expected content of the headers
- Update formatting.gradle on both plugins to validate the license header
- Rename buildSrc directory to formatter

* Update formatter settings

* Implement custom import order based on wazuh-indexer defined convention

* Apply format-related changes requested by spotless formatter

* Initialize a gradle base project to handle generic processes for the subprojects

- Move spotless-related configuration to main project directory
- Add pre-commit hook script to run spotlessCheck
- Add block on build.gradle to automatically apply pre-commit script into local .git dir
- Remove duplicated spotless-related code

* Apply spotless formatting to command-manager classes
2024-10-17 14:35:44 +02:00

22 lines
660 B
Bash

#!/bin/bash
# Navigate to the root of the repository
cd "$(git rev-parse --show-toplevel)"
# Run spotlessCheck
./gradlew spotlessCheck
# Capture the exit code
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "======================================================================================"
echo "Spotless found some formatting issues. Please run ./gradlew spotlessApply to fix them."
echo "======================================================================================"
exit 1
else
echo "==================================="
echo "Spotless check passed successfully!"
echo "==================================="
fi