mvn依赖项:在琐碎的项目上树失败 [英] mvn dependency:tree fails on trivial project

查看:108
本文介绍了mvn依赖项:在琐碎的项目上树失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常复杂的项目(大约100个模块),我想在该项目上运行mvn dependency:tree.它失败,抱怨无法解决的依赖关系.否则该项目可以编译.因此,我创建了我可以提出的最基本的项目,但它仍然失败,并出现相同的错误.显然,我必须做一些非常基本的错误,或者 maven-dependency-plugin 尚未被任何人使用.这是按测试项目的三个POM:

I've got a pretty complex project (about 100 modules) on which I'd like to run mvn dependency:tree. It fails, complaining about dependencies it cannot resolve. The project otherwise compiles fine. So I created the most basic project I could come up and it still fails with the same error. Obviously either I must be doing some very basic mistake or the maven-dependency-plugin has not been used by anyone yet. Here are the three POMs im by test project:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>root</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>foo</module>
        <module>bar</module>
    </modules>
</project>

foo/pom.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>foo</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
</project>

bar/pom.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>bar</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>foo</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

然后我在顶级目录中发出以下命令mvn dependency:tree并获得以下输出:

Then I issue the following command mvn dependency:tree in the top-level directory and get the following output:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] foo
[INFO] bar
[INFO] root
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building foo 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ foo ---
[INFO] com.example:foo:jar:1.0.0-SNAPSHOT
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building bar 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] foo ................................................ SUCCESS [  0.756 s]
[INFO] bar ................................................ FAILURE [  0.011 s]
[INFO] root ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.065 s
[INFO] Finished at: 2015-03-03T16:19:18+01:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project bar: Could not resolve dependencies for project com.example:bar:jar:1.0.0-SNAPSHOT: Could not find artifact com.example:foo:jar:1.0.0-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :bar

我想念什么?这不行吗?

What am I missing? Shouldn't this just work?

推荐答案

我很沮丧为什么它不起作用.
简单的依赖关系分析无法正常工作.
而且该官员对此没有任何指导.
另一个非常有用的命令也不起作用

I'm frustrated why it didn't work.
A simple dependency analysis just didn't work.
And the official has no any guide how to do it.
Another much usefully command didn't work neither

mvn dependency:resolve

但是,也许您可​​以尝试使用这些命令

but, maybe you could try these commands instead

mvn test-compile dependency:resolve
mvn test-compile dependency:tree

无论如何,它对我有用

2017年3月13日更新

通过跳过编译,我们可以使其更快

We can make it much more faster by skipping the compilation

 mvn test-compile dependency:resolve -Dmaven.main.skip=true -Dmaven.test.skip=true
 mvn test-compile dependency:tree    -Dmaven.main.skip=true -Dmaven.test.skip=true

很遗憾,它对我们的项目不起作用,因为我们的项目使用的是kotlin,也许是kotlin的bug没有跳过编译,也许我应该将此错误报告给jetbrains.

So sad it didn't work for our project because our project was using kotlin, maybe it is kotlin's bug which didn't skip the compilation, maybe I should report this bug to jetbrains.

这篇关于mvn依赖项:在琐碎的项目上树失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆