Development Setup
This guide will help you set up your development environment for contributing to MARSLib. The setup process takes about 10-15 minutes.
Prerequisites
Section titled “Prerequisites”Required Tools
Section titled “Required Tools”- Java 17 - Development JDK.
- Gradle 8.5+ - Build system (included with project)
- Git - Version control.
- VS Code - Recommended IDE (with extensions)
- Node.js 18+ - For website development.
Optional Tools
Section titled “Optional Tools”- AdvantageScope - Telemetry visualization.
- WPILib VS Code Extension - FRC development support.
Step 1: Fork and Clone
Section titled “Step 1: Fork and Clone”Fork the Repository
Section titled “Fork the Repository”- Go to github.com/MARSProgramming/MARSLib
- Click the “Fork” button in the top-right.
- Choose your GitHub account as the destination.
Clone Your Fork
Section titled “Clone Your Fork”# Clone your forkgit clone https://github.com/YOUR_USERNAME/MARSLib.gitcd MARSLib
# Add upstream repositorygit remote add upstream https://github.com/MARSProgramming/MARSLib.gitStep 2: Install Java Dependencies
Section titled “Step 2: Install Java Dependencies”Using Gradle Wrapper (Recommended)
Section titled “Using Gradle Wrapper (Recommended)”The project includes Gradle Wrapper, so you don’t need to install Gradle separately:
# On Windows.\gradlew.bat build
# On macOS/Linux./gradlew buildVerify Installation
Section titled “Verify Installation”# Run tests to verify setup.\gradlew.bat test
# Run simulation to verify physics.\gradlew simulateJavaStep 3: Set Up VS Code
Section titled “Step 3: Set Up VS Code”Install Extensions
Section titled “Install Extensions”Install these VS Code extensions for best development:
- Extension Pack for Java (Microsoft)
- Gradle for Java (Microsoft)
- WPILib (WPILib contributors)
- Markdown All in One (for documentation)
Configure VS Code
Section titled “Configure VS Code”Create .vscode/settings.json (if not present):
{ "java.format.settings.url": "https://raw.githubusercontent.com/MARSProgramming/MARSLib/master/spotless.license", "java.configuration.updateBuildConfiguration": "automatic", "java.import.gradle.enabled": true, "files.associations": { "*.gradle": "groovy" }}Step 4: Set Up Website Development
Section titled “Step 4: Set Up Website Development”Install Dependencies
Section titled “Install Dependencies”cd websitenpm installRun Development Server
Section titled “Run Development Server”npm run devThe website will be available at http://localhost:4321
Build for Production
Section titled “Build for Production”npm run buildStep 5: Install Git Hooks (Optional)
Section titled “Step 5: Install Git Hooks (Optional)”Install git hooks to automatically format code before commits:
# On Windows.\install-git-hooks.bat
# On macOS/Linuxchmod +x .githooks/pre-commitThis ensures your code follows MARSLib formatting standards automatically.
Step 6: Verify Everything Works
Section titled “Step 6: Verify Everything Works”Build the Project
Section titled “Build the Project”.\gradlew.bat buildRun Tests
Section titled “Run Tests”.\gradlew.bat testRun Simulation
Section titled “Run Simulation”.\gradlew.bat simulateJavaTest Website
Section titled “Test Website”cd websitenpm run devDevelopment Workflow
Section titled “Development Workflow”Create a Feature Branch
Section titled “Create a Feature Branch”git checkout -b feature/your-feature-nameMake Changes
Section titled “Make Changes”- Edit code in
src/main/java/ - Add tests in
src/test/java/ - Update documentation if needed.
Test Your Changes
Section titled “Test Your Changes”# Run all tests.\gradlew.bat test
# Run specific test.\gradlew.bat test --tests SwerveDriveTest
# Run simulation.\gradlew.bat simulateJavaCommit Your Changes
Section titled “Commit Your Changes”git add .git commit -m "Descriptive commit message"Push and Create Pull Request
Section titled “Push and Create Pull Request”git push origin feature/your-feature-nameThen create a pull request on GitHub.
Useful Gradle Commands
Section titled “Useful Gradle Commands”Building
Section titled “Building”# Build entire project.\gradlew.bat build
# Build without tests.\gradlew.bat build -x test
# Clean build artifacts.\gradlew.bat cleanTesting
Section titled “Testing”# Run all tests.\gradlew.bat test
# Run with coverage.\gradlew.bat test jacocoTestReport
# Run specific test class.\gradlew.bat test --tests MARSTestHarness
# Run simulation tests.\gradlew.bat simulateJavaDocumentation
Section titled “Documentation”# Generate JavaDoc.\gradlew.bat generateDocs
# View generated docs# Open docs/javadoc/index.htmlDeployment
Section titled “Deployment”# Deploy to robot.\gradlew.bat deploy
# Build deployment JAR.\gradlew.bat buildDeploymentJarTroubleshooting
Section titled “Troubleshooting”Java Version Issues
Section titled “Java Version Issues”Ensure you’re using Java 17:
java -version# Should show "17.x.x"Gradle Build Fails
Section titled “Gradle Build Fails”Try cleaning and rebuilding:
.\gradlew.bat clean build --refresh-dependenciesTests Fail Locally
Section titled “Tests Fail Locally”Make sure you’ve initialized HAL:
# Tests should call this automaticallyHAL.initialize(500, 0);Website Won’t Build
Section titled “Website Won’t Build”Clear node_modules and reinstall:
cd websiterm -rf node_modules package-lock.jsonnpm installNext Steps
Section titled “Next Steps”- Read our Coding Standards to understand our patterns.
- Learn about our Testing Philosophy .
- Find a good first issue.
- Join our GitHub Discussions.
Need Help?
Section titled “Need Help?”- 📖 Check the main documentation
- 💬 Ask in GitHub Discussions
- 🐛 Report issues on GitHub Issues
Ready to code? Check out our Coding Standards to learn MARSLib patterns!