Documentation
Learn how to use Forge in your projects
Command Reference
Essential Forge commands for building and managing projects:
| Command | Description |
|---|---|
forge build |
Compile source code and create build artifacts |
forge clean |
Remove all generated build files and directories |
forge resolve |
Display resolved dependencies and their versions |
forge version |
Display Forge version information |
forge help |
Show help and available commands |
Build Configuration
Create a build.forge file in your project root to configure your build. Forge supports both Groovy DSL and Kotlin DSL.
Groovy DSL Example (build.forge)
name = "MyProject"
version = "1.0.0"
dependencies {
add "com.google.code.gson:gson:2.10.1"
add "org.junit.jupiter:junit-jupiter-api:5.9.2"
}
repositories {
add "https://repo.maven.apache.org/maven2"
}
Kotlin DSL Example (build.forge.kts)
name("MyProject")
version("1.0.0")
dependencies {
add("com.google.code.gson:gson:2.10.1")
add("org.junit.jupiter:junit-jupiter-api:5.9.2")
}
repositories {
add("https://repo.maven.apache.org/maven2")
}
Configuration Elements
| Element | Description |
|---|---|
name |
Project name (displayed in build output) |
version |
Project version in semantic versioning format |
dependencies |
List of Maven-style dependencies to include |
repositories |
Maven repositories to fetch dependencies from |
Project Structure
Forge expects a standard Java project layout:
MyProject/
├── build.forge # Build configuration file
├── src/
│ └── main/
│ └── java/ # Source code directory
│ └── com/
│ └── example/
│ └── Main.java
└── build/ # Generated by Forge
├── classes/ # Compiled classes
└── libs/ # Downloaded dependencies
Important Notes
- Source files must be in
src/main/java/ - Package names must match directory structure
- Example:
package com.example;→src/main/java/com/example/ClassName.java
Environment Variables
| Variable | Description | Example |
|---|---|---|
FORGE_HOME |
Forge installation directory (set by installer) | C:\Program Files\forge |
FORGE_DEBUG |
Enable debug output (set to 1 to enable) | set FORGE_DEBUG=1 |
Enable Debug Mode
To see detailed build information:
set FORGE_DEBUG=1
forge build
Common Issues
Build fails with "No build.forge found"
Make sure you have a build.forge or build.forge.kts file in your project root directory.
"Compiled 0 Java files"
Ensure your Java files are located in src/main/java/ and that your package structure matches your directory structure.
Dependency resolution fails
Check that:
- The repository URL is correct and accessible
- The dependency format is correct:
groupId:artifactId:version - You have internet connectivity
Uninstalling Forge
To remove Forge from your system:
- Delete the Forge installation directory
- Remove
%FORGE_HOME%\binfrom your PATH environment variable - Delete the
FORGE_HOMEenvironment variable
Need help? Check the Installation Guide for troubleshooting or visit the Downloads page to get the latest version.