代码之家  ›  专栏  ›  技术社区  ›  Janning Vygen

maven release插件忽略releaseProfile

  •  10
  • Janning Vygen  · 技术社区  · 16 年前

    我使用两个配置文件:开发和生产。

    违约时应积极开发;我发布时应该使用产品。

    [...]
    <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 也不起作用: http://jira.codehaus.org/browse/MRELEASE-459

    开发概要文件应始终处于活动状态,但在运行时不应处于活动状态 mvn release:perform . 你如何做到这一点?

    [更新]: activeByDefault . 这不能被 releaseProfile 只有

    4 回复  |  直到 9 年前
        1
  •  15
  •   Kai    9 年前

    这个 maven-release-plugin documentation releaseProfiles 在发布过程中自动调用配置文件的配置参数。

    这是一种比从命令行手动调用发布概要文件更好的方法。一个原因是,版本中使用的概要文件将记录在 pom.xml

    如果使用 maven发布插件 早于 2.4 看到这个了吗 bug 防止使用上述参数。

    this issue 更多信息。

        2
  •  2
  •   splash    15 年前

    我认为你应该通过一个属性激活你的个人资料。

    <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
    
        3
  •  1
  •   user1553780    13 年前

    "Introduction to Build Profiles"

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

    我想你可以用这个停用你的默认配置文件?

        4
  •  0
  •   Anthonie Botes    8 年前

    这是一个非常老的职位,但我遇到这个问题最近。只有当我将releaseProfiles设置为profile时,releaseProfiles才对我有效

    示例代码:

    <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>
    
    推荐文章