【问题标题】:How can I switch off a profile during perform goal of the maven-release-plugin如何在执行 maven-release-plugin 目标期间关闭配置文件
【发布时间】:2014-01-15 13:46:15
【问题描述】:

在正常开发过程中,我需要执行某个构建功能。在发布期间,该构建功能需要替换为发布等效项(在这种情况下是 Proguard 而不是复制)。

我认为我可以使用 2 个配置文件,一个 DevelopmentProfile 和一个 ReleaseProfile,并且 DevelopmentProfile 是 activeByDefault。

例如

<profiles>
    <profile>
        <id>DevelopmentProfile</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <developmentBuild>true</developmentBuild>
            <releaseBuild>false</releaseBuild>
        </properties>
    </profile>
    <profile>
        <id>ReleaseProfile</id>
        <properties>
            <developmentBuild>false</developmentBuild>
            <releaseBuild>true</releaseBuild>
        </properties>
    </profile>
</profiles>

并通过 release-plugin releaseProfiles 属性打开 ReleaseProfile,并通过 releaseProfiles 属性关闭 ReleaseProfile

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
        <releaseProfiles>ReleaseProfile,!DevelopmentProfile</releaseProfiles>
    </configuration>
</plugin>

考虑到这篇关于“停用配置文件”http://maven.apache.org/guides/introduction/introduction-to-profiles.html 的文章以及发布插件的源只是使用提供的字符串构造配置文件这一事实,这看起来是可行的。

但它似乎不起作用。我怀疑是因为发布插件预先添加了活动配置文件,这可能会覆盖配置文件停用。

无论如何。有没有另一种方法可以在发布期间停用配置文件。或者以其他方式确保在任何时候只有这 2 个配置文件中的一个处于活动状态。

而且我对涉及我传递系统属性以显式激活配置文件的解决方案不感兴趣,因为它们不够强大,无法承受这里的工作负载。

【问题讨论】:

    标签: maven-3 maven-release-plugin maven-profiles


    【解决方案1】:

    好的,我上面所做的一切都是 100% 正确的。 正如我在上面所做的那样,您绝对可以在发布期间停用配置文件。

    它对我不起作用的原因是因为显示的发布插件配置已在子 pom 中指定,而父 pom 要么重载了 releaseProfiles 的值,要么完全控制了。

    因此,将我的配置移至父级使一切正常。

    【讨论】:

      猜你喜欢
      • 2020-04-20
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-12
      • 1970-01-01
      相关资源
      最近更新 更多