You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 11:25:56