morpheus
morpheus

Reputation: 20330

mvn dependency:tree tries to get artifact from artifactory when it shouldn't

I have a moderate sized project with many modules depending on each other. When I run mvn compile or mvn package it works, but when I try to run mvn dependency:tree from the root directory it fails complaining that it cannot get an artifact from artifactory. Its true that the artifact does not exist in artifactory. It is one of the modules that I have written and that is a dependency of another module in my project. Why is mvn dependency:tree searching for this module in the artifactory when it should recognize that this is a first-party module? mvn package does not complain. Please advise. The maven error is like this
[ERROR] Failed to execute goal on project XXX: Could not resolve dependencies for project XXX: Could not transfer artifact YYY from/to repo (ZZZ): Failed to transfer file: YYY. Return code is: 503 , ReasonPhrase:Error. -> [Help 1]

This is my settings.xml in case its needed:

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

    <mirrors>
        <mirror>
            <mirrorOf>external:*</mirrorOf>
            <name>repo</name>
            <url>http://XXX/artifactory/repo/</url>
            <id>repo</id>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>Artifactory Central</name>
                    <url>http://XXX/artifactory/libs-release/</url>
                </repository>

                <repository>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <id>snapshots</id>
                    <name>Artifactory Snapshots</name>
                    <url>http://XXX/artifactory/libs-snapshot/</url>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>Artifactory Plugins Central</name>
                    <url>http://XXX/artifactory/plugins-release/</url>
                </pluginRepository>

                <pluginRepository>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <id>snapshots</id>
                    <name>Artifactory Plugins Snapshots</name>
                    <url>http://XXX/artifactory/plugins-snapshot/</url>
                </pluginRepository>
            </pluginRepositories>

            <id>artifactory</id>
        </profile>
    </profiles>

  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

Upvotes: 0

Views: 2986

Answers (2)

morpheus
morpheus

Reputation: 20330

This is same issue as Maven doesn't recognize sibling modules when running mvn dependency:tree and the answer is to run:

mvn compile dependency:tree

(source: https://stackoverflow.com/a/1905927/147530)

Upvotes: 1

sunny
sunny

Reputation: 1945

'mvn package' skips 'validate' phase of Maven cycle.

This way you succeed with 'mvn package' and you never knew about any 'validate' issue.

Upvotes: 0

Related Questions