Understanding Maven
Apache Maven is a project management tool that simplifies build processes through a Project Object Model (POM). It standardizes project structures, manages dependencies, and automates builds, documentation, and reporting.
Private Repository Ovreview
A private repository acts as a local cache for remote artifacts, reducing external dependencies and improving build speeds within a team environment.
Nexus Repository Manager
Nexus is a robust Maven repository manager that:
- Proxies remote repositories
- Hosts internal artifacts
- Manages dependencies efficiently
Installation Steps
-
Prerequisites
- JDK 1.8 installed
- Maven configured
-
Nexus Setup
# Download and extract wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz tar -zxvf latest-unix.tar.gz -C /opt/ # Start Nexus cd /opt/nexus-*/bin/ ./nexus start -
Configuration
- Access via http://localhost:8081
- Default credentials: admin/admin123
- Modify
/opt/nexus-*/etc/nexus-default.propertiesfor port changes
-
Repository Types
- Proxy: Mirrors remote repositories
- Hosted: Stores internal artifacts
- Group: Combines multiple repositories
Integration with Maven
-
Settings.xml Configuration
<servers> <server> <id>nexus</id> <username>admin</username> <password>admin123</password> </server> </servers> -
Project POM Configuration
<distributionManagement> <repository> <id>nexus</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus</id> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> -
Deploying Artifacts
# For releases mvn clean deploy # For third-party JARs mvn deploy:deploy-file \ -DgroupId=com.example \ -DartifactId=library \ -Dversion=1.0.0 \ -Dpackaging=jar \ -Dfile=path/to/library.jar \ -Durl=http://localhost:8081/repository/maven-releases/ \ -DrepositoryId=nexus
Repository Management
- Blob Stores: Physical storage locations
- Security: User/role management
- System: Maintenance and monitoring