简体   繁体   English

Maven本地存储库代理外部

[英]maven local repository proxy external

I am supporting an Archiva internal repository in an organization where some build environments don't have access to the open internet to fetch dependencies. 我在一个组织中支持Archiva内部存储库,在该组织中某些构建环境无法访问开放的Internet来获取依赖项。 I thought I could configure Archiva as a mirror for everything external (mirror with mirrorOf set to "external.*,!snapshots") and set it up with proxies so that, if one of my builds asks for something that is not in Archiva, it will use the proxies to go get the dependencies from the external sources I set up with proxies. 我以为可以将Archiva配置为所有外部组件(mirrorOf的镜像设置为“ external。* ,! snapshots”)的镜像,并使用代理进行设置,这样,如果我的其中一个版本要求的内容不在Archiva中,它将使用代理从我用代理设置的外部源获取依赖项。 After that, it would be cached in Archiva and would not have to be fetched from outside. 之后,它将被缓存在Archiva中,而不必从外部获取。

So I have proxies in my Archiva config for codehaus, sonatype (several), the basic Central, Cloudera for Hadoop stuff etc.; 因此,我在Archiva配置中有用于代码库,sonatype(多个),基本Central,用于Hadoop的Cloudera等代理。 but I can't find a configuration that keeps my builds from trying to go directly to the external sources (which they can't reach) and yet satisfies the things that are not already in my Archiva by using the proxies. 但是我找不到一种配置,可以阻止我的构建直接尝试访问外部资源(它们无法访问),却无法通过代理满足Archiva中尚未存在的内容。

Is there some trick configuration I'm missing here? 我这里缺少一些技巧配置吗? Or do I need to switch to Artifactory or Nexus to get this kind of functionality? 还是我需要切换到Artifactory或Nexus才能获得这种功能?

You need to set the maven settings on each of the build environments to point to your archiva instance. 您需要在每个构建环境上设置Maven设置以指向您的archiva实例。
eg in $user.home/.m2/settings.xml 例如在$ user.home / .m2 / settings.xml中

<mirror>
  <id>InternalMirror</id>
  <mirrorOf>*</mirrorOf>
  <name>Internal Mirror.</name>
  <url>http://archivaserver/archivaPath/</url>
</mirror>

I haven't used Archiva before, but I have done this successfully with Nexus 我以前从未使用过Archiva,但是我已成功通过Nexus成功完成此操作

Switching to a nexus will be moer preferable. 切换到联系将是更可取的。

I have attached a settings.xml which can be used for nexus.... 我已经附上了可用于联系的settings.xml。

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>F:\m2\repository</localRepository>

    <pluginGroups>
                <pluginGroup>org.codehaus.sonar</pluginGroup>
        </pluginGroups>


    <proxies>
        <proxy>
            <active>true</active>
            <protocol>http</protocol>
            <host>your-host-id</host>
            <port>8080</port>
        </proxy>
    </proxies>

    <mirrors>
    <mirror>
        <id>nexus</id>
        <mirrorOf>*,!sonar</mirrorOf>
        <url>http://nexus-repo-url/content/groups/public</url>
        <name>Nexus</name>
    </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>NexusProfile</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.5</jdk>
            </activation>
            <repositories>
                <repository>
                  <snapshots>
                    <enabled>true</enabled>
                  </snapshots>
                  <releases>
                    <enabled>true</enabled>
                  </releases>
                  <id>nexus</id>
                  <name>default-repos</name>
                  <url>http://nexus-repo-url/content/groups/default-repos</url>
                </repository>
                <repository>
                  <snapshots>
                    <enabled>true</enabled>
                  </snapshots>
                  <releases>
                    <enabled>true</enabled>
                  </releases>
                  <id>nexus</id>
                  <name>default-repos</name>
                  <url>http://nexus-repo-url/content/groups/default-repos</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                  <snapshots>
                    <enabled>true</enabled>
                  </snapshots>
                  <releases>
                    <enabled>true</enabled>
                  </releases>
                  <id>nexus</id>
                  <name>default-repos</name>
                  <url>http://nexus-repo-url/content/groups/default-repos</url>
                </pluginRepository>
                <pluginRepository>
                  <snapshots>
                    <enabled>true</enabled>
                  </snapshots>
                  <releases>
                    <enabled>true</enabled>
                  </releases>
                  <id>nexus</id>
                  <name>default-repos</name>
                  <url>http://nexus-repo-url/content/groups/default-repos</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>NexusProfile</activeProfile>
    </activeProfiles>


    <servers>
        <server>
            <id>nexus</id>
            <username>anonymous</username>
            <password>password</password>
        </server>
    </servers>
</settings>

I recommend you read http://maven.apache.org/guides/mini/guide-mirror-settings.html for configuring your settings. 我建议您阅读http://maven.apache.org/guides/mini/guide-mirror-settings.html来配置设置。 And I recommend you to use Archiva 1.4 version series which is more performant. 并且我建议您使用性能更高的Archiva 1.4版本系列。 We are currently rewriting the ui see a real sample https://archiva-repository.apache.org/archiva/index.html?request_lang=en . 我们目前正在重写ui,请参阅真实示例https://archiva-repository.apache.org/archiva/index.html?request_lang=en If you want your own version you must download a snapshot from here: https://builds.apache.org/view/AF/view/Archiva/job/archiva-all-maven-3.x-jdk-1.6/ 如果要使用自己的版本,则必须从此处下载快照: https : //builds.apache.org/view/AF/view/Archiva/job/archiva-all-maven-3.x-jdk-1.6/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM