wazuh / wazuh-indexer-plugins

GNU Affero General Public License v3.0
1 stars 3 forks source link

Include Spotless Gradle precommit hook #104

Open AlexRuiz7 opened 21 hours ago

AlexRuiz7 commented 21 hours ago

Description

OpenSearch's codebase, and by inheritance Wazuh Indexer's, uses a precommit hook to format and lint the Java code using Spotless. In order to guarantee that our plugin's code is consistent and well maintained, we will include this precommit hook to our plugin's build.gradle.

The code conventions to be used are the ones defined in the Developer Guide. We will inherit the code and naming conventions from OpenSearch to keep all the codebase consistent.

Explore if we can add a root Grade project to simplify the configuration. The subprojects (each plugin's Gradle project), will inherit the precommit hook from the root project.

Functional requirements

Implementation restrictions

* Optional

Resources

QU3B1M commented 20 hours ago

Gradle offers this documentation that could be useful for the implementation of the generic build.gradle to run for all the subprojects (plugins).

For now we will work on a basic implementation of the functionality, so this improvement will be worked on later.

QU3B1M commented 13 hours ago

The spotless tool is applied and working correctly with the gradlew commands, but not the pre-commit hook, for now the implementation is only working on the plugin command-manager.

The problem with the hook is that it seems to require org.opensearch.gradle.BuildPlugin that is not present on our plugins repository, for what I can see on the OpenSearch plugins' repositories that class is not present neither, so I have to re-evaluate the implementation of the pre-commit hook, maybe for the plugins we can have a more "typical" and basic solution, something like this

Once the pre-commit hook is working successfully, I will apply the required changes to the other plugin.