Application of Nexus Repository Manager

Installing and running Nexus Repository Manager is easy.You can either unzip the archive file into a directory where you have full access or install it using the Docker image.

Installation package download: https://help.sonatype.com/repomanager3/download
Installation reference documentation: https://help.sonatype.com/repomanager3

1, Download the installation package
https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

2, Unzip

tar xvzf nexus-3.19.1-01-unix.tar.gz

3, Modify the default configuration file (etc/nexus-default.properties) [optional]

This is mainly used to modify the port number

4, Modify the default configuration (bin/nexus.vmoptions) [optional]

Normally, no modification is required.

5, Modify jdk configuration [optional]
You can edit the bin/nexus script, find "INSTALL4J_JAVA_HOME_OVERRIDE", delete the hash, and specify the location of the JDK/JRE.

For example:

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/openjdk-8

6, Start

./nexus run

Using run causes nexus to run in the current shell.You can also use the start, stop, restart, force-reload, and status directives.

7, Access


The login password is in the file/data/sonatype/sonatype-work/nexus3/admin.password.




By default, enabling anonymous access allows unauthenticated download, browse, and search of repository content.You can change the privileges of unauthenticated users by editing the roles assigned to anonymous users.

Type column description:
1) Proxy
By default, a central repository is created for access over HTTPS ( The proxy repository for https://repo1.maven.org/maven2/).To reduce duplicate downloads and increase download speed for developers and CI servers, all other remote repositories accessed should also be proxied as proxy repositories.

2) hosted
The hosted Maven repository can be used to deploy your own components and third-party components.By default, two hosted Maven libraries are created, maven-releases and maven-snapshots.One for publishing and one for snapshot versions.

3) group
Repository groups allow you to expose aggregated content from multiple proxies and managed repositories and other repository groups using a single URL for tool configuration.It is recommended that all Maven repositories be exposed to users from the repository manager using repository groups without further client configuration.

8. Warehouse operation

9, used in Maven
1) Edit Maven's setting.xml file

<settings>
  <mirrors>
            <!—Configure a mirror to replace the central warehouse -->
            <mirror>
                <id>nexus</id>
                <name>nexus</name>
                <url>http://192.168.30.161:8081/repository/maven-public/</url>
                <mirrorOf>*</mirrorOf> 
            </mirror>
  </mirrors>
  <servers>
            <server>
                <id>nexus</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>realeases</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>snapshots</id>
                <username>admin</username>
                <password>123456</password>
            </server>
  </servers>
</settings>

2) Edit the pom.xml file under the project

    <!-- Remote warehouse address -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>
   <!-- Configure remote publishing to private services, mvn deploy -->
    <distributionManagement>
        <!-- Definition releases Coordinates of the library -->
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-releases/</url>
        </repository>
        <!-- Definition snapshots library -->
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

Plug-in unit

<!-- deploy Upload only jar Configuration of packages to remote warehouses -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                 <configuration>
                                    <!-- Update Metadata -->
                                    <updateReleaseInfo>true</updateReleaseInfo>
                                </configuration>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip default deploy Execution of plug-ins -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- Development phase upload to snapshot Warehouse, upload to online stage release Warehouse -->
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

This allows you to upload jar packages to a private service repository via MVM deployment.

Tags: Programming nexus Maven snapshot Unix

Posted on Tue, 03 Dec 2019 11:35:23 -0800 by hubardz