MavGuard is a command-line tool for analyzing and monitoring Maven dependencies in Java projects.
It examines pom.xml files in your repository and provides:
- Comprehensive dependency analysis for single and multi-module projects
- Detection of available updates for dependencies and parent POMs
- Identification of version inconsistencies across modules
- Clear, tabular output showing current vs. available versions
- Dependency Analysis: Comprehensive analysis of single and multi-module Maven projects
- Update Checking: Automatic detection of available updates for dependencies and parent POMs
- Version Inconsistency Detection: Identifies when different modules use different versions of the same dependency
- Multi-Module Support: Auto-detection and analysis of Maven multi-module projects with consolidated dependency views
- Parent POM Updates: Checks for updates to parent POMs in your project hierarchy
- Clear Output: Well-formatted, tabular output for easy reading
- Detailed Usage Reports: Optional
--detailed-usageflag shows which modules use which dependencies - Flexible Project Detection: Automatic detection with optional
--force-multi-moduleoverride
- Dependency Auditing: Quickly analyze all dependencies in your Maven projects
- Version Management: Identify outdated dependencies and available updates
- Multi-Module Consistency: Ensure consistent dependency versions across modules
- CI/CD Integration: Automate dependency checks in your build pipeline
- Security: Stay informed about updates that might include security fixes
MavGuard is built as a Maven multi-module project with a clean, modular architecture:
mav-guard/
├── mav-guard-model/ # Core domain model
├── mav-guard-xml-parser/ # POM file parsing
├── mav-guard-cli/ # Command-line interface
├── mav-guard-nexus/ # Nexus repository integration
└── sample/ # Example projects for testing
├── simple-project/
└── multi-module-project/
| Module | Description | Key Technologies |
| mav-guard | Parent project with common configuration | Maven |
| mav-guard-model | Core domain model (Java Records) | Java 21, Records |
| mav-guard-xml-parser | XML parsing for POM files | JAXB, Spring Context |
| mav-guard-cli | Command-line interface | Spring Boot, PicoCLI |
| mav-guard-nexus | Nexus integration (in progress) | Spring WebClient |
The project follows a layered architecture:
- Model Layer (mav-guard-model): Contains the core domain objects representing Maven projects and dependencies
- Service Layer (mav-guard-xml-parser): Provides services for parsing and analyzing Maven POM files
- Presentation Layer (mav-guard-cli): Offers a user interface for interacting with the system
This modular design allows for:
- Clear separation of concerns
- Independent development and testing of modules
- Flexibility to add new modules (e.g., a future web interface)
- Reuse of core functionality across different interfaces
- Java 21: Leveraging modern Java features including Records
- Spring Boot 3.4: For dependency injection and application framework
- PicoCLI: For powerful command-line argument parsing
- JAXB: For XML binding and POM file parsing
- Maven: As both build tool and the target domain
- Java 21 or higher
- Maven 3.8.0 or higher
To build the application as an executable JAR:
# From the project root directory
mvn clean packageThis will compile the code, run the tests, and package the application into an executable JAR file located in the mav-guard-cli/target directory.
After building, you can run the application using:
java -jar mav-guard-cli.jarMavGuard provides two main commands for analyzing your Maven projects:
Provides a comprehensive overview of your Maven project structure and dependencies.
# Analyze a single module project
java -jar mav-guard-cli.jar analyze pom.xml
# Analyze a multi-module project
java -jar mav-guard-cli.jar analyze /path/to/root/pom.xml
# Show detailed dependency usage by module
java -jar mav-guard-cli.jar analyze pom.xml --detailed-usageFeatures:
- Displays project coordinates and parent information
- Lists all dependencies (consolidated for multi-module projects)
- Detects and warns about version inconsistencies across modules
- Auto-detects single vs. multi-module projects
Performs all analysis features plus checks for available updates.
# Check for updates in current project
java -jar mav-guard-cli.jar check-updates pom.xml
# Force multi-module analysis
java -jar mav-guard-cli.jar check-updates pom.xml --force-multi-moduleFeatures:
- All features from
analyzecommand - Checks for newer versions of all dependencies
- Checks for parent POM updates
- Shows current vs. latest versions in aligned columns
- For multi-module projects, shows which modules are affected by each update
--- Update Check Results ---
Consolidated Dependency Updates Available:
DEPENDENCY CURRENT LATEST AFFECTED MODULES
--------------------------------------------------------------------------------
org.springframework:spring-core 5.3.10 -> 5.3.25 (Modules: module-a, module-b)
org.slf4j:slf4j-api 1.7.30 -> 1.7.36 (Modules: module-a)
Parent Project Updates:
MODULE PARENT CURRENT LATEST
--------------------------------------------------------------------------------
root org.springframework.boot:spring-boot-... 2.7.0 -> 2.7.8
Run all tests:
mvn testRun tests for a specific module:
mvn -pl mav-guard-cli testMavGuard supports different repository types for dependency update checks:
Uses Maven Central repository without authentication:
# Default configuration in application.properties
mavguard.repository.type=MAVEN_CENTRAL
mavguard.repository.base-url=https://repo1.maven.org/maven2
mavguard.repository.connection-timeout=5000
mavguard.repository.read-timeout=10000For enterprise environments with private Nexus repositories:
# Nexus configuration
mavguard.repository.type=NEXUS
mavguard.repository.base-url=https://nexus.your-company.com
mavguard.repository.username=your-username
mavguard.repository.password=your-password
mavguard.repository.repository=maven-public
mavguard.repository.connection-timeout=5000
mavguard.repository.read-timeout=10000Option 1: External Properties File
Create application-secrets.properties in the classpath:
# Create configuration file
cp mav-guard-cli/src/main/resources/application-secrets.properties.sample application-secrets.properties
# Edit with your Nexus credentialsOption 2: System Properties
java -Dmavguard.repository.type=NEXUS \
-Dmavguard.repository.base-url=https://nexus.company.com \
-Dmavguard.repository.username=user \
-Dmavguard.repository.password=pass \
-Dmavguard.repository.repository=maven-public \
-jar mav-guard-cli.jar check-updates pom.xmlOption 3: Environment Variables
export MAVGUARD_REPOSITORY_TYPE=NEXUS
export MAVGUARD_REPOSITORY_BASE_URL=https://nexus.company.com
export MAVGUARD_REPOSITORY_USERNAME=user
export MAVGUARD_REPOSITORY_PASSWORD=pass
export MAVGUARD_REPOSITORY_REPOSITORY=maven-public
java -jar mav-guard-cli.jar check-updates pom.xmlThe repository includes sample projects for testing:
# Build the application
mvn clean package
# Try the simple project (single module)
java -jar mav-guard-cli.jar analyze sample/simple-project/pom.xml
# Try the multi-module project
java -jar mav-guard-cli.jar analyze sample/multi-module-project/pom.xml --detailed-usage
# Check for updates using Maven Central
java -jar mav-guard-cli.jar check-updates sample/simple-project/pom.xml# Analyze your project
java -jar mav-guard-cli.jar analyze /path/to/your/project/pom.xml
# Check for updates (uses Maven Central by default)
java -jar mav-guard-cli.jar check-updates /path/to/your/project/pom.xmlFor analyze command:
- Project information (coordinates, parent)
- Complete dependency list
- Version inconsistency warnings (for multi-module projects)
- Module breakdown (with
--detailed-usage)
For check-updates command:
- All analysis information above
- Update availability table showing current vs. latest versions
- Parent POM update information
- Summary with total number of potential updates
Note: The first run may take a moment as it fetches metadata from the configured repository.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.