多模块项目无法解析的依赖Maven站点 [英] Maven site on multi module project could not resolve dependency

查看:275
本文介绍了多模块项目无法解析的依赖Maven站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的连续集成作业(哈德森)分成两个步骤。 (因为随着构建和报告一起运行时间过长)。
在第一份工作,我建我的多模块Maven项目与MVN套装成功。
然后我我的工作空间复制到另一个位置,并尝试只与目标网站和/或FindBugs的/的Checkstyle / PMD创建报表重新编译项目。
但是,这并不工作! Maven的无法解析的依赖我的子模块的
(但是,所有的JAR文件都在目标文件夹中可用。)

例如:
我的结构是这样的:




    • A


    • C

    • D


项目C具有作为依赖B项目。

当我构建MVN网站的一切,它生成项目A和B的所有报告。但在与错误信息的项目C.叫停无法解析项目B.依赖
但是,项目B已经建造了MVN套装。即我能找到项目B的JAR文件中的目标文件夹。

有什么办法来解决从子模块B上的依赖没有MVN安装?
(我不想做我的CI服务器上。我担心这可能是危险的具有相同code碱基其他工作。)

更新12年8月20日:

根文件夹的POM:

<项目的xmlns =htt​​p://maven.apache.org/POM/4.0.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instanceXSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd>
    < modelVersion> 4.0.0< / modelVersion>
    <名称>&符LT; /名称>
    <&的groupId GT;富< /的groupId>
    <&的artifactId GT;巴≤; / artifactId的>
    <&版GT; 1.0 LT; /版本>
    <包装和GT; POM< /包装>
    <模块>
        <&模块GT亲代LT; /模块>
    < /模块>
< /项目>

父POM:

<项目的xmlns =htt​​p://maven.apache.org/POM/4.0.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance
    XSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
    < modelVersion> 4.0.0< / modelVersion>
    <名称>&符LT; /名称>
    <&的groupId GT;富< /的groupId>
    <&的artifactId GT亲代LT; / artifactId的>
    <&版GT; 1.0 LT; /版本>
    <包装和GT; POM< /包装>
    <模块>
        <&模块GT; ../酒吧-A< /模块>
        <&模块GT; ../酒吧B< /模块>
        <&模块GT; ../酒吧℃下/模块>
        <&模块GT; ../酒吧D< /模块>
    < /模块>
    [...]
    <报告>
        <&插件GT;
            <&插件GT;
                <的groupId方式>组织codehaus.mojo< /的groupId>
                <&的artifactId GT; FindBugs的-Maven的插件< / artifactId的>
                <&版GT; 2.5.1< /版本>
                [...]
            < /插件>
            <&插件GT;
                <&的groupId GT; org.apache.maven.plugins< /的groupId>
                <&的artifactId GT;的maven-PMD-插件< / artifactId的>
                <&版GT; 2.7.1< /版本>
                [...]
            < /插件>
            <&插件GT;
                <&的groupId GT; org.apache.maven.plugins< /的groupId>
                <&的artifactId GT;的maven-Checkstyle的-插件< / artifactId的>
                <&版GT; 2.9.1< /版本>
                [...]
            < /插件>
        < /插件>
    < /报告>
< /项目>

的B POM:

<项目的xmlns =htt​​p://maven.apache.org/POM/4.0.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instanceXSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd>
    < modelVersion> 4.0.0< / modelVersion>
    &所述亲本GT;
        <&的groupId GT;富< /的groupId>
        <&的artifactId GT亲代LT; / artifactId的>
        <&版GT; 1.0 LT; /版本>
        < relativePath> ../父< / relativePath>
    < /母体GT;
    <名称>酒吧B< /名称>
    <&的artifactId GT;酒吧B< / artifactId的>
    <&版GT; 1.0 LT; /版本>
    <包装和GT;&罐子LT; /包装>
    [...]
< /项目>

的C POM:

<项目的xmlns =htt​​p://maven.apache.org/POM/4.0.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance
    XSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
    < modelVersion> 4.0.0< / modelVersion>
    &所述亲本GT;
        <&的groupId GT;富< /的groupId>
        <&的artifactId GT亲代LT; / artifactId的>
        <&版GT; 1.0 LT; /版本>
        < relativePath> ../父< / relativePath>
    < /母体GT;
    <名称>酒吧℃下/名称>
    <&的artifactId GT;酒吧℃下/ artifactId的>
    <包装和GT;&罐子LT; /包装>
    [...]
    <依赖和GT;
        <&依赖性GT;
            <&的groupId GT;富< /的groupId>
            <&的artifactId GT;酒吧B< / artifactId的>
            <&版GT; 1.0 LT; /版本>
        < /依赖性>
    < /依赖和GT;
    [...]
< /项目>


解决方案

我面临完全一样很长时间的问题。

只有这样,(我认为)与您的工作方式确实MVN安装解决它,因为你的建议吧。

但问题是你确实尝试有不同的行为与复制您的工作空间的方式。
而应该考虑到CI将建立和经常你想要的(每提交或每隔一小时)进行测试,但要报告只是一个时间(每个午夜为例)。你将能够有更快的连续构建,并在夜间正确的文件和报告。

这是我们的工作方式,这是相当足够。我们使用詹金斯对于这一点,但你可以与每一个CI软了,我认为)触发它!

  @hourly:MVN清洁套装(或安装) -  GT;从1到5分钟,以运行在所有模块中的所有测试
@daily:MVN全新安装的站点 - >从15到35分钟上运行的所有模块+ DOC + +报告PDF报告所有测试

您也可以使用配置文件来触发不同的行为,但这是这样一个基本使用太多复杂的。

I want to split my continous integration job (Hudson) into two steps. (Because the runtime with build and reporting together takes too long.) In the first job, I build my multi module maven project with "mvn package" successfully. Then I copy my workspace to another location and try to build the project again only with the goal "site" and/or findbugs/checkstyle/pmd to create reports. But this doesn't work! Maven can't resolve a dependency of my submodules. (But all JARs are available in its target folders.)

Example: My structure looks like this:

  • Parent
    • A
    • B
    • C
    • D

Project C has as dependency project B.

When I build everything with "mvn site", it generates for project A and B all reports. But halted at project C with error message "Could not resolve dependencies for project B." But project B is already builded with "mvn package". I.e. I can find the JAR file of project B in its target folder.

Is there any way to resolve the dependency from submodule B without a "mvn install"? (I don't wanna do this on my ci server. I fear it could be dangerous for other jobs with the same code base.)

Update 08/20/12:

POM of root folder:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>Foo</name>
    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <modules>
        <module>parent</module>
    </modules>
</project>

Parent POM:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>Foo</name>
    <groupId>foo</groupId>
    <artifactId>parent</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <modules>
        <module>../bar-a</module>
        <module>../bar-b</module>
        <module>../bar-c</module>
        <module>../bar-d</module>
    </modules>
    [...]
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.5.1</version>
                [...]
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.7.1</version>
                [...]
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.9.1</version>            
                [...]
            </plugin>
        </plugins>
    </reporting>
</project>

POM of B:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>foo</groupId>
        <artifactId>parent</artifactId>
        <version>1.0</version>
        <relativePath>../parent</relativePath>
    </parent>
    <name>Bar B</name>
    <artifactId>bar-b</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>  
    [...]
</project>

POM of C:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>foo</groupId>
        <artifactId>parent</artifactId>
        <version>1.0</version>
        <relativePath>../parent</relativePath>
    </parent>
    <name>Bar C</name>
    <artifactId>bar-c</artifactId>
    <packaging>jar</packaging>
    [...]
    <dependencies>
        <dependency>
            <groupId>foo</groupId>
            <artifactId>bar-b</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
    [...]
</project>

解决方案

I was facing quite the same "long time" issue.

The only way (I think) to solve it with your way of working is indeed mvn install, as you suggested it.

But the problem is indeed the way you try to have different behaviours with copying your workspace. You should instead considering that CI will build and test as often as you want (each commit or every hour), but make reporting just one time (each midnight for example). You would be able to have faster continous builds, and correct documentation and reporting by night.

This is the way we work, and it is quite sufficient. We use jenkins for that, but you could trigger it with every CI soft I think) !

@hourly : mvn clean package (or install) --> from 1 to 5 minutes to run all test on all modules
@daily : mvn clean install site -->  from 15 to 35 minutes to run all test on all modules + doc + reports + PDF reports

You can also use profiles to trigger different behaviours, but this is too much sophisticated for such a basic use.

这篇关于多模块项目无法解析的依赖Maven站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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