Source:
- https://www.theserverside.com/news/1364121/Setting-Up-a-Maven-Repository
- https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Nexus-repository-manager-tutorial-Get-started-with-the-OSS-Maven-tool
- https://help.sonatype.com/repomanager2/download
- https://hub.docker.com/r/sonatype/nexus3/
- https://help.sonatype.com/repomanager3/release-notes/2019-release-notes
- https://www.theserverside.com/tutorial/How-to-install-Maven-and-build-apps-with-the-mvn-command-line
PreReqs
- jdk8
- nexus
- firewall-cmd for port8081
- apt install hashalot / sha256sum
Install Maven CLI
How to install Maven
A Maven install is one of the easier software installations you can do. At a high level, the steps to install Maven are:
- Download Maven binaries from the Apache website.
- Unzip the Apache Maven download, and move the folder to a place on your computer where you keep all of your other DevOps tools.
- Add system variables named MAVEN_HOME and M2_HOME, and point both of these variables to the root Maven directory. The root Maven directory will contain a folder named \bin, which contains the pivotally important mvn command-line utility.
- The root Maven directory contains a subfolder named \bin. Add this \bin directory to the OS' path. This makes the mvn command-line tool universally available to the OS.
In my personal development environments, I like to rename the Maven directory _maven, and when I install Maven on a Windows machine, I place that folder directly in the root of the C: drive. Here's how the system variables and edited path look after you successfully configure and install Maven.
Install Nexus OSS
Download
wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
Unpack
tar -xzf latest-unix.tar.gz
Start
./nexus start
Add hole in firewall for port 8081
sudo firewall-cmd --permanent --add-port=8081/tcp sudo firewall-cmd --reload
The default username and password for the Nexus Maven repository is: admin:admin123. When the Nexus repository manager’s administrative console loads, log in with these credentials.
Admin>Repository>Repositories
- Name: uc-maven
- Online: YES
Maven2
- Version policy: Release
- Layout policy: Strict
Storage
- blob store: default
- Strict Content Type Validation: YES
Hosted
- Deployment policy: Disable redeploy
Cleanup Policy
- Available cleanup policies: None
Create repository
Maven Installation
System Requirements
Java Development Kit (JDK) | Maven 3.3+ require JDK 1.7 or above to execute - they still allow you to build against 1.3 and other JDK versions by Using Toolchains |
Memory | No minimum requirement |
Disk | Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. |
Operating System | No minimum requirement. Start up scripts are included as shell scripts and Windows batch files. |
Files
Maven is distributed in several formats for your convenience. Simply pick a ready-made binary distribution archive and follow the installation instructions. Use a source archive if you intend to build Maven yourself.
In order to guard against corrupted downloads/installations, it is highly recommended to verify the signature of the release bundles against the public KEYS used by the Apache Maven developers.
Link | Checksums | Signature | |
---|---|---|---|
Binary tar.gz archive | apache-maven-3.6.0-bin.tar.gz | apache-maven-3.6.0-bin.tar.gz.sha512 | apache-maven-3.6.0-bin.tar.gz.asc |
Binary zip archive | apache-maven-3.6.0-bin.zip | apache-maven-3.6.0-bin.zip.sha512 | apache-maven-3.6.0-bin.zip.asc |
Source tar.gz archive | apache-maven-3.6.0-src.tar.gz | apache-maven-3.6.0-src.tar.gz.sha512 | apache-maven-3.6.0-src.tar.gz.asc |
Source zip archive | apache-maven-3.6.0-src.zip | apache-maven-3.6.0-src.zip.sha512 | apache-maven-3.6.0-src.zip.asc |
Previous Releases
It is strongly recommended to use the latest release version of Apache Maven to take advantage of newest features and bug fixes.
If you still want to use an old version you can find more information in the Maven Releases History and can download files from the archives for versions 3.0.4+ and legacy archives for earlier releases.
Download & Extract
[setup@c7 maven]$ wget http://apache.mirrors.pair.com/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
--2019-04-13 03:36:19-- http://apache.mirrors.pair.com/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
Resolving apache.mirrors.pair.com (apache.mirrors.pair.com)... 216.92.2.131
Connecting to apache.mirrors.pair.com (apache.mirrors.pair.com)|216.92.2.131|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9136463 (8.7M) [application/x-gzip]
Saving to: ‘apache-maven-3.6.1-bin.tar.gz’
100%[==========================================================================>] 9,136,463 15.0MB/s in 0.6s
2019-04-13 03:36:20 (15.0 MB/s) - ‘apache-maven-3.6.1-bin.tar.gz’ saved [9136463/9136463]
[setup@c7 maven]$ tar -xzf apache-maven-3.6.1-bin.tar.gz
[setup@c7 maven]$ ls
apache-maven-3.6.1 apache-maven-3.6.1-bin.tar.gz
[setup@c7 maven]$ ls apache-maven-3.6.1
bin boot conf lib LICENSE NOTICE README.txt
[setup@c7 maven]$ cd ..
[setup@c7 Downloads]$ ls
cat get-docker.sh if.txt less maven nano nexus temp
[setup@c7 Downloads]$ cd maven
[setup@c7 maven]$ ls
apache-maven-3.6.1 apache-maven-3.6.1-bin.tar.gz
Making mvn executable
[setup@c7 maven]$ cd apache-maven-3.6.1
[setup@c7 apache-maven-3.6.1]$ ls
bin boot conf lib LICENSE NOTICE README.txt
[setup@c7 apache-maven-3.6.1]$ cd bin
[setup@c7 bin]$ ls
m2.conf mvn mvn.cmd mvnDebug mvnDebug.cmd mvnyjp
[setup@c7 bin]$ sudo chmod +x mvn
[sudo] password for setup:
[setup@c7 bin]$ ls -la
total 32
drwxrwxr-x. 2 setup setup 97 Apr 13 03:36 .
drwxrwxr-x. 6 setup setup 99 Apr 13 03:36 ..
-rw-r--r--. 1 setup setup 228 Apr 4 13:56 m2.conf
-rwxr-xr-x. 1 setup setup 5741 Apr 4 13:56 mvn
-rw-r--r--. 1 setup setup 6349 Apr 4 13:56 mvn.cmd
-rwxr-xr-x. 1 setup setup 1485 Apr 4 13:56 mvnDebug
-rw-r--r--. 1 setup setup 1668 Apr 4 13:56 mvnDebug.cmd
-rwxr-xr-x. 1 setup setup 1532 Apr 4 13:56 mvnyjp
Add mvn to PATH
[setup@c7 bin]$ echo $PATH
[setup@c7 bin]$ export PATH=$PATH:/home/setup/Downloads/maven/apache-maven-3.6.1/bin
Verifying Installation
[setup@c7 bin]$ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T14:00:29-05:00)
Maven home: /home/setup/Downloads/maven/apache-maven-3.6.1
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_201-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.14.4.el7.x86_64", arch: "amd64", family: "unix"
Maven Repository Architecture
Install JDK8 on CentOS7
[setup@c7 jvm]$ sudo wget --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm --2019-04-13 01:06:14-- https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm Resolving download.oracle.com (download.oracle.com)... 104.73.166.201 Connecting to download.oracle.com (download.oracle.com)|104.73.166.201|:443... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm [following] --2019-04-13 01:06:14-- https://edelivery.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.2.49.236, 2600:1404:5800:193::366, 2600:1404:5800:1a5::366 Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.2.49.236|:443... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm?AuthParam=1555135696_27e878e8049f0de9d502264a11cb8683 [following] --2019-04-13 01:06:14-- http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm?AuthParam=1555135696_27e878e8049f0de9d502264a11cb8683 Connecting to download.oracle.com (download.oracle.com)|104.73.166.201|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm?AuthParam=1555135696_27e878e8049f0de9d502264a11cb8683 [following] --2019-04-13 01:06:14-- https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm?AuthParam=1555135696_27e878e8049f0de9d502264a11cb8683 Connecting to download.oracle.com (download.oracle.com)|104.73.166.201|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 176209195 (168M) [application/x-redhat-package-manager] Saving to: ‘jdk-8u201-linux-x64.rpm’ 100%[==========================================================================>] 176,209,195 6.84MB/s in 24s 2019-04-13 01:06:38 (7.04 MB/s) - ‘jdk-8u201-linux-x64.rpm’ saved [176209195/176209195] [setup@c7 jvm]$ sudo yum localinstall jdk-8u201-linux-x64.rpm Loaded plugins: fastestmirror Examining jdk-8u201-linux-x64.rpm: 2000:jdk1.8-1.8.0_201-fcs.x86_64 Marking jdk-8u201-linux-x64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package jdk1.8.x86_64 2000:1.8.0_201-fcs will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================== Package Arch Version Repository Size ==================================================================================================================== Installing: jdk1.8 x86_64 2000:1.8.0_201-fcs /jdk-8u201-linux-x64 288 M Transaction Summary ==================================================================================================================== Install 1 Package Total size: 288 M Installed size: 288 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2000:jdk1.8-1.8.0_201-fcs.x86_64 1/1 Unpacking JAR files... tools.jar... plugin.jar... javaws.jar... deploy.jar... rt.jar... jsse.jar... charsets.jar... localedata.jar... Verifying : 2000:jdk1.8-1.8.0_201-fcs.x86_64 1/1 Installed: jdk1.8.x86_64 2000:1.8.0_201-fcs Complete!
- Log in to post comments