maven标签(1)— profile+module指定操作版本

2021-11-04  本文已影响0人  小胖学编程

多模块项目中,我们需要对某些模块进行操作,例如对api模块进行delpoy操作等等。可以通过mvn -P参数的不同来选择不同的策略。

例子:微服务项目中,需要发布api的包,但是其他模块我们并不希望打包。

方案一

在对应的模块执行deploy命令

方案一.png

方案二

要自动化的发布(自动化发布,可以使用release插件)。但是如何只发布api模块呢?

模式一:其他模块引入如下插件,即跳过deploy操作。

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M1</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

模式二:利用profile+module

增加一个profile,如:

<profiles>      
  <profile>
            <id>patch_001</id>
            <properties>
                
            </properties>
            <modules>
                <module>module_three</module>
                <module>module_five</module>
                <module>module_seven</module>
            </modules>
        </profile>
</profiles>

maven多模块profiles的石使用

方式二.png
上一篇 下一篇

猜你喜欢

热点阅读