如何通过Maven命令行完全跳过central-publishing-maven-plugin?
问题
是否可以通过命令行参数让Maven执行时完全跳过central-publishing-maven-plugin?例如使用类似mvn -DcentralPublishing.skip=true的命令?
我了解到可以使用skipPublishing配置参数,但该参数需要修改pom.xml,且即使设置后插件仍会运行。附上当前插件配置:
<plugin> <groupId>org.sonatype.central</groupId> <artifactId>central-publishing-maven-plugin</artifactId> <version>0.8.0</version> <extensions>true</extensions> <executions> <execution> <id>central-publishing</id> <phase>none</phase> </execution> </executions> <configuration> <publishingServerId>ossrh</publishingServerId> <skipPublishing>true</skipPublishing> </configuration> </plugin>
解决方案
完全跳过插件执行(推荐):使用Maven插件通用的跳过参数,直接在命令行执行:
mvn clean install -Dcentral-publishing-maven-plugin.skip=true这个参数会让Maven完全跳过该插件的所有执行逻辑,包括初始化和配置加载,比
skipPublishing更彻底。自定义参数控制(需微调pom):如果偏好使用
-DcentralPublishing.skip=true这类自定义参数,可修改插件配置将skipPublishing绑定到系统属性:<configuration> <publishingServerId>ossrh</publishingServerId> <skipPublishing>${centralPublishing.skip:false}</skipPublishing> </configuration>之后就能用
mvn clean install -DcentralPublishing.skip=true跳过发布步骤,但注意这种方式下插件仍会被加载初始化,仅跳过发布动作。
内容的提问来源于stack exchange,提问作者Pat
相关产品推荐
相关产品推荐

