从 mvn dependency:resolve 中排除一些依赖

Excluding some dependency from mvn dependency:resolve

在我的 pom.xml of com.test:Service:1.0 中,我依赖于一些本地 jar:com.test:Parser:1.0

我想解决除它之外的所有依赖项,因为我手动将它安装到本地 maven。解析命令:

mvn -B dependency:resolve -DincludeParents=true

但它失败了:

[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)

然后我尝试添加选项

-DexcludeGroupIds=com.test -DexcludeArtifactIds=Parser

但我仍然遇到同样的错误。我是否滥用了这些选项?

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

这似乎只是一个错误。参见

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

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

如上述线程中所提出的解决方案是使用不同的库:https://github.com/qaware/go-offline-maven-plugin

在你的 pom.xml 添加插件:

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

然后使用带有所需选项的命令mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies