Heuristic:Datahub project Datahub Gradle Task Only
| Knowledge Sources | |
|---|---|
| Domains | Build_System, CI_CD |
| Last Updated | 2026-02-09 17:00 GMT |
Overview
Always use Gradle tasks for formatting, linting, and building. Never invoke npm, yarn, npx, ruff, mypy, or py_compile directly.
Description
The DataHub project enforces a strict rule that all code formatting, linting, and build operations must be performed through Gradle wrapper tasks (./gradlew). This ensures that the same tool versions, configurations, and processes used in CI are used locally. Bypassing Gradle and running tools directly (e.g., npx prettier, ruff format, python3 -m py_compile) uses different configurations and versions, causing CI failures and inconsistencies across the team.
Usage
Apply this heuristic always when working on the DataHub codebase. Any time you need to format, lint, or validate code, use the corresponding Gradle task rather than the underlying tool directly.
The Insight (Rule of Thumb)
- Action: Use
./gradlewtasks for ALL formatting and linting operations. - Mapping:
- Java formatting:
./gradlew spotlessApply - Python linting/formatting:
./gradlew :metadata-ingestion:lintFix - Markdown formatting:
./gradlew :datahub-web-react:mdPrettierWrite - GraphQL formatting:
./gradlew :datahub-web-react:graphqlPrettierWrite - GitHub Actions YAML:
./gradlew :datahub-web-react:githubActionsPrettierWrite - Everything at once:
./gradlew format
- Java formatting:
- Trade-off: Gradle tasks may be slightly slower than direct tool invocation due to JVM startup, but ensures consistency with CI.
Reasoning
Gradle tasks wrap the underlying tools (Prettier, Spotless, ruff, mypy) with the project's specific configuration files, tool versions, and plugin settings. Direct tool invocation may pick up different global configs, different tool versions, or miss project-specific rules. Since CI runs the Gradle tasks, local development must match to avoid formatting-only CI failures. Pre-commit hooks also call Gradle tasks, reinforcing this pattern.