简体   繁体   中英

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. 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. After that, it would be cached in Archiva and would not have to be fetched from outside.

So I have proxies in my Archiva config for codehaus, sonatype (several), the basic Central, Cloudera for Hadoop stuff etc.; 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.

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?

You need to set the maven settings on each of the build environments to point to your archiva instance.
eg in $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

Switching to a nexus will be moer preferable.

I have attached a settings.xml which can be used for nexus....

<?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. And I recommend you to use Archiva 1.4 version series which is more performant. We are currently rewriting the ui see a real sample 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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