Maven 多模块和配置文件

问题描述 投票:0回答:1

我不明白如何管理模块和配置文件。有人能给我解释一下吗?

例如在父pom中我添加了5个模块,因为我有这样的结构

parent
    db
    common
    core
    security
    web

我只想在core模块中开始测试,该模块依赖于除web之外的另一个模块。我想用一些配置文件来做。

我认为它看起来像在parent.pom中

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    <profile>
        <id>core-no-test</id>
        <build><plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
                <skipTests>true</skipTests>
             </configuration>
       </plugin>
       </plugins></build>
    </profile>
... another profiles
</profiles>

这里也适用于 db 我想创建集成测试,它不应该从整个项目开始,而只能从特定的配置文件开始。

还有很多其他的想法和任务,但应该如何解决?

这就像父pom中的东西

<profile>
...
<modules><module>db</module></modules>
<build><plugins>...</plugins></build>

Ant 将逻辑放入父 pom 中的每个配置文件中,还是应该将每个特定构建划分到每个子 pom 中?以及如何开始呢?

java maven devops
1个回答
0
投票

您可以使用以下命令行选项来执行此操作,而无需修改 POM:

mvn -pl core -am test

请参阅 CLI 选项的完整参考:https://maven.apache.org/ref/3.9.9/maven-embedder/cli.html

© www.soinside.com 2019 - 2024. All rights reserved.