复杂的maven项目依赖项被多次编译

时间:2013-05-28 08:41:59

标签: java maven

<project (...)>
    <modelVersion>4.0.0</modelVersion>

    <groupId>our.group.id</groupId>
    <artifactId>parent.of.all</artifactId>
    <version>3.2.2-SNAPSHOT</version>
    <packaging>pom</packaging>
    <url>http://maven.apache.org</url>

    <modules>
        <module>module-common</module>
        <module>module-A</module>
        <module>module-B</module>
        <module>module-C</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                (... - some external dependecies...)
            </dependency>
            <dependency>
                (... - some external dependecies...)
            </dependency>
            <dependency>
                (... - some external dependecies...)
            </dependency>

            <dependency>
                <groupId>our.group.id</groupId>
                <artifactId>module-common</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>our.group.id</groupId>
                <artifactId>module-A</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>our.group.id</groupId>
                <artifactId>module-B</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>our.group.id</groupId>
                <artifactId>module-C</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

这是项目的主要内容,在一些模块中module-common module-A module-B module-C

我面临的问题是,由于模块之间存在内部依赖关系,因此大多数情况都是经过多次编译和测试的。

<project (...)>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>our.group.id</groupId>
        <artifactId>parent.of.all</artifactId>
        <version>3.2.2-SNAPSHOT</version>
    </parent>

    <artifactId>module-B</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            (... - some external dependecies...)
        </dependency>

        <dependency> <!-- internal dependency to other module -->
            <groupId>our.group.id</groupId>
            <artifactId>module-common</artifactId>
        </dependency>
    </dependencies>
</project>

依赖关系越多,构建项目所需的时间就越长。如何防止maven在多次完成的相同模块上进行完全安装?

0 个答案:

没有答案