Skip to main content
Version: 0.2.0

Installation

jGuard requires JDK 21 or later. This guide covers installation via Gradle (recommended) and Maven.

Prerequisites​

  • JDK 21+ - jGuard uses modern JVM features
  • Gradle 8.5+ or Maven 3.8+

Add the Plugin​

Add the jGuard Gradle plugin to your build.gradle:

plugins {
id "java"
id "application"
id "io.jguard.policy" version "0.2.0"
}

dependencies {
implementation("io.jguard:jguard-core:0.2.0")
}

Configure the Plugin​

jguardPolicy {
// Policy source file (default: src/main/java/module-info.jguard)
sourceFile = file("src/main/java/module-info.jguard")

// Enforcement mode: strict, permissive, or audit
mode = "strict"

// Log level: error, warn, info, debug, trace
logLevel = "info"
}

Create Your Policy​

Create src/main/java/module-info.jguard:

security module com.example.myapp {
entitle module to fs.read(config, "**");
}

Run with Enforcement​

# Run with the jGuard agent attached
./gradlew runWithAgent

# Run in audit mode (log violations, don't block)
./gradlew runWithAgent -Pjguard.mode=audit

Maven​

Add Dependencies​

Add to your pom.xml:

<dependencies>
<dependency>
<groupId>io.jguard</groupId>
<artifactId>jguard-core</artifactId>
<version>0.2.0</version>
</dependency>
</dependencies>

Manual Agent Configuration​

Download the agent JAR and run manually:

# Download agent
curl -O https://repo1.maven.org/maven2/io/jguard/jguard-agent/0.2.0/jguard-agent-0.2.0.jar

# Compile policy
java -jar jguard-cli-0.2.0.jar compile -o policy.bin module-info.jguard

# Run with agent
java -javaagent:jguard-agent-0.2.0.jar=policy.bin \
-Djguard.mode=strict \
-jar your-app.jar

Artifacts​

jGuard publishes the following artifacts:

ArtifactDescriptionLink
io.jguard:jguard-corePublic API for applicationsMaven Central
io.jguard:jguard-policyPolicy model and compilationMaven Central
io.jguard:jguard-agentRuntime enforcement agentMaven Central
io.jguard:jguard-cliCommand-line toolsMaven Central
io.jguard.policyGradle pluginGradle Plugin Portal

Next Steps​