Skip to content

Building

Cyrusbye720 edited this page Aug 29, 2026 · 2 revisions

Building from Source

Prerequisites

  • Java 21+ (required for compilation)
  • Git (for cloning the repository)

Building with Gradle (Recommended)

1. Clone the Repository

git clone https://github.com/DemonZ-Development/Onlysleep.git
cd Onlysleep

2. Build the Plugin

./gradlew clean build

On Windows, use gradlew.bat clean build.

3. Find the Output

The compiled JAR will be in build/libs/:

build/libs/Onlysleep-1.0.0.jar

4. Install the Built JAR

Copy the JAR to your server's plugins/ folder and restart.


Building with Maven (Alternative)

1. Clone the Repository

git clone https://github.com/DemonZ-Development/Onlysleep.git
cd Onlysleep

2. Build the Plugin

mvn clean package

3. Find the Output

The compiled JAR will be in target/:

target/Onlysleep-1.0.0.jar

Running Tests

# Run all tests
./gradlew test

# Run specific test class
./gradlew test --tests "com.demonzdevelopment.onlysleep.config.ConfigManagerTest"

# Run with verbose output
./gradlew test --info

# Run tests without building first
./gradlew test --no-daemon

The project has 152+ unit tests covering:

  • ConfigManager (configuration loading and progress bar logic)
  • SleepManager (sleep counting, player filtering, permissions)
  • AfkTracker (AFK detection and timeout)
  • PlatformAdapter (server platform detection)
  • UpdateChecker (version comparison)
  • SleepPlaceholderExpansion (all 19+ placeholders)
  • OnlysleepIntegrationTest (end-to-end plugin lifecycle)

Build Options

Skipping Tests

./gradlew build -x test

Building with Debug Information

./gradlew clean build --info

Generating a Comprehensive Test Report

./gradlew clean test

HTML test reports are available at build/reports/tests/test/index.html.


Project Structure

Onlysleep/
β”œβ”€β”€ build.gradle.kts              # Gradle build configuration
β”œβ”€β”€ settings.gradle.kts           # Gradle settings
β”œβ”€β”€ pom.xml                       # Maven build configuration
β”œβ”€β”€ gradlew / gradlew.bat         # Gradle wrapper scripts
β”œβ”€β”€ CHANGELOG.md                  # Version history
β”œβ”€β”€ README.md                     # Main README
β”œβ”€β”€ MODRINTH.md                   # Modrinth description
β”œβ”€β”€ SPIGOT.md                     # Spigot description
β”œβ”€β”€ HANGAR.md                     # Hangar description
β”œβ”€β”€ wiki/                         # Wiki documentation
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/com/demonzdevelopment/onlysleep/
β”‚   β”‚   β”‚   β”œβ”€β”€ Onlysleep.java                    # Main plugin class
β”‚   β”‚   β”‚   β”œβ”€β”€ config/ConfigManager.java          # Configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ command/OnlysleepCommand.java      # Commands
β”‚   β”‚   β”‚   β”œβ”€β”€ listener/SleepListener.java        # Event listeners
β”‚   β”‚   β”‚   β”œβ”€β”€ manager/SleepManager.java          # Core logic
β”‚   β”‚   β”‚   └── util/
β”‚   β”‚   β”‚       β”œβ”€β”€ AfkTracker.java                # AFK detection
β”‚   β”‚   β”‚       β”œβ”€β”€ OfflinePlayerTracker.java      # Offline caching
β”‚   β”‚   β”‚       β”œβ”€β”€ PlatformAdapter.java           # Platform detection
β”‚   β”‚   β”‚       β”œβ”€β”€ SchedulerAdapter.java          # Folia compatibility
β”‚   β”‚   β”‚       β”œβ”€β”€ SleepPlaceholderExpansion.java # PAPI expansion
β”‚   β”‚   β”‚       └── UpdateChecker.java             # Version checking
β”‚   β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ config.yml                         # Default config
β”‚   β”‚       β”œβ”€β”€ messages.yml                       # Default messages
β”‚   β”‚       └── plugin.yml                         # Plugin metadata
β”‚   └── test/
β”‚       └── java/com/demonzdevelopment/onlysleep/
β”‚           β”œβ”€β”€ OnlysleepIntegrationTest.java
β”‚           β”œβ”€β”€ config/ConfigManagerTest.java
β”‚           β”œβ”€β”€ manager/SleepManagerTest.java
β”‚           └── util/
β”‚               β”œβ”€β”€ AfkTrackerTest.java
β”‚               β”œβ”€β”€ PlatformAdapterTest.java
β”‚               β”œβ”€β”€ SleepPlaceholderExpansionTest.java
β”‚               └── UpdateCheckerTest.java
└── .github/workflows/
    β”œβ”€β”€ build.yml                  # CI build workflow
    β”œβ”€β”€ codeql.yml                 # Security analysis
    └── release.yml               # Release automation

CI/CD

The project uses GitHub Actions for continuous integration:

  • build.yml β€” Runs on every push and pull request. Builds the plugin with both Gradle and Maven, runs all tests, and caches dependencies.
  • codeql.yml β€” Runs CodeQL security analysis on every push to main and weekly.
  • release.yml β€” Triggered by tags matching v*. Builds the plugin, runs tests, creates a GitHub Release with the JAR artifact.

Dependencies

Build Dependencies

Dependency Purpose
Paper API (1.21.4) Bukkit/Paper server API
PlaceholderAPI Optional placeholder expansion
bStats Anonymous usage metrics
Adventure API Modern component-based chat

Test Dependencies

Dependency Purpose
JUnit 5 (Jupiter) Test framework
Mockito 5 Mocking Bukkit APIs
Mockito JUnit Jupiter Mockito integration with JUnit 5

Clone this wiki locally