小编res*_*res的帖子

在pom.xml中将变量子字符串化

是否有可能(以及如何)在pom.xml或使用此变量的属性中为变量添加子字符串?

我的情况:

我有一个swing应用程序,在其页脚中显示了一种版本。此版本是从属性文件中读取的。该属性文件仅具有maven变量的引用,例如:

version=${git.branch}
Run Code Online (Sandbox Code Playgroud)

在我的pom.xml中,有一个插件来查找分支名称,并将其写入“ git.branch”变量中。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>pl.project13.maven</groupId>
            <artifactId>git-commit-id-plugin</artifactId>
            <version>2.2.2</version>
            <configuration>
                <dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
                <injectAllReactorProjects>true</injectAllReactorProjects>
            </configuration>
            <executions>
                <execution>
                    <id>get-the-git-infos</id>
                    <goals>
                        <goal>revision</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/version.properties</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <excludes>
                <exclude>**/version.properties</exclude>
            </excludes>
        </resource>
    </resources>
</build>
Run Code Online (Sandbox Code Playgroud)

但是现在我们在分支名称中使用前缀,并且该前缀不应与应用程序版本一起部署。

我有类似的分支:

v123
v124
v125
Run Code Online (Sandbox Code Playgroud)

现在我有类似的分支:

b_04_v123
b_04_v124
Run Code Online (Sandbox Code Playgroud)

而且我希望Maven仅获取字符串“ b_04_v123”的值“ v124”,前缀是固定的,就像“ b_NN_”一样。

注意:否,无法更改分支名称,因为其他部门将它们与脚本和自动化一起使用。

build version pom.xml maven

3
推荐指数
2
解决办法
1592
查看次数

标签 统计

build ×1

maven ×1

pom.xml ×1

version ×1