首页 > 解决方案 > 从 Maven 中的计算机属性设置 GAE 应用程序版本

问题描述

我想通过使用maven-build-helper-plugin regex-property目标将 Maven POM 版本转换为有效的 GAE 版本字符串(小写,只有字母数字字符和下划线),从 POM 的版本中导出我的 AppEngine 标准应用程序的版本。

所以在POM中我试图这样做:

<groupId>foobar.tests</groupId>
<artifactId>version-test</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>compute-gae-version</id>
                    <goals>
                        <goal>regex-property</goal>
                    </goals>
                    <configuration>
                        <name>gae.version</name>
                        <regex>[^A-Za-z0-9]+</regex>
                        <value>${project.version}</value>
                        <replacement>-</replacement>
                        <failIfNoMatch>false</failIfNoMatch>
                        <toLowerCase>true</toLowerCase>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.3.2</version>
            <configuration>
                <deploy.version>${gae.version}</deploy.version>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1</version>
        </plugin>

    </plugins>
</build>

<dependencies>
     [...]
</dependencies>

当然它不起作用:应用程序使用默认的时间戳计算版本标签进行部署。我知道这是因为configurationAppEngine 插件的块在 build-helper 运行之前得到了早期评估。

有没有办法来解决这个问题?

标签: google-app-enginemaven-3

解决方案


我相信这与这篇文章中的问题相同。

mvn build-helper:regex-property appengine:deploy按照 fboulay 的建议,将配置块移出执行块,并用于部署 GAE 应用程序版本。


推荐阅读