簡體   English   中英

maven release plugin忽略releaseProfile

[英]maven release plugin ignores releaseProfile

我使用兩個配置文件:開發和生產。

開發應在默認情況下有效; 我發布時應該使用生產。

在我的pom.xml中,我有:

[...]
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
<configuration>
  <useReleaseProfile>false</useReleaseProfile>
  <goals>deploy</goals>
  <arguments>-Pproduction</arguments>
</configuration>
</plugin>
[...]
<profiles>
  <profile>
    <id>production</id>
    <properties>
      <profile.name>production</profile.name>
    </properties>
    [...]
  </profile>
  <profile>
    <id>development</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
    <profile.name>development</profile.name>
    </properties>
       [...]
  </profile>
[...]

它只是不起作用。
useReleaseProfiles也不起作用: httpuseReleaseProfiles

開發配置文件應該始終處於活動狀態,但在運行mvn release:perform時不會mvn release:perform 你是如何實現這一目標的?

[更新]:我已經看到調試標志使用了我的生產配置文件,但也使用了開發配置文件,因為它是activeByDefault 這不能被releaseProfile參數覆蓋。 強制釋放插件使用“生產”配置文件會很好。

maven-release-plugin 文檔鼓勵使用releaseProfiles配置參數在發布過程中自動調用配置文件。

這是比從命令行手動調用發布配置文件更好的方法。 原因之一是,發布中使用的配置文件將記錄在pom.xml並與標記的代碼一起存儲。 這使得構建過程更容易理解,以后更容易重復,與項目最初發布的方式完全相同。

如果使用早於2.4 maven-release-plugin請參閱此錯誤,以防止使用上述參數。

請注意,在多模塊項目的情況下,您必須將“releaseProfiles”配置放在根pom中! 有關更多信息,請參閱此問題

我認為你應該通過一個屬性來激活你的個人資料。

<profiles>
  <profile>
    <id>production</id>
    <activation>
      <property>
        <name>build</name>
        <value>release</value>
      </property>
    </activation>
    [...]
  </profile>
  <profile>
    <id>development</id>
    <activation>
      <property>
        <name>build</name>
        <value>develop</value>
      </property>
    </activation>
    [...]
  </profile>
<profiles>

通過執行類似的操作來構建您的構建

mvn -Dbuild=develop package
mvn -Dbuild=develop test

mvn -Dbuild=release release:prepare
mvn -Dbuild=release release:perform

如果選中“構建配置文件簡介” ,“取消激活配置文件”:

mvn groupId:artifactId:goal -P !profile-1,!profile-2

我想你可以用這個去激活你的默認配置文件?

這是一篇非常古老的帖子,但我最近才遇到這個問題。 當我將releaseProfiles設置為名為release的配置文件時,releaseProfile僅對我有用。 任何其他配置文件給出相同的錯

示例代碼:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
                <autoVersionSubmodules>true</autoVersionSubmodules>
                <releaseProfiles>release</releaseProfiles>
                <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>release</id>
        <properties>
            <connectionUrl>${scm-base}/tags/${project.artifactId}-${project.version}</connectionUrl>
        </properties>
    </profile>
</profiles>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM