First off, thanks for your interest in contributing to Naftah! Your help improves the language and grows the community. This guide will help you set up your development environment, understand the build system, and get started with contributing code, grammar, or tooling.
We welcome all contributions — code, documentation, testing, discussions, and ideas!
Before you begin, make sure you have the following installed:
| Tool | Minimum Version | Notes |
|---|---|---|
| Java JDK | 17 | Required. Preview features enabled. |
| Gradle | >= 7.5 (optional) | You can use the wrapper (./gradlew). |
| Git | Any | For cloning the repo. |
| GPG | Optional | Required only for publishing/signing. |
Click the "Fork" button in the top right and clone your fork:
git clone https://github.com/Chakib-DAII/Naftah.git
cd naftahYou can build the project and generate all necessary artifacts (including the parser, dependencies, and REPL) using:
./gradlew buildOr on Windows:
gradlew.bat buildHere's a breakdown of the most useful Gradle tasks available:
| Task | Description |
|---|---|
build |
Compiles source code, runs tests, checks code style |
compileJava |
Compiles Java source including generated ANTLR code |
clean |
Cleans build directory (also deletes generated ANTLR files) |
| Task | Description |
|---|---|
test |
Runs JUnit tests with vector preview features |
jacocoTestReport |
Generates HTML and XML test coverage report |
jacocoTestCoverageVerification |
Enforces minimum coverage (70%) |
Test results and reports are available under build/reports/tests/.
| Task | Description |
|---|---|
checkstyleMain, checkstyleTest, checkstyleBenchmark |
Run code style checks using Checkstyle |
spotlessApply |
Auto-formats Java and Gradle files using Eclipse formatter |
lintAndFormat |
Runs both Checkstyle and Spotless formatting |
To fix formatting issues automatically:
./gradlew formatANTLR is used to define Naftah’s syntax. The grammar files live in:
src/main/antlr/
| Task | Description |
|---|---|
generateGrammarSource |
Regenerates parser/lexer code from .g4 files |
This task runs automatically before compileJava.
If you edit
NaftahLexer.g4orNaftahParser.g4, always regenerate the sources.
| Task | Description |
|---|---|
dist |
Creates a minimal distribution ZIP under build/distributions/ |
distStandalone |
Creates a fat/standalone JAR with all dependencies |
fatJar |
Builds a single runnable .jar with embedded dependencies |
To create a full distribution (includes compiled classes, REPL scripts, lib JARs):
./gradlew distOr for the fat standalone JAR:
./gradlew distStandaloneNaftah uses custom tasks to extract tokens and symbols from the lexer:
| Task | Description |
|---|---|
extractLexerLiterals |
Extracts all string literals and tokens from NaftahLexer.g4 (reused in error listener and error messages) |
writeResolvedJars |
Writes resolved JAR names to build/libs/original-dependencies (jars to be ignored by the classpath class scanner) |
These are automatically included in the dist tasks.
To run performance benchmarks:
./gradlew runJmhThis executes JMH tests defined in:
benchmark/java/
Results are written as JSON to:
build/reports/benchmarks/jmh-results.json
Publishing is supported using:
./gradlew publishMake sure to configure the following:
-
Set environment variables:
OSSRH_USERNAMEOSSRH_PASSWORD
-
For signing (optional):
export GPG_PRIVATE_KEY=$(gpg --armor --export-secret-keys YOUR_KEY_ID)
export GPG_PASSPHRASE=yourPassphraseEnable signing in build.gradle by uncommenting the signing { ... } section.
- Regenerate parser after grammar changes:
./gradlew generateGrammarSource - Clean builds:
./gradlew clean build - Check JavaDoc output:
build/docs/javadoc/index.html - Watch for preview feature use — Java 17+ with
--enable-previewis required. - Use
--infoor--stacktracefor debug builds if something fails.
├── build.gradle # Main Gradle build config
├── naftah-builtin-core # Core builtin extensions dependency
├── src/main/java # Core builtin annotations
├── src/test/ # JUnit tests
├── build.gradle # Gradle build config
└── build/ # Gradle output (compiled classes, zips, etc.)
├── naftah-lang # Core language implementation
├── src/main/java # Core language classes
├── src/main/resources # Core language resources
├── src/main/antlr # Naftah grammar files (ANTLR)
├── src/main/bin # CLI / REPL scripts (.sh / .bat)
├── src/test/ # JUnit tests
├── src/benchmark/ # JMH performance tests
├── build.gradle # Gradle build config
└── build/ # Gradle output (compiled classes, zips, etc.)
├── learn-by-example/ # Sample .naftah scripts
├── docs-site/ # documentation site
└── config/ # Code style and formatter config
If you use IntelliJ IDEA:
- Import as Gradle project.
- Enable preview features:
File > Project Settings > Compiler > Java Compiler > Add
--enable-previewas additional args. - Enable ANTLR plugin (for syntax highlighting and navigation).
- Add
generated-src/antlr/mainas a generated source root.
- Fork the repo and clone it locally.
- Create a new branch:
git checkout -b feature/my-new-feature - Make your changes.
- Run build:
./gradlew build - Run tests:
./gradlew test - Open a PR on GitHub.
Please include:
- Clear description of your change
- Before/after behavior if applicable
- Tests or examples for any syntax/runtime changes
Open an issue or start a discussion on GitHub: 👉 Naftah on GitHub