Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency resolution configuration in Artifactory

Recently we started to work with Artifactory. We configured settings.xml as Artifactory proposed. However we have problems downloading jars while running "mvn compile", even if they appear in Artifactory repo. Adding explicitly repo1-cache solves the compilation problem but download is performed from remote repository rather than from Artifactory.

<repository>
    <id>My Repository</id>
    <name>MyRepository-releases</name>
    <url>http://mvn-srv:8081/artifactory/repo1</url>
</repository>

What should be added to settings.xml in for resolving automatically dependencies and fetching them from artifactory rather than accessing remote servers each time?

settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
    <profile>
        <repositories>
            <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>http://mvn-srv:8081/artifactory/libs-release</url>
            </repository>
            <repository>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>http://mvn-srv:8081/artifactory/libs-snapshot</url>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>plugins-release</name>
                <url>http://mvn-srv:8081/artifactory/plugins-release</url>
            </pluginRepository>
            <pluginRepository>
                <snapshots />
                <id>snapshots</id>
                <name>plugins-snapshot</name>
                <url>http://mvn-srv:8081/artifactory/plugins-snapshot</url>
            </pluginRepository>
        </pluginRepositories>
        <id>artifactory</id>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>artifactory</activeProfile>
</activeProfiles>
<servers>
    <server>
        <id>MyRepository</id>
    </server>
</servers>

Compilation error:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.355s
[INFO] Finished at: Wed Nov 14 14:52:31 IST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project common: Could not resolve dependencies for project com.myc
ompany.app:common:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: commons-jxpath:co
mmons-jxpath:jar:1.3-osgi, xpp3:xpp3_min:jar:1.1.3.4.O-osgi, net.java.dev.stax-utils:stax-utils:jar:
20080702-osgi, net.sf.saxon:saxon:jar:8.9.0.4-osgi, net.sf.saxon:saxon-dom:jar:8.9.0.4-osgi, net.sf.
saxon:saxon-xqj:jar:8.9.0.4, dom4j:dom4j:jar:1.6.1-osgi, mx4j:mx4j-jmx:jar:2.1.1-osgi, mx4j:mx4j-imp
l:jar:2.1.1-osgi, mx4j:mx4j-tools:jar:2.1.1-osgi, mx4j:mx4j-remote:jar:2.1.1-osgi, com.yourkit:yjp-c
ontroller-api-redist:jar:9.0.8, org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1-osgi, common
s-codec:commons-codec:jar:1.3-osgi, commons-httpclient:commons-httpclient:jar:3.1-osgi, quartz:quart
z-all:jar:1.6.6: Could not find artifact commons-jxpath:commons-jxpath:jar:1.3-osgi in central (http
://mvn-srv:8081/artifactory/libs-release) -> [Help 1]
like image 945
Kobikis Avatar asked Nov 14 '12 13:11

Kobikis


2 Answers

Adding to @duncan-jones excellent answer, great way to troubleshoot resolution is performing Trace Artifact Retrieval call, in your case:

http://mvn-srv:8081/artifactory/libs-release/commons-jxpath/commons-jxpath/1.3-osgi/commons-jxpath-1.3-osgi.jar?trace

BTW, I don't even see the 1.3-osgi version in repo1.

like image 153
JBaruch Avatar answered Oct 10 '22 15:10

JBaruch


You need to ensure your virtual repositories map to the real repositories you expect.

For example, libs-release will typically map to both internal and external release repositories. Perhaps this is mis-configured, resulting in it not hitting the repositories you want.

In Artifactory, go to the Admin page and look at Configuration > Repositories. At the bottom of the page, take a look at your virtual repositories. Double-clicking on them will show you what is included.

For me, libs-release includes libs-release-local, ext-release-local and remote-repos. The latter is another virtual repository that maps to all the external repositories listed in my installation, e.g. codehaus, repo1, jboss, google-code, ...

Perhaps one of these virtual repositories is missing repo1?

like image 39
Duncan Jones Avatar answered Oct 10 '22 17:10

Duncan Jones