nexus proxy repository

 

 1. Install and download nexus 

   1.1 Download nexus

   Visit http://nexus.sonatype.org/downloads/, I downloaded the nexus-3.0.2-02-unix.tar.gz version

   1.2 Install nexus

   tar -zxvf nexus-3.0.2-02-unix.tar.gz

   ln -s  nexus-3.0.2-02 nexus (make a soft link)

   1.3 Running nexus

   Start nexus is to start a jetty server, the default port is 8081, ./bin/nexus run

....nexus3.0 requires jdk1.8 or above to support, silently download a nexus-2.14.0-01-bundle.tar package

     The command to start nexus 2.14 is ./bin/nexus start, it may take a few minutes for the first start

    Enter http://ip:8081/nexus in the browser, you will see the following interface

    

 

   1.4 Login to nexus

    Click log in in the upper right corner, enter the username amdin password admin123 to log in

  1.5 Change the default configuration of nexus

      1.5.1 Change password

             Click admin->profile in the upper right corner, click change password in the page that appears

       1.5.2 Enable remote index download

            Nexus comes with three important proxy repositories, the central Maven repository, the Apache snapshot repository, and the Codehaus snapshot repository. Each of these repositories contains thousands (or tens of thousands) of artifacts, and it would be impractical to download everything from each repository. For this reason, most repositories maintain a Lucene index of the entire content to provide fast and efficient search. Nexus uses these remote index search widgets, but by default we turn off index downloads. To download a remote index

             1. Open the Repositories tab, select the remote repository and open Configuration, set Download Remote Location to true

       

    
2. Right-click on the remote warehouse and select Update Index, Nexus will automatically create a task plan; generally, the remote warehouse is relatively large, there will be more builds, and the index file will be large, like http://repo1.maven.org/maven2/ There are hundreds of M, so the time required is relatively long.

     

      You can enter Scheduled Tasks to view the execution of the task. When the execution is completed, the index of the remote warehouse has been established. (The automatic update is too slow, it is recommended to update manually)


 After downloading the index, you can see it from the browse index

    2. Manual update

         Download
            nexus-maven-repository-index.gz
            nexus-maven-repository-index.properties from http://repo.maven.apache.org/maven2/.index/
          and then download an indexer-cli-5.1.0. The download address of jar
          indexer: http://maven.outofmemory.cn/org.apache.maven.indexer/indexer-cli/5.1.0/
          Place the above three files (.gz & .properties & .jar) in the same directory, run the following command

          java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
        delete all the files under {nexus_home}\sonatype-work\nexus\indexer\central-ctx and execute it After that, copy everything under indexer to %nexus-home%\sonatype-work\nexus\indexer\central-ctx
        

        Restart nexus, enter the management interface, select central->Browse Index, and you will see the updated index. 

2. Manage the warehouse

           Agency warehouse

             A proxy repository is a proxy to a remote repository. By default, Nexus comes with a proxy repository configured as follows:

             Apache Snapshots

            This repository contains snapshot releases from the Apache Software Foundation. http://people.apache.org/repo/m2-snapshot-repository Codehaus Snapshots This repository contains snapshot versions from Codehaus. http://snapshots.repository.codehaus.org/ _

            Central Maven Repository

             This is the central Maven repository (release version). http://repo1.maven.org/maven2/

          host repository

               A hosting repository is a repository hosted by Nexus. Maven comes with a host repository configured as follows.

          3rd Party

               This host repository should be used to store third-party dependencies not found in the public Maven repository. Examples of such dependencies are: your organization's use of commercial, proprietary class libraries such as the Oracle JDBC driver.

          Releases

               This host repository is where your organization publishes internal releases.

         Snapshots

                This host repository is where your organization publishes internal snapshot versions.

       virtual warehouse

               A virtual repository exists as an adapter for Maven 1. Nexus comes with a central-m1 virtual warehouse .

      Type:

      hosted, local proxy repository, usually we deploy our own components to this type of repository.

      proxy, proxy remote repositories, they are used to proxy remote public repositories, such as maven central repositories.

      group, warehouse group, is used to combine multiple hosted/proxy warehouses, usually we configure maven to depend on warehouse groups.

3. Deploy the build to nexus   

     3.1 Deploy release version

         You need to configure distributionManagement. With this configuration, the project can execute the mvc deploy command.        

<project>
...
<distributionManagement>
...
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
...
</distributionManagement>
...
</project>

    Nexus can support multiple host repositories; you don't need to stick to the default releases and snapshots repositories . You can create different host repositories for different departments and then combine multiple repositories into a single Nexus group.

      3.2 Deploying snapshot versions

       If your project's version is a snapshot version (eg 1.0-SNAPSHOT) Maven will deploy it to the snapshotRepository:

 

<project>
...
<distributionManagement>
...
<snapshotRepository>
<id>Snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
...
</distributionManagement>
...
</project

       3.3部署第三方构件

       DgroudId 和artifactId分别代表第三方构件的id

 mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
> -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar \
> -Durl=http://localhost:8081/nexus/content/repositories/thirdparty \
> -DrepositoryId=thirdparty

 

 

 

   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326449522&siteId=291194637