Nexus

The world’s best way to organize, store, and distribute software components.

Nexus

download->install: install->start:

download

download

Install methods:

  • A bundle with Jetty, only need JRE. I choose this way nexus-2.13.0-01-bundle.tar.gz;

  • War, deploy on web is okay.

install

Unzip the file at where you want. There are two folder:

  • nexus-2.13.0-01 contains what Nexus run needed.

  • sonatype-work contains the config, repository, log files.

start

Enter the bin folder, in ~/nexus-2.13.0-01/bin, run the nexus you may get:

houbinbindeMacBook-Pro:~ houbinbin$ /Users/houbinbin/IT/learn/nexus/nexus-2.13.0-01-bundle/nexus-2.13.0-01/bin/nexus ; exit;
Usage: /Users/houbinbin/IT/learn/nexus/nexus-2.13.0-01-bundle/nexus-2.13.0-01/bin/nexus { console | start | stop | restart | status | dump }
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

so, just run following command to start the nexus serve.

/Users/houbinbin/IT/learn/nexus/nexus-2.13.0-01-bundle/nexus-2.13.0-01/bin/nexus start

You can edit the port in file nexus.properties in the path of:

~/nexus/nexus-2.13.0-01-bundle/nexus-2.13.0-01/conf

visit

Input the url in your browser, then you can visit the dashboard of nexus.

http://127.0.0.1:8081/nexus

nexus dashboard

login

You can login the nexus on the right top place, the default admin is:

usr:    admin
pwd:    admin123

Config

intro zh_CN

3rd zh_CN

setting zh_CN

1、Set all remote repository use internal repository in setting.xml.

<!--setting maven only use internal repository-->
<mirrors>
    <mirror>
        <id>central</id>
        <name>central-mirror</name>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <!--this profile will allow snapshots to be searched when activated-->
        <id>public-snapshots</id>
        <repositories>
            <repository>
                <id>public-snapshots</id>
                <url>http://localhost:8081/nexus/content/groups/public</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>public-snapshots</id>
                <url>http://localhost:8081/nexus/content/groups/public</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>public-snapshots</activeProfile>
</activeProfiles>

Repository

nexus dashboard

Remote Repository

  • set in pom.xml
<repositories>
    <repository>
        <id>nexus</id>
        <name>Team Nexus Repository</name>
        <url>http://localhost:8081/nexus/content/groups/public</url>
        <releases><enabled>true</enabled></releases>
        <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>ignore</checksumPolicy>
            <updatePolicy>daily</updatePolicy>
        </snapshots>
    </repository>
</repositories>
  • authentication in maven setting.xml
<settings>
    <!--...-->
    <servers>
        <server>
            <id>my-auth</id>
            <username>usr</username>
            <password>pwd</password>
        </server>
    </servers>
</settings>

There must be a server in setting.xml that it’s id equals pom.xml, ad=nd right authentication info.

  • deploy to remote repository in pom.xml
<distributionManagement><repository><id>releases</id>
        <name>Nexus Releases Repository</name><url>http://localhost:8081/nexus/content/repositories/releases/</url></repository><snapshotRepository><id>snapshots</id>
        <name>Nexus Snapshots Repository</name>
        <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

then, use following command can deploy it.

mvn clean deploy

It need auth when deploy.

<servers>
    <server>
        <id>releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
</servers>

默认角色:

1) admin :对 Nexus 服务的完全控制权限,默认密码为 admin123

2) deployment :能够访问 Nexus ,浏览仓库内容,搜索并且上传部署构件但无法配置 Nexus ,默认密码为: deployment123

3) anonymous :对应所有未登录用户,可以浏览和搜索仓库

Jar包存储地址默认为:

~/nexus/nexus-2.13.0-01-bundle/sonatype-work/nexus/storage

Mirror

Everything we can get from the X repository, can also get from it’s mirror.

Actual my like this:

<mirrors>
  <mirror>
    <id>nexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://localhost:8081/nexus/content/groups/public</url>
  </mirror>
</mirrors>
  1. <mirrorOf>*</mirrorOf> Match all remote repository.

  2. <mirrorOf>external: *</mirrorOf> Match all not localhost’s remote repository.

  3. <mirrorOf>repo1, repo2</mirrorOf> Match repo1 and repo2 …

  4. <mirrorOf>*, !repo1</mirrorOf> Match all except repo1.

注: 这个一般不用修改。

Tips

  • Cannot deploy artifacts when Maven is in offline mode

Enter Command+, to search maven, dis-select Work offline.

  • 上传三方jar到

third jar

点击【Add Artifact】-》点击【Upload Artifact(s)】