不同的构建导致多模块maven项目

时间:2014-04-17 09:38:03

标签: java maven classpath multi-module

我有一个多项目maven结构,有一个父pom。 父pom只引用要构建的模块。这些模块有他们的子模块等(这是一个非常大而复杂的结构)。所有项目都是2个项目,并符合maven标准。所以我有类似的东西

父pom.xml

<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>

<modules>
    <module>framework</module> 
    <module>server</module> 
    <module>utils</module> 
</modules>

框架pom.xml

<groupId>com.test</groupId>
<artifactId>framework</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>

<modules>
    <module>gui</module> 
    <module>ear</module> 
    <module>libs</module> 
</modules>

如果我从我耳朵的耳部子模块运行mvn clean install,它会按预期构建。 当我从框架运行我的mvn clean install时,我得到了相同的结果。 但是当我从顶层运行时,我的耳朵中包含了我不想要的其他库(我将它们排除在我的耳朵pom.xml中)。 有什么想法吗?

编辑: 我以经典的方式排除了我耳中不需要的库

<dependency>
    <groupId>ear.dependency</groupId>
    <artifactId>dep1</artifactId>
    <exclusions>
        <exclusion>
             <groupId>unwanted.lib</groupId>
             <artifactId>lib1</artifactId>
        </exclusion>
    </exclusions>
</dependency>

我还比较了mvn依赖:来自顶级pom和框架pom的树,关于耳节,它们是相同的

1 个答案:

答案 0 :(得分:0)

尝试从根目录和mvn help:effective-pom -pl :ear文件夹运行framework。比较两个输出。