Setting Up Maven

For setting up maven to use artifactory proxy, just configure a maven repository with the following URL:

http://[your server name]:[port]/artifactory/repo

This URL will make artifactory look through all repositories (local and remote), for any artifacts maven is fetching.



But, you can also place the name of the local repository to limit artifactory search to this local repository and all remote repositories.

The maven repository URL should look like:

http://[your server name]:[port]/artifactory/[local repo name]

or the older deprecated format http://[your server name]:[port]/artifactory/[local repo name]@repo

If your artifactory is configured correctly, you should override the built-in central and snapshots repositories of Maven, so that no request will be sent directly to them.

Insert the following into your parent POM or settings.xml (under an active profile):

<repositories>
    <repository>
        <id>central</id>
        <url>http://[your server name]:[port]/artifactory/repo</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>snapshots</id>
        <url>http://[your server name]:[port]/artifactory/repo</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>http://[your server name]:[port]/artifactory/plugins-releases</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>snapshots</id>
        <url>http://[your server name]:[port]/artifactory/plugins-snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

With Maven 2.0.5 and above, you can use the new "mirror any" feature instead of the above, and have Artifactory act as a redirecting proxy for any Maven repository, including ones defined inside dependency POMs.

Insert the following into your settings.xml:

<mirrors>
    <mirror>
      <id>artifactory</id>
      <mirrorOf>*</mirrorOf>
      <url>http://<host>:<port>/artifactory/repo</url>
      <name>Artifactory</name>
    </mirror>
</mirrors>

ATTENTION: There seem to be (yet unverified) artifact resolution issues with using this technique under Maven 2.0.7. If you are using Maven 2.0.7, please prefer using the first technique (overriding the built-in central and snapshots repositories of Maven) which will work as expected.