使用本地工件更新Nexus存储库 [英] Update Nexus repository with local artifacts

查看:152
本文介绍了使用本地工件更新Nexus存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将一些Maven工件直接下载到了我的本地存储库(.m2/repository). 现在,我安装了Nexus Repository Manager,需要填充其存储空间,而无需再次下载所有工件.有没有一种方法可以使用本地库更新Nexus库. 我不想简单地复制它们,因为Nexus会分离有关其公共服务器(中央服务器,codehaus等)的工件,而本地存储库结构则不会.

i recently downloaded some maven artifacts directly to my local repository (.m2/repository). Now i installed the Nexus Repository Manager and need to fill its storage without to download all the artifacts again. Is there a way to update the Nexus repository with the local one. I don't want to simply copy them because Nexus separate artifacts concerning their public servers (central, codehaus, etc.) and the local repository structure doesn't.

更新: 同时,我将工件从本地存储库复制到Nexus存储(公共存储库).我可以通过Nexus Web应用程序浏览到工件,但是Maven无法以某种方式从Nexus解析工件. 我需要特别注册吗?我为公共存储库重新编制了索引,并多次重新启动了Nexus-没有更改.

Update: Meanwhile i copied the the artifacts from the local repository to the Nexus storage (public repository). I can browse to the artifacts via the Nexus webapp, but Maven somehow can't resolve the artifacts from Nexus. Do i need to register them particularly? I re-indexed the public repository and restarted Nexus multiple times - no changes.

推荐答案

Nexus有几种类型的存储库:托管存储库(确实存储Maven工件的存储库),代理存储库(当请求工件时,将流量重定向到其他远程存储库),虚拟存储库(仅是maven1存储库的适配器[不在此问题范围内]).您还可以创建存储库组,这些存储库组可以从其任何聚合中提供工件(public存储库是其中之一).

Nexus has several type of repositories: hosted repositories (those that really store maven artifacts), proxy repositories (that redirect traffic to other remote repositories when an artifact is requested), virtual repositories (a mere adapter of maven1 repositories [out of the scope of this question]). you can also create repository groups that can serve artifacts from any of its aggregates (the public repository is one of these).

此外,nexus根据发布策略将其存储库分为快照发行版.前者仅存储快照工件;后者仅存储快照工件.虽然从理论上讲,后者可以存储快照和发行版,但是当存储库很大且包含快照时,它实际上会表现出错误.

In addition, nexus divides their repositories according to its publishing policy into snapshots and releases. The former stores only snapshot artifacts; while the latter, in theory, can store both snapshots and releases, but it actually behaves buggy when the repo is very big and contains snapshots.

要托管您的工件,您需要:

In order to host your artifacts you need to:

首先:将本地存储库分为两个:一个包含快照,另一个包含发行版.如果您的仓库很大,那么Nexus仓库转换工具将为您提供帮助:

First: Divide your local repository into two: one containing the snapshots, and another containing the releases. Nexus repository convertion tool will help you if your repo is very big:

    <dependency>
        <groupId>org.sonatype.nexus.tools</groupId>
        <artifactId>nexus-repository-conversion-tool</artifactId> 
        <version>1.8.0.1</version>
        <classifier>cli</classifier> 
    </dependency>

一旦更新,您只需执行java -jar nexus-repository-conversion-tool-1.8.0.1-cli.jar -rSource -oTarget,其中Source是包含要移至nexus的本地存储库的目录,而Target是现有的,空的且可写的目录,转换工具将在其中保留分割后的存储库.假设源目录为repository,目标目录为temp,它将创建temp/repository-snapshotstemp/repository-releases目录.

Once downlaoded you can just execute java -jar nexus-repository-conversion-tool-1.8.0.1-cli.jar -rSource -oTarget where Source is the directory that contains the local repository to move to nexus, and Target is an existing, empty and writable directory where the convertion tool will leave the splitted repositories. Provided that source directory is repository and Target is temp, it will create temp/repository-snapshots and temp/repository-releases directories.

第二步::将拆分后的存储库移至联系.并将它们保留在${NEXUS_HOME}/sonatype-work/nexus/storage中,或将您的nexus安装配置为存储存储库的任何位置.

Second: move your splitted repos to nexus. And leave them in ${NEXUS_HOME}/sonatype-work/nexus/storage, or wherever your nexus installation is configured to store the repositories.

第三步::创建两个托管存储库,其ID与您在第二步中移动的存储库相同. (在示例repository-snapshotsrepository-releases中)

Third: create two hosted repositories with the same id as the repos you moved in the second step. (in the example repository-snapshots and repository-releases)

如果您的回购仅包含发行版,则您的解决方案可能会起作用,但是您将犯下另一个错误.尽管nexus会为每个存储库存储工件,但那些非托管存储库的存储对象只是出于缓存目的(例如public存储库),您必须将内容复制到托管对象中才能工作.

If your repo would only contained releases, your solution could have worked, but you will have commited another mistake. Although nexus stores artifacts for every repository, the storage of those that aren't hosted repos is just for caching purposes (as in the case of the public repository), you would have to copied your contents to a hosted one in order to work.

这篇关于使用本地工件更新Nexus存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆