在没有互联网连接的离线状态下运行Maven和Sonateype Nexus



我正在尝试使用nexus设置一个maven环境,以便maven从本地nexus存储库下载其工件。安装Maven和Nexus的机器由于安全原因没有互联网连接。

我的工作站上有一个类似的配置,它确实有互联网连接。我在这两台机器上都安装了Maven和Nexus。我还在~m2/settings.xml中更新了我的本地maven设置文件,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <proxies></proxies>
  <servers></servers>
  <pluginGroups></pluginGroups>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

我在安全服务器上运行了一个简单的"mvn安装",它抱怨缺少依赖项。这是意料之中的事,因为我还没有下载和上传任何工件到存储库中。

我想使用我的本地工作站下载工件,压缩它们,然后将它们上传到安全机器上的Nexus存储库。我在本地工作站上运行了"mvn-install",所有内容都已下载。现在我需要将本地工作站上的存储库复制到安全服务器上。

根据Nexus文档,文件夹$HOME/sonatype-work是"存储"位置。

  • 这个文件夹是我唯一需要复制到安全服务器才能复制存储库的文件夹吗
  • 还有其他文件需要我担心吗?例如配置文件
  • 我注意到,默认情况下,Nexus会禁用远程存储库。这是否意味着,如果我保持原样,我不需要做任何事情来阻止它从中央存储库下载任何东西

提前谢谢。

可以将本地存储库的内容上传到Nexus服务器的存储区域。您可能需要重新索引或重新生成存储库元数据(可以通过Nexus GUI调用的任务)。

然而。。。。我建议您考虑一种最终会减少维护的替代解决方案。

Nexus的专业版具有采购套件功能,使您能够创建内容受规则控制或基于参考构建的存储库。

打开防火墙,这样只有Nexus可以访问互联网。使您能够对任何第三方Nexus存储库进行开发控制访问。

最新更新