javamavenpom.xmlmaven-dependency-plugin

Excluding some dependency from mvn dependency:resolve


In my pom.xml of com.test:Service:1.0, I have a dependency on some local jar: com.test:Parser:1.0

I want to resolve all dependencies except for it, since I install it manually to my local maven. Resolve command:

mvn -B dependency:resolve -DincludeParents=true

But it fails on:

[ERROR] Failed to execute goal on project Service: Could not resolve dependencies for project com.test:Service:jar:1.0: Could not find artifact com.test:Parser:jar:1.0 in central (https://repo.maven.apache.org/maven2)

Then I tried to add the options

-DexcludeGroupIds=com.test -DexcludeArtifactIds=Parser

but am still getting the same error. Am I misusing the options?

Reference: http://maven.apache.org/plugins/maven-dependency-plugin/resolve-mojo.html


Solution

  • This seems to simply be a bug. See

    https://issues.apache.org/jira/browse/MDEP-568

    https://github.com/apache/maven-dependency-plugin/pull/2

    The solution, as proposed in the above threads, is to use a different library: https://github.com/qaware/go-offline-maven-plugin

    In your pom.xml add the plugin:

                <plugin>
                    <groupId>de.qaware.maven</groupId>
                    <artifactId>go-offline-maven-plugin</artifactId>
                    <version>1.2.1</version>
                    <configuration>
                        <dynamicDependencies>
                        </dynamicDependencies>
                    </configuration>
                </plugin>
    

    Then use the command mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies with the required options.